Client: index.html generated within build script
authorDarren <darren@darrenwhitlen.com>
Sun, 4 Nov 2012 01:01:57 +0000 (01:01 +0000)
committerDarren <darren@darrenwhitlen.com>
Sun, 4 Nov 2012 01:01:57 +0000 (01:01 +0000)
client/assets/dev/build.js
client/assets/dev/index.html.tmpl [moved from client/index.html with 93% similarity]

index 738d0d662b54a05689c4968c9299cf115962ef57..44db168c797b3c486b04baa9d5fbaaf89b7e5fc7 100644 (file)
@@ -1,5 +1,7 @@
-var fs = require('fs');\r
-var uglyfyJS = require('uglify-js');\r
+var fs        = require('fs'),\r
+    uglyfyJS  = require('uglify-js'),\r
+    _         = require('underscore'),\r
+    config    = require('./../../../server/configuration.js');\r
 \r
 var FILE_ENCODING = 'utf-8',\r
     EOL = '\n';\r
@@ -14,6 +16,18 @@ function concat(src) {
     return out.join(EOL);\r
 }\r
 \r
+\r
+\r
+config.loadConfig();\r
+\r
+\r
+\r
+\r
+\r
+/**\r
+ * Build the kiwi.js files\r
+ */\r
+\r
 var src = concat([\r
     __dirname + '/app.js',\r
     __dirname + '/model_application.js',\r
@@ -50,4 +64,32 @@ fs.writeFileSync(__dirname + '/../kiwi.min.js', uglyfyJS.uglify.gen_code(src), F
 \r
 \r
 \r
-console.log(' kiwi.js and kiwi.min.js built');
\ No newline at end of file
+console.log('kiwi.js and kiwi.min.js built');\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+/**\r
+ * Build the index.html file\r
+ */\r
+\r
+var index_src = fs.readFileSync(__dirname + '/index.html.tmpl', FILE_ENCODING);\r
+var vars = {\r
+    base_path: config.get().http_base_path,\r
+    cache_buster: Math.ceil(Math.random() * 9000).toString()\r
+};\r
+\r
+_.each(vars, function(value, key) {\r
+    index_src = index_src.replace(new RegExp('<%' + key + '%>', 'g'), value);\r
+});\r
+\r
+fs.writeFileSync(__dirname + '/../../index.html', index_src, FILE_ENCODING);\r
+\r
+\r
+console.log('index.html built');
\ No newline at end of file
similarity index 93%
rename from client/index.html
rename to client/assets/dev/index.html.tmpl
index 76468a509143c0e74d1c5fc03cee1e95cad431a3..35921d15b0adf93ea12a1cf13768d8ee7acc81f5 100644 (file)
-<!DOCTYPE html>
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
-<base target="_blank">
-
-<title> KiwiIRC </title>
-
-<link rel="stylesheet" type="text/css" href="/kiwi/assets/css/style.css" />
-<link rel="stylesheet" type="text/css" href="/kiwi/assets/css/font-awesome.css" />
-<!--[if IE 7]>
-<link rel="stylesheet" type="text/css" href="/kiwi/assets/css/font-awesome-ie7.css" />
-<![endif]-->
-</head>
-<body>
-    <div id="kiwi" class="theme_relaxed">
-        <div id="toolbar">
-            <div class="app_tools">
-                <ul class="main">
-                    <li class="settings"><i class="icon-cogs" title="Settings"></i></li>
-                    <li><a href="http://kiwiirc.com/" target="_blank"><img src="/kiwi/assets/img/ico.png" alt="KiwiIRC" title="KiwiIRC" /></a></li>
-                </ul>
-            </div>
-
-            <div id="tabs">
-                <ul class="panellist channels"></ul>
-                <ul class="panellist applets"></ul>
-            </div>
-
-            <div id="topic">
-                <div contenteditable="true"></div>
-            </div>
-
-            <div id="status_message"></div>
-        </div>
-
-        <div id="memberlists_resize_handle"></div>
-
-        <div id="panels">
-            <div class="panel_container container1"></div>
-        </div>
-
-        <div id="memberlists"></div>
-
-        <div id="controlbox">
-            <div class="input">
-                <span class="nick"> </span>
-                <div class="input_wrap"><textarea class="inp"></textarea></div>
-            </div>
-        </div>
-    </div>
-
-
-
-
-
-    
-    <script type="text/html" id="tmpl_userbox">
-        <div class="userbox">
-            <a class="query"><i class="icon-comment"></i>Message</a>
-            <a class="info"><i class="icon-info-sign"></i>Info</a>
-            <a class="slap"><i class="icon-user-md"></i>Slap!</a>
-
-            <div class="divider-horizontal"></div>
-        </div>
-    </script>
-    
-    <script type="text/html" id="tmpl_nickchange">
-        <form class="nickchange">
-            <label for="nickchange">New nick:</label> <input type="text" mozactionhint="done" autocomplete="off" spellcheck="false"/> <button>Change</button> <a class="cancel">Cancel</a>
-        </form>
-    </script>
-
-    <script type="text/html" id="tmpl_server_select">
-        <div class="server_select">
-
-            <div style="position:relative;float:left;width:320px;padding-right:3em;margin-top:50px;">
-                <div class="status">Think of a nickname..</div>
-
-                <form>
-                    <div class="basic">
-                        <label for="server_select_nick">Nickname</label>
-                        <input type="text" class="nick" id="server_select_nick"> <br />
-
-                        <button type="submit">Start..</button> <br />
-                        <a href="" onclick="return false;" class="show_more">More</a>
-                    </div>
-
-                    <div class="more">
-                        <label for="server_select_server">Server</label>
-                        <input type="text" class="server" id="server_select_server"> <br />
-                        <label for="server_select_channel">Channel</label>
-                        <input type="text" class="channel" id="server_select_channel"> <br />
-                        <input type="hidden" class="channel_key">
-                        <br />
-                        <label for="server_select_port">Port</label>
-                        <input type="text" class="port" id="server_select_port"> <br />
-                        <label for="server_select_password">Password</label>
-                        <input type="text" class="password" id="server_select_password"> <br />
-                        <label for="server_select_ssl">SSL</label>
-                        <input type="checkbox" class="ssl" id="server_select_ssl">
-                    </div>
-                </form>
-
-                <div class="divider-verticle"></div>
-            </div>
-
-            <div style="position:relative;float:left;width:320px;margin-left:3em;color:#555555;">
-                <a class="kiwi_logo" href="http://www.kiwiirc.com/" target="_blank">
-                    <img src="/kiwi/assets/img/ico.png" alt="KiwiIRC Logo" title="Kiwi IRC" /> <br />
-                    <h1>Powered by Kiwi IRC</h1>
-                </a>
-
-                <p style="font-style:italic;">A <strong>hand-crafted IRC client</strong> that you can enjoy. Designed to be used <strong>easily</strong> and <strong>freely</strong>.</p>
-
-                <p style="font-size:0.9em;margin-top:2em;">Peek at the <a href="http://www.kiwiirc.com/">Kiwi IRC homepage</a> for more information or to find out how to embed it on your own website. Looking for source code? Try the <a href="http://github.com/prawnsalad/KiwiIRC/">GitHub</a> page. This network of people may not be associated with Kiwi IRC itself.</p>
-            </div>
-        </div>
-    </script>
-
-    <script type="text/html" id="tmpl_applet_settings">
-        <div>
-            <select class="theme">
-                <option value="default">Default</option>
-                <option value="relaxed">Relaxed</option>
-                <option value="cli">CLI</option>
-            </select>
-            <button class="save">Save</button>
-        </div>
-    </script>
-
-
-    <script type="text/html" id="tmpl_channel_list">
-        <div>
-            <table style="margin:1em 2em;">
-                <thead style="font-weight: bold;">
-                    <tr>
-                        <td>Channel Name</td>
-                        <td>Users</td>
-                        <td style="padding-left: 2em;">Topic</td>
-                    </tr>
-                </thead>
-                <tbody style="vertical-align: top;">
-                </tbody>
-            </table>
-        </div>
-    </script>
-
-
-<script>
-/* Script loader (https://github.com/ded/script.js) */
-(function(a,b,c){typeof c["module"]!="undefined"&&c.module.exports?c.module.exports=b():typeof c["define"]!="undefined"&&c["define"]=="function"&&c.define.amd?define(a,b):c[a]=b()})("$script",function(){function p(a,b){for(var c=0,d=a.length;c<d;++c)if(!b(a[c]))return j;return 1}function q(a,b){p(a,function(a){return!b(a)})}function r(a,b,i){function o(a){return a.call?a():d[a]}function t(){if(!--n){d[m]=1,l&&l();for(var a in f)p(a.split("|"),o)&&!q(f[a],o)&&(f[a]=[])}}a=a[k]?a:[a];var j=b&&b.call,l=j?b:i,m=j?a.join(""):b,n=a.length;return setTimeout(function(){q(a,function(a){if(h[a])return m&&(e[m]=1),h[a]==2&&t();h[a]=1,m&&(e[m]=1),s(!c.test(a)&&g?g+a+".js":a,t)})},0),r}function s(c,d){var e=a.createElement("script"),f=j;e.onload=e.onerror=e[o]=function(){if(e[m]&&!/^c|loade/.test(e[m])||f)return;e.onload=e[o]=null,f=1,h[c]=2,d()},e.async=1,e.src=c,b.insertBefore(e,b.firstChild)}var a=document,b=a.getElementsByTagName("head")[0],c=/^https?:\/\//,d={},e={},f={},g,h={},i="string",j=!1,k="push",l="DOMContentLoaded",m="readyState",n="addEventListener",o="onreadystatechange";return!a[m]&&a[n]&&(a[n](l,function t(){a.removeEventListener(l,t,j),a[m]="complete"},j),a[m]="loading"),r.get=s,r.order=function(a,b,c){(function d(e){e=a.shift(),a.length?r(e,d):r(e,b,c)})()},r.path=function(a){g=a},r.ready=function(a,b,c){a=a[k]?a:[a];var e=[];return!q(a,function(a){d[a]||e[k](a)})&&p(a,function(a){return d[a]})?b():!function(a){f[a]=f[a]||[],f[a][k](b),c&&c(e)}(a.join("|")),r},r},this)
-
-
-
-
-    function getQueryVariable(variable) {
-        var query = window.location.search.substring(1);
-        var vars = query.split('&');
-        for (var i = 0; i < vars.length; i++) {
-            var pair = vars[i].split('=');
-            if (decodeURIComponent(pair[0]) == variable) {
-                return decodeURIComponent(pair[1]);
-            }
-        }
-    }
-
-    window.onload = function () {
-
-        // Common dependancies that are required at all times
-        var scripts = [
-            ['jquery-1.8.2.min.js', 'underscore.min.js'],
-            'backbone.min.js'
-        ];
-
-        // If in debug mode, load each development script
-        if (getQueryVariable('debug')) {
-            console.log('Loading debugging scripts');
-            scripts = scripts.concat([
-                'dev/app.js',
-                [
-                    'dev/model_application.js',
-                    'dev/model_gateway.js'
-                ],
-                [
-                    'dev/model_panellist.js',
-                    'dev/model_panel.js',
-                    'dev/model_member.js',
-                    'dev/model_memberlist.js'
-                ],
-                
-                [
-                    'dev/model_query.js',
-                    'dev/model_channel.js',
-                    'dev/model_server.js',
-                    'dev/model_applet.js'
-                ],
-
-                [
-                    'dev/applet_settings.js',
-                    'dev/applet_nickserv.js',
-                    'dev/applet_chanlist.js'
-                ],
-
-                [
-                    'dev/utils.js',
-                    'dev/view.js'
-                ]
-            ]);
-        } else {
-            scripts.push('kiwi.js');
-        }
-
-
-        // Run after all dependancies have been loaded
-        function startApp () {
-            var opts = {
-                container: $('#kiwi'),
-                base_path: base_path
-
-                // Override the kiwi_server to use. (Think: running on standalone client..)
-                //kiwi_server: 'http://kiwiirc.com:80'
-            };
-
-            // Start the app by either the dev or closed environment
-            (kiwi && kiwi.global && kiwi.global.start(opts)) || (kiwi && kiwi.start(opts));
-        }
-
-
-        // Load each script
-        var cur_script = 0;
-        function loadNextScript () {
-            var to_load,
-                base = base_path + '/assets/';
-
-            // Start the kiwi app if all scripts have been loaded
-            if (cur_script === scripts.length) {
-                startApp();
-                return;
-            }
-
-            if (typeof scripts[cur_script] === 'string') {
-                to_load = base + scripts[cur_script];
-            } else {
-                to_load = [];
-                for(var idx in scripts[cur_script]) {
-                    to_load.push(base + scripts[cur_script][idx]);
-                }
-            }
-            
-            $script(to_load, loadNextScript);
-
-            cur_script++;
-        }
-
-        // Entry path for the kiwi application
-        var base_path = '/kiwi';
-
-        // Start loading scripts
-        loadNextScript();
-    };
-</script>
-</body>
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> \r
+<base target="_blank">\r
+\r
+<title> KiwiIRC </title>\r
+\r
+<link rel="stylesheet" type="text/css" href="<%base_path%>/assets/css/style.css" />\r
+<link rel="stylesheet" type="text/css" href="<%base_path%>/assets/css/font-awesome.css" />\r
+<!--[if IE 7]>\r
+<link rel="stylesheet" type="text/css" href="/kiwi/assets/css/font-awesome-ie7.css" />\r
+<![endif]-->\r
+</head>\r
+<body>\r
+    <div id="kiwi" class="theme_relaxed">\r
+        <div id="toolbar">\r
+            <div class="app_tools">\r
+                <ul class="main">\r
+                    <li class="settings"><i class="icon-cogs" title="Settings"></i></li>\r
+                    <li><a href="http://kiwiirc.com/" target="_blank"><img src="<%base_path%>/assets/img/ico.png" alt="KiwiIRC" title="KiwiIRC" /></a></li>\r
+                </ul>\r
+            </div>\r
+\r
+            <div id="tabs">\r
+                <ul class="panellist channels"></ul>\r
+                <ul class="panellist applets"></ul>\r
+            </div>\r
+\r
+            <div id="topic">\r
+                <div contenteditable="true"></div>\r
+            </div>\r
+\r
+            <div id="status_message"></div>\r
+        </div>\r
+\r
+        <div id="memberlists_resize_handle"></div>\r
+\r
+        <div id="panels">\r
+            <div class="panel_container container1"></div>\r
+        </div>\r
+\r
+        <div id="memberlists"></div>\r
+\r
+        <div id="controlbox">\r
+            <div class="input">\r
+                <span class="nick"> </span>\r
+                <div class="input_wrap"><textarea class="inp"></textarea></div>\r
+            </div>\r
+        </div>\r
+    </div>\r
+\r
+\r
+\r
+\r
+\r
+    \r
+    <script type="text/html" id="tmpl_userbox">\r
+        <div class="userbox">\r
+            <a class="query"><i class="icon-comment"></i>Message</a>\r
+            <a class="info"><i class="icon-info-sign"></i>Info</a>\r
+            <a class="slap"><i class="icon-user-md"></i>Slap!</a>\r
+\r
+            <div class="divider-horizontal"></div>\r
+        </div>\r
+    </script>\r
+    \r
+    <script type="text/html" id="tmpl_nickchange">\r
+        <form class="nickchange">\r
+            <label for="nickchange">New nick:</label> <input type="text" mozactionhint="done" autocomplete="off" spellcheck="false"/> <button>Change</button> <a class="cancel">Cancel</a>\r
+        </form>\r
+    </script>\r
+\r
+    <script type="text/html" id="tmpl_server_select">\r
+        <div class="server_select">\r
+\r
+            <div style="position:relative;float:left;width:320px;padding-right:3em;margin-top:50px;">\r
+                <div class="status">Think of a nickname..</div>\r
+\r
+                <form>\r
+                    <div class="basic">\r
+                        <label for="server_select_nick">Nickname</label>\r
+                        <input type="text" class="nick" id="server_select_nick"> <br />\r
+\r
+                        <button type="submit">Start..</button> <br />\r
+                        <a href="" onclick="return false;" class="show_more">More</a>\r
+                    </div>\r
+\r
+                    <div class="more">\r
+                        <label for="server_select_server">Server</label>\r
+                        <input type="text" class="server" id="server_select_server"> <br />\r
+                        <label for="server_select_channel">Channel</label>\r
+                        <input type="text" class="channel" id="server_select_channel"> <br />\r
+                        <input type="hidden" class="channel_key">\r
+                        <br />\r
+                        <label for="server_select_port">Port</label>\r
+                        <input type="text" class="port" id="server_select_port"> <br />\r
+                        <label for="server_select_password">Password</label>\r
+                        <input type="text" class="password" id="server_select_password"> <br />\r
+                        <label for="server_select_ssl">SSL</label>\r
+                        <input type="checkbox" class="ssl" id="server_select_ssl">\r
+                    </div>\r
+                </form>\r
+\r
+                <div class="divider-verticle"></div>\r
+            </div>\r
+\r
+            <div style="position:relative;float:left;width:320px;margin-left:3em;color:#555555;">\r
+                <a class="kiwi_logo" href="http://www.kiwiirc.com/" target="_blank">\r
+                    <img src="<%base_path%>/assets/img/ico.png" alt="KiwiIRC Logo" title="Kiwi IRC" /> <br />\r
+                    <h1>Powered by Kiwi IRC</h1>\r
+                </a>\r
+\r
+                <p style="font-style:italic;">A <strong>hand-crafted IRC client</strong> that you can enjoy. Designed to be used <strong>easily</strong> and <strong>freely</strong>.</p>\r
+\r
+                <p style="font-size:0.9em;margin-top:2em;">Peek at the <a href="http://www.kiwiirc.com/">Kiwi IRC homepage</a> for more information or to find out how to embed it on your own website. Looking for source code? Try the <a href="http://github.com/prawnsalad/KiwiIRC/">GitHub</a> page. This network of people may not be associated with Kiwi IRC itself.</p>\r
+            </div>\r
+        </div>\r
+    </script>\r
+\r
+    <script type="text/html" id="tmpl_applet_settings">\r
+        <div>\r
+            <select class="theme">\r
+                <option value="default">Default</option>\r
+                <option value="relaxed">Relaxed</option>\r
+                <option value="cli">CLI</option>\r
+            </select>\r
+            <button class="save">Save</button>\r
+        </div>\r
+    </script>\r
+\r
+\r
+    <script type="text/html" id="tmpl_channel_list">\r
+        <div>\r
+            <table style="margin:1em 2em;">\r
+                <thead style="font-weight: bold;">\r
+                    <tr>\r
+                        <td>Channel Name</td>\r
+                        <td>Users</td>\r
+                        <td style="padding-left: 2em;">Topic</td>\r
+                    </tr>\r
+                </thead>\r
+                <tbody style="vertical-align: top;">\r
+                </tbody>\r
+            </table>\r
+        </div>\r
+    </script>\r
+\r
+\r
+<script>\r
+/* Script loader (https://github.com/ded/script.js) */\r
+(function(a,b,c){typeof c["module"]!="undefined"&&c.module.exports?c.module.exports=b():typeof c["define"]!="undefined"&&c["define"]=="function"&&c.define.amd?define(a,b):c[a]=b()})("$script",function(){function p(a,b){for(var c=0,d=a.length;c<d;++c)if(!b(a[c]))return j;return 1}function q(a,b){p(a,function(a){return!b(a)})}function r(a,b,i){function o(a){return a.call?a():d[a]}function t(){if(!--n){d[m]=1,l&&l();for(var a in f)p(a.split("|"),o)&&!q(f[a],o)&&(f[a]=[])}}a=a[k]?a:[a];var j=b&&b.call,l=j?b:i,m=j?a.join(""):b,n=a.length;return setTimeout(function(){q(a,function(a){if(h[a])return m&&(e[m]=1),h[a]==2&&t();h[a]=1,m&&(e[m]=1),s(!c.test(a)&&g?g+a+".js":a,t)})},0),r}function s(c,d){var e=a.createElement("script"),f=j;e.onload=e.onerror=e[o]=function(){if(e[m]&&!/^c|loade/.test(e[m])||f)return;e.onload=e[o]=null,f=1,h[c]=2,d()},e.async=1,e.src=c,b.insertBefore(e,b.firstChild)}var a=document,b=a.getElementsByTagName("head")[0],c=/^https?:\/\//,d={},e={},f={},g,h={},i="string",j=!1,k="push",l="DOMContentLoaded",m="readyState",n="addEventListener",o="onreadystatechange";return!a[m]&&a[n]&&(a[n](l,function t(){a.removeEventListener(l,t,j),a[m]="complete"},j),a[m]="loading"),r.get=s,r.order=function(a,b,c){(function d(e){e=a.shift(),a.length?r(e,d):r(e,b,c)})()},r.path=function(a){g=a},r.ready=function(a,b,c){a=a[k]?a:[a];var e=[];return!q(a,function(a){d[a]||e[k](a)})&&p(a,function(a){return d[a]})?b():!function(a){f[a]=f[a]||[],f[a][k](b),c&&c(e)}(a.join("|")),r},r},this)\r
+\r
+\r
+\r
+\r
+    function getQueryVariable(variable) {\r
+        var query = window.location.search.substring(1);\r
+        var vars = query.split('&');\r
+        for (var i = 0; i < vars.length; i++) {\r
+            var pair = vars[i].split('=');\r
+            if (decodeURIComponent(pair[0]) == variable) {\r
+                return decodeURIComponent(pair[1]);\r
+            }\r
+        }\r
+    }\r
+\r
+    window.onload = function () {\r
+\r
+        // Common dependancies that are required at all times\r
+        var scripts = [\r
+            ['jquery-1.8.2.min.js', 'underscore.min.js'],\r
+            'backbone.min.js'\r
+        ];\r
+\r
+        // If in debug mode, load each development script\r
+        if (getQueryVariable('debug')) {\r
+            console.log('Loading debugging scripts');\r
+            scripts = scripts.concat([\r
+                'dev/app.js',\r
+                [\r
+                    'dev/model_application.js',\r
+                    'dev/model_gateway.js'\r
+                ],\r
+                [\r
+                    'dev/model_panellist.js',\r
+                    'dev/model_panel.js',\r
+                    'dev/model_member.js',\r
+                    'dev/model_memberlist.js'\r
+                ],\r
+                \r
+                [\r
+                    'dev/model_query.js',\r
+                    'dev/model_channel.js',\r
+                    'dev/model_server.js',\r
+                    'dev/model_applet.js'\r
+                ],\r
+\r
+                [\r
+                    'dev/applet_settings.js',\r
+                    'dev/applet_nickserv.js',\r
+                    'dev/applet_chanlist.js'\r
+                ],\r
+\r
+                [\r
+                    'dev/utils.js',\r
+                    'dev/view.js'\r
+                ]\r
+            ]);\r
+        } else {\r
+            scripts.push('kiwi.min.js?<%cache_buster%>');\r
+        }\r
+\r
+\r
+        // Run after all dependancies have been loaded\r
+        function startApp () {\r
+            var opts = {\r
+                container: $('#kiwi'),\r
+                base_path: base_path\r
+\r
+                // Override the kiwi_server to use. (Think: running on standalone client..)\r
+                //kiwi_server: 'http://kiwiirc.com:80'\r
+            };\r
+\r
+            // Start the app by either the dev or closed environment\r
+            (kiwi && kiwi.global && kiwi.global.start(opts)) || (kiwi && kiwi.start(opts));\r
+        }\r
+\r
+\r
+        // Load each script\r
+        var cur_script = 0;\r
+        function loadNextScript () {\r
+            var to_load,\r
+                base = base_path + '/assets/';\r
+\r
+            // Start the kiwi app if all scripts have been loaded\r
+            if (cur_script === scripts.length) {\r
+                startApp();\r
+                return;\r
+            }\r
+\r
+            if (typeof scripts[cur_script] === 'string') {\r
+                to_load = base + scripts[cur_script];\r
+            } else {\r
+                to_load = [];\r
+                for(var idx in scripts[cur_script]) {\r
+                    to_load.push(base + scripts[cur_script][idx]);\r
+                }\r
+            }\r
+            \r
+            $script(to_load, loadNextScript);\r
+\r
+            cur_script++;\r
+        }\r
+\r
+        // Entry path for the kiwi application\r
+        var base_path = '<%base_path%>';\r
+\r
+        // Start loading scripts\r
+        loadNextScript();\r
+    };\r
+</script>\r
+</body>\r
 </html>
\ No newline at end of file