Skip to content

Commit 6f2f03e

Browse files
committed
App: Organize it in app/src and external, build into app/dist
Move everything from app/resources into app/src and external/, given that all files on external/ should be fetched by bower. Ref #228
1 parent 3538b6e commit 6f2f03e

File tree

104 files changed

+135
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+135
-70
lines changed

.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
app/resources/download.all.min.js
2-
app/resources/themeroller.all.min.js
3-
app/src/template
1+
app/dist
2+
external
43
jquery-ui
54
log/downloads.log
65
node_modules

Gruntfile.js

+33-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module.exports = function( grunt ) {
66

77
"use strict";
88
grunt.loadNpmTasks( "grunt-check-modules" );
9+
grunt.loadNpmTasks( "grunt-contrib-clean" );
10+
grunt.loadNpmTasks( "grunt-contrib-copy" );
911
grunt.loadNpmTasks( "grunt-contrib-handlebars" );
1012
grunt.loadNpmTasks( "grunt-contrib-jshint" );
1113
grunt.loadNpmTasks( "grunt-contrib-uglify" );
@@ -23,8 +25,8 @@ grunt.initConfig({
2325
},
2426
compile: {
2527
files: {
26-
"app/src/template/download.js": [ "template/download/components.html", "template/download/service_status.html", "template/download/theme.html" ],
27-
"app/src/template/themeroller.js": [ "template/themeroller/rollyourown.html", "template/themeroller/_rollyourown_group_corner.html", "template/themeroller/_rollyourown_group_default.html", "template/themeroller/_rollyourown_group_dropshadow.html", "template/themeroller/_rollyourown_group_font.html", "template/themeroller/_rollyourown_group_modaloverlay.html" ]
28+
"tmp/app/template/download.js": [ "template/download/components.html", "template/download/service_status.html", "template/download/theme.html" ],
29+
"tmp/app/template/themeroller.js": [ "template/themeroller/rollyourown.html", "template/themeroller/_rollyourown_group_corner.html", "template/themeroller/_rollyourown_group_default.html", "template/themeroller/_rollyourown_group_dropshadow.html", "template/themeroller/_rollyourown_group_font.html", "template/themeroller/_rollyourown_group_modaloverlay.html" ]
2830
}
2931
}
3032
},
@@ -48,20 +50,43 @@ grunt.initConfig({
4850
undef: true
4951
}
5052
},
53+
copy: {
54+
appExternal: {
55+
expand: true,
56+
cwd: "external",
57+
src: [ "farbtastic.css", "lzma_worker.min.js" ],
58+
dest: "app/dist/external"
59+
},
60+
appImages: {
61+
expand: true,
62+
cwd: "app/src",
63+
src: [ "images/**/*" ],
64+
dest: "app/dist"
65+
},
66+
appStyles: {
67+
expand: true,
68+
cwd: "app/src",
69+
src: [ "download.css", "themeroller.css" ],
70+
dest: "app/dist"
71+
}
72+
},
5173
uglify: {
5274
options: {
5375
preserveComments: "some"
5476
},
5577
// DownloadBuilder minified frontend bundle
5678
download: {
57-
src: [ "app/src/external/event_emitter.min.js", "app/src/external/handlebars.runtime.js", "app/src/template/download.js", "app/src/external/lzma.js", "app/src/hash.js", "app/src/querystring.js", "app/src/model.js", "app/src/download.js" ],
58-
dest: "app/resources/download.all.min.js"
79+
src: [ "external/event_emitter.min.js", "external/handlebars.runtime.js", "tmp/app/template/download.js", "external/lzma.js", "app/src/hash.js", "app/src/querystring.js", "app/src/model.js", "app/src/download.js" ],
80+
dest: "app/dist/download.all.min.js"
5981
},
6082
// ThemeRoller minified frontend bundle
6183
themeroller: {
62-
src: [ "app/src/external/event_emitter.min.js", "app/src/external/handlebars.runtime.js", "app/src/template/themeroller.js", "app/src/external/farbtastic.js", "app/src/external/lzma.js", "app/src/hash.js", "app/src/querystring.js", "app/src/model.js", "app/src/themeroller.js" ],
63-
dest: "app/resources/themeroller.all.min.js"
84+
src: [ "external/event_emitter.min.js", "external/handlebars.runtime.js", "tmp/app/template/themeroller.js", "external/farbtastic.js", "external/lzma.js", "app/src/hash.js", "app/src/querystring.js", "app/src/model.js", "app/src/themeroller.js" ],
85+
dest: "app/dist/themeroller.all.min.js"
6486
}
87+
},
88+
clean: {
89+
appDist: [ "app/dist" ]
6590
}
6691
});
6792

@@ -429,7 +454,7 @@ function buildPackages( folder, callback ) {
429454

430455
grunt.registerTask( "default", [ "check-modules", "jshint" ] );
431456

432-
grunt.registerTask( "build-app", [ "handlebars", "uglify" ] );
457+
grunt.registerTask( "build-app", [ "clean", "handlebars", "copy", "uglify" ] );
433458

434459
grunt.registerTask( "build-packages", "Builds zip package of each jQuery UI release specified in config file with all components and lightness theme, inside the given folder", function( folder ) {
435460
var done = this.async();
@@ -441,7 +466,7 @@ grunt.registerTask( "build-packages", "Builds zip package of each jQuery UI rele
441466
});
442467

443468
grunt.registerTask( "mkdirs", "Create directories", function() {
444-
[ "app/resources/template", "log", "tmp" ].forEach(function( dir ) {
469+
[ "log", "tmp" ].forEach(function( dir ) {
445470
if ( !fs.existsSync( dir ) ) {
446471
grunt.file.mkdir( dir );
447472
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

app/src/model.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
(function( exports, $, EventEmitter, LZMA, QueryString, undefined ) {
1212
var Model, DownloadBuilderModel, ThemeRollerModel, lzmaInterval,
13-
lzma = new LZMA( "/resources/external/lzma_worker.min.js" ),
13+
lzma = new LZMA( $( "[data-lzma-worker]" ).data( "lzma-worker" ) ),
1414
lzmaLoad = $.Deferred();
1515

1616
// Encodes an Array of booleans [ true, false, ... ] into a string sequence "10...".

app/resources/themeroller.css app/src/themeroller.css

+18-18
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
padding: 0;
143143
text-indent: -999999px;
144144
overflow: hidden;
145-
background: transparent url("/resources/images/themeroller/logo_themeRoller_sml.gif") -5px 0 no-repeat;
145+
background: transparent url("images/themeroller/logo_themeRoller_sml.gif") -5px 0 no-repeat;
146146
}
147147

148148
/* corner radius in TR app elements */
@@ -195,11 +195,11 @@
195195

196196

197197
/* tabs colors, texture */
198-
#themeroller .application #rollerTabsNav {font-size: 1em; border: 1px solid #222222/* borderColorHeader */; background: #000000 url("/resources/images/themeroller/bg_tr_tabs.png") 0 50% repeat-x; color: #222222/* fcHeader */; font-weight: bold !important; border-bottom: 0; margin: 0; list-style: none;}
198+
#themeroller .application #rollerTabsNav {font-size: 1em; border: 1px solid #222222/* borderColorHeader */; background: #000000 url("images/themeroller/bg_tr_tabs.png") 0 50% repeat-x; color: #222222/* fcHeader */; font-weight: bold !important; border-bottom: 0; margin: 0; list-style: none;}
199199
#themeroller .application #rollerTabsNav .widget-header a { color: #222222/* fcHeader */; }
200-
#themeroller .application #rollerTabsNav li { float: left; border: 1px solid #000000/* borderColorDefault */; background: #333333 url("/resources/images/themeroller/bg_tr_tabs_tab.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #dddddd/* fcDefault */ !important; }
200+
#themeroller .application #rollerTabsNav li { float: left; border: 1px solid #000000/* borderColorDefault */; background: #333333 url("images/themeroller/bg_tr_tabs_tab.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #dddddd/* fcDefault */ !important; }
201201
#themeroller .application #rollerTabsNav li a { color: #dddddd/* fcDefault */; text-decoration: none; }
202-
#themeroller .application #rollerTabsNav li.state-hover { border: 1px solid #000000/* borderColorHover */; background: #333333 url("/resources/images/themeroller/bg_tr_tabs_tab_hover.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #ffffff/* fcHover */ !important; }
202+
#themeroller .application #rollerTabsNav li.state-hover { border: 1px solid #000000/* borderColorHover */; background: #333333 url("images/themeroller/bg_tr_tabs_tab_hover.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #ffffff/* fcHover */ !important; }
203203
#themeroller .application #rollerTabsNav li.state-hover a { color: #ffffff/* fcHover */; text-decoration: none; }
204204
#themeroller .application #rollerTabsNav li.ui-tabs-active { border: 1px solid #111111/* borderColorActive */; border-bottom: #000; background: #000 ; font-weight: normal/* fwDefault */; color: #ffffff/* fcActive */ !important; outline: none; }
205205
#themeroller .application #rollerTabsNav li.ui-tabs-active a { color: #ffffff/* fcActive */; outline: none; text-decoration: none; }
@@ -220,7 +220,7 @@
220220

221221
/* Download Theme button */
222222
#downloadTheme {
223-
background: #fa9300 url("/resources/images/themeroller/bg_download_btn.png") repeat-x scroll 0 50%;
223+
background: #fa9300 url("images/themeroller/bg_download_btn.png") repeat-x scroll 0 50%;
224224
color:#222;
225225
border: 1px solid #111;
226226
padding: 0.3em 1.8em 0.4em 2.8em;
@@ -231,15 +231,15 @@
231231
margin: -2px 0 14px 0;
232232
}
233233
#downloadTheme .download-icon {
234-
background-image: url("/resources/images/themeroller/tr_icons_white.png");
234+
background-image: url("images/themeroller/tr_icons_white.png");
235235
background-position: -128px -192px;
236236
position: absolute;
237237
top: 50%;
238238
left: .5em;
239239
margin-top: -8px;
240240
}
241241
#downloadTheme:hover {
242-
background:#faae00 url("/resources/images/themeroller/bg_download_btn_hover.png") repeat-x scroll 0 50%
242+
background:#faae00 url("images/themeroller/bg_download_btn_hover.png") repeat-x scroll 0 50%
243243
color: #000;
244244
border-color: #000;
245245
}
@@ -264,17 +264,17 @@
264264

265265
}
266266
/* header states */
267-
#themeroller .application .theme-group .theme-group-header.state-default { border: 1px solid #222/* borderColorDefault */; background: #111 url("/resources/images/themeroller/bg_tr_group_headers.png") 0 50% repeat-x; font-weight: normal; color: #aaaaaa/* fcDefault */ !important; }
267+
#themeroller .application .theme-group .theme-group-header.state-default { border: 1px solid #222/* borderColorDefault */; background: #111 url("images/themeroller/bg_tr_group_headers.png") 0 50% repeat-x; font-weight: normal; color: #aaaaaa/* fcDefault */ !important; }
268268
#themeroller .application .theme-group .theme-group-header.state-default a { color: #aaaaaa/* fcDefault */; text-decoration: none; }
269-
#themeroller .application .theme-group .theme-group-header.state-active { border: 1px solid #444/* borderColorActive */; border-bottom: 0 !important; background: #333 url("/resources/images/themeroller/bg_tr_group_headers_active.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #ffffff/* fcActive */ !important; outline: none; }
269+
#themeroller .application .theme-group .theme-group-header.state-active { border: 1px solid #444/* borderColorActive */; border-bottom: 0 !important; background: #333 url("images/themeroller/bg_tr_group_headers_active.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #ffffff/* fcActive */ !important; outline: none; }
270270
#themeroller .application .theme-group .theme-group-header.state-active a { color: #ffffff/* fcActive */; outline: none; text-decoration: none; }
271-
#themeroller .application .theme-group .theme-group-content { border: 1px solid #444/* borderColorContent */; background: #333 url("/resources/images/themeroller/bg_tr_group_headers_content.png") 0 0 repeat-x/* bgContentRepeat */; color: #ffffff/* fcContent */; }
272-
#themeroller .application .theme-group .theme-group-header.state-hover { border: 1px solid #444/* borderColorHover */; background: #1a1a1a url("/resources/images/themeroller/bg_tr_group_headers_hover.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #cccccc/* fcHover */ !important; }
271+
#themeroller .application .theme-group .theme-group-content { border: 1px solid #444/* borderColorContent */; background: #333 url("images/themeroller/bg_tr_group_headers_content.png") 0 0 repeat-x/* bgContentRepeat */; color: #ffffff/* fcContent */; }
272+
#themeroller .application .theme-group .theme-group-header.state-hover { border: 1px solid #444/* borderColorHover */; background: #1a1a1a url("images/themeroller/bg_tr_group_headers_hover.png") 0 50% repeat-x; font-weight: normal/* fwDefault */; color: #cccccc/* fcHover */ !important; }
273273
#themeroller .application .theme-group .theme-group-header.state-hover a { color: #cccccc/* fcHover */; text-decoration: none; }
274274
#themeroller .arrow-icon {
275275
float: left;
276276
margin: -2px 3px 0 0;
277-
background-image: url("/resources/images/themeroller/tr_icons_white.png");
277+
background-image: url("images/themeroller/tr_icons_white.png");
278278
}
279279
#themeroller .state-active .arrow-icon {
280280
margin: -1px 2px 0 1px !important;
@@ -506,13 +506,13 @@ a.cornerWarning { color: red !important; text-decoration: none; }
506506
z-index: 99999999;
507507
}
508508
.farbtastic .wheel {
509-
background-image: url("/resources/images/farbtastic/wheel.png");
509+
background-image: url("images/farbtastic/wheel.png");
510510
}
511511
.farbtastic .overlay {
512-
background-image: url("/resources/images/farbtastic/mask.png");
512+
background-image: url("images/farbtastic/mask.png");
513513
}
514514
.farbtastic .marker {
515-
background-image: url("/resources/images/farbtastic/marker.png");
515+
background-image: url("images/farbtastic/marker.png");
516516
}
517517

518518

@@ -583,15 +583,15 @@ a.cornerWarning { color: red !important; text-decoration: none; }
583583
font-size: .9em;
584584
text-decoration: none !important;
585585
float: left;
586-
background: #333 url("/resources/images/themeroller/bg_sml_download_edit_btn.png") repeat-x scroll 50% 50% ;
586+
background: #333 url("images/themeroller/bg_sml_download_edit_btn.png") repeat-x scroll 50% 50% ;
587587
margin: 3px 4px 0 0;
588588
padding: 2px 4px;
589589
border: 1px solid #222;
590590
color: #ccc;
591591

592592
}
593593
#themeGallery a.download:hover, #themeGallery a.edit:hover {
594-
background: #444 url("/resources/images/themeroller/bg_sml_download_edit_btn_hover.png") repeat-x scroll 50% 50%;
594+
background: #444 url("images/themeroller/bg_sml_download_edit_btn_hover.png") repeat-x scroll 50% 50%;
595595
color: #ddd;
596596
}
597597

@@ -606,7 +606,7 @@ a.cornerWarning { color: red !important; text-decoration: none; }
606606
}
607607
#help span.icon {
608608
float: left;
609-
background-image: url("/resources/images/themeroller/tr_icons_orange.png");
609+
background-image: url("images/themeroller/tr_icons_orange.png");
610610
height: 13px;
611611
width: 14px;
612612
margin: -1px 4px 0 0;

download.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var Frontend = function( args ) {
4848

4949
Frontend.prototype = {
5050
index: function( params, options ) {
51+
var production = this.env.toLowerCase() === "production";
5152
options = options || {};
5253
if ( options.wrap ) {
5354
options = _.defaults({
@@ -64,7 +65,8 @@ Frontend.prototype = {
6465
categories: JqueryUi.getStable().categories()
6566
}),
6667
host: this.host,
67-
production: this.env.toLowerCase() === "production",
68+
lzmaWorker: ( production ? "/resources" : "" ) + "/external/lzma_worker.min.js",
69+
production: production,
6870
resources: this.resources,
6971
jqueryUis: jqueryUis
7072
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

frontend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var errorTemplate = Handlebars.compile( fs.readFileSync( __dirname + "/template/
2020
*
2121
*/
2222
var Frontend = function( options ) {
23-
options = _.extend( {}, Frontend.defaults, options );
23+
this.options = options = _.extend( {}, Frontend.defaults, options );
2424
if ( options.config && typeof options.config === "object" ) {
2525
require( "./lib/config" ).get = function() {
2626
return options.config;

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"gm": "1.8.1",
1212
"grunt": "0.4.1",
1313
"grunt-check-modules": "0.2.0",
14+
"grunt-contrib-clean": "0.5.0",
15+
"grunt-contrib-copy": "0.4.1",
1416
"grunt-contrib-handlebars": "0.5.7",
1517
"grunt-contrib-jshint": "0.9.2",
1618
"grunt-contrib-uglify": "0.2.0",

server.js

+18-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ process.on( "uncaughtException", function ( err ) {
77
process.exit( 1 );
88
});
99

10-
var argv = require( "optimist" ).argv,
10+
var frontend, server,
11+
argv = require( "optimist" ).argv,
1112
Builder = require( "./lib/builder" ),
1213
Cache = require( "./lib/cache" ),
1314
connect = require( "connect" ),
@@ -29,10 +30,9 @@ var argv = require( "optimist" ).argv,
2930
themerollerIcon: /^\/themeroller\/images\/(ui-icons_.+)$/,
3031
themerollerParseTheme: "/themeroller/parsetheme.css",
3132
themerollerTexture: /^\/themeroller\/images\/(ui-bg_.+)$/
32-
},
33-
staticDir = "app";
33+
};
3434

35-
var frontend = new Frontend();
35+
frontend = new Frontend();
3636
if ( process.argv.indexOf( "--nocache" ) === -1 ) {
3737
Cache.on( 60000 * 60 );
3838
Packer.cacheThemeGalleryImages();
@@ -95,9 +95,19 @@ function route( app ) {
9595
});
9696
}
9797

98-
connect.createServer(
99-
connect.router( route ),
100-
connect[ "static" ]( staticDir )
101-
).listen( httpPort, httpHost, function() {
98+
99+
server = connect( connect.router( route ) );
100+
101+
// App static directories.
102+
if ( frontend.options.env === "production" ) {
103+
server.use( "/resources", connect[ "static" ]( "app/dist" ) );
104+
} else {
105+
server
106+
.use( "/app", connect[ "static" ]( "app/src" ) )
107+
.use( "/external", connect[ "static" ]( "external" ) )
108+
.use( "/template", connect[ "static" ]( "tmp/app/template" ) );
109+
}
110+
111+
server.listen( httpPort, httpHost, function() {
102112
console.log( "HTTP Server running at http://%s:%d", httpHost, httpPort );
103113
});

template/download/index.html

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<link rel="stylesheet" href="http://code.jquery.com/ui/{{resources.jqueryuiVersion}}/themes/smoothness/jquery-ui.css">
2-
<link rel="stylesheet" href="/resources/download.css">
3-
<div id="download-builder" data-base-vars="{{baseVars}}" data-download-jqueryui-host="{{host}}" data-initial-components="{{components}}">
2+
{{#if production}}
3+
<link rel="stylesheet" href="/resources/download.css">
4+
{{else}}
5+
<link rel="stylesheet" href="/app/download.css">
6+
{{/if}}
7+
<div id="download-builder" data-base-vars="{{baseVars}}" data-download-jqueryui-host="{{host}}" data-initial-components="{{components}}" data-lzma-worker="{{lzmaWorker}}">
48
<p class="bundle-links">
59
<strong>Quick downloads:</strong>
610
{{#join jqueryUis " | "}}
@@ -39,12 +43,12 @@ <h2>Theme</h2>
3943
{{#if production}}
4044
<script src="/resources/download.all.min.js"></script>
4145
{{else}}
42-
<script src="/src/external/event_emitter.min.js"></script>
43-
<script src="/src/external/handlebars.runtime.js"></script>
44-
<script src="/src/template/download.js"></script>
45-
<script src="/src/external/lzma.js"></script>
46-
<script src="/src/hash.js"></script>
47-
<script src="/src/querystring.js"></script>
48-
<script src="/src/model.js"></script>
49-
<script src="/src/download.js"></script>
46+
<script src="/external/event_emitter.min.js"></script>
47+
<script src="/external/handlebars.runtime.js"></script>
48+
<script src="/template/download.js"></script>
49+
<script src="/external/lzma.js"></script>
50+
<script src="/app/hash.js"></script>
51+
<script src="/app/querystring.js"></script>
52+
<script src="/app/model.js"></script>
53+
<script src="/app/download.js"></script>
5054
{{/if}}

template/themeroller/comp_group_a.html

+11-2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ <h2 class="demoHeaders">Framework Icons (content color preview)</h2>
260260
<!-- Tooltip -->
261261
<h2 class="demoHeaders">Tooltip</h2>
262262
<p>
263-
<img src="/resources/images/themeroller/st-stephens.jpg" alt="St. Stephen's Cathedral">
264-
<img src="/resources/images/themeroller/tower-bridge.jpg" alt="Tower Bridge">
263+
{{#if production}}
264+
<link rel="stylesheet" href="/resources/external/farbtastic.css">
265+
<link rel="stylesheet" href="/resources/themeroller.css">
266+
<img src="/resources/images/themeroller/st-stephens.jpg" alt="St. Stephen's Cathedral">
267+
<img src="/resources/images/themeroller/tower-bridge.jpg" alt="Tower Bridge">
268+
{{else}}
269+
<link rel="stylesheet" href="/external/farbtastic.css">
270+
<link rel="stylesheet" href="/app/themeroller.css">
271+
<img src="/app/images/themeroller/st-stephens.jpg" alt="St. Stephen's Cathedral">
272+
<img src="/app/images/themeroller/tower-bridge.jpg" alt="Tower Bridge">
273+
{{/if}}
265274
</p>

0 commit comments

Comments
 (0)