suite 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +4 -0
  3. data/README.md +304 -0
  4. data/Rakefile +2 -0
  5. data/bin/suite +3 -0
  6. data/lib/suite/builder.rb +139 -0
  7. data/lib/suite/cli.rb +52 -0
  8. data/lib/suite/environment.rb +22 -0
  9. data/lib/suite/generators/project/application.js.erb +10 -0
  10. data/lib/suite/generators/project/application.scss.erb +5 -0
  11. data/lib/suite/generators/project/content.yml +16 -0
  12. data/lib/suite/generators/project/core.js.coffee +4 -0
  13. data/lib/suite/generators/project/gitignore +1 -0
  14. data/lib/suite/generators/project/homepage.html.haml +6 -0
  15. data/lib/suite/generators/project/info.html.haml +8 -0
  16. data/lib/suite/generators/project/suite.yml.erb +6 -0
  17. data/lib/suite/generators/project/template.html.haml.erb +44 -0
  18. data/lib/suite/generators/project/text.txt +1 -0
  19. data/lib/suite/generators/project.rb +69 -0
  20. data/lib/suite/helpers/image_view_helper.rb +14 -0
  21. data/lib/suite/helpers/javascript_view_helper.rb +23 -0
  22. data/lib/suite/helpers/stylesheet_view_helper.rb +13 -0
  23. data/lib/suite/helpers/view_helpers.rb +19 -0
  24. data/lib/suite/project/asset_registry.rb +62 -0
  25. data/lib/suite/project.rb +76 -0
  26. data/lib/suite/renderers/abstract.rb +21 -0
  27. data/lib/suite/renderers/exception.rb +17 -0
  28. data/lib/suite/renderers/haml.rb +12 -0
  29. data/lib/suite/renderers/html.rb +11 -0
  30. data/lib/suite/renderers/page.rb +59 -0
  31. data/lib/suite/renderers.rb +11 -0
  32. data/lib/suite/server/asset.rb +17 -0
  33. data/lib/suite/server/content.rb +18 -0
  34. data/lib/suite/server/error.rb +7 -0
  35. data/lib/suite/server/root_asset.rb +4 -0
  36. data/lib/suite/server.rb +16 -0
  37. data/lib/suite/version.rb +3 -0
  38. data/lib/suite.rb +33 -0
  39. data/suite.gemspec +30 -0
  40. metadata +196 -0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ bin/.sass-cache/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in suite.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,304 @@
1
+ # Simple Static Website Development Toys: suite
2
+
3
+ All the stuff that make front end web development fun, in one simple toolkit.
4
+
5
+ ### Suite _gives you…_
6
+ * Coffee Script
7
+ * SASS
8
+ * HAML
9
+ * Sprockets
10
+ * Javascript & CSS minifying
11
+ * Development Server
12
+ * Scaffolding
13
+ * Happiness
14
+
15
+ ### Suite _does not_
16
+ * Have routes
17
+ * Access a database
18
+ * Give you a controller
19
+ * Get fat models
20
+ * Cache
21
+ * Cook eggs
22
+ * Make you want to kill yourself
23
+
24
+ ## Table of Contents
25
+
26
+ * [1 How It Works](#section_1)
27
+ * [2 Installation](#section_2)
28
+ * [3 Usage](#section_3)
29
+ * [3.1 suite project](#section_3.1)
30
+ * [3.2 suite server](#section_3.2)
31
+ * [3.3 suite build](#section_3.3)
32
+ * [4 Creating a Site](#section_4)
33
+ * [4.1 Content](#section_4.1)
34
+ * [4.2 Layouts](#section_4.2)
35
+ * [4.3 Assets](#section_4.3)
36
+ * [4.4 Images](#section_4.4)
37
+ * [4.5 Pages (content.yml)](#section_4.5)
38
+ * [4.6 Settings (suite.yml)](#section_4.6)
39
+ * [5 About](#section_5)
40
+ * [6 Development](#section_6)
41
+ * [6.1 Version History](#section_6.1)
42
+ * [6.2 TODO](#section_6.2)
43
+ * [6.3 License](#section_6.3)
44
+
45
+ ## <a name="section_1"></a> 1 How It Works
46
+ Suite works on a per project basis. Each suite project has a directory structure that it knows and loves. When you’re in a project directory you can either run the `suite server` for the development server, or build a compiled site with `suite build`.
47
+
48
+ ## <a name="section_2"></a> 2 Installation
49
+ Suite is available via rubygems `gem install suite`
50
+
51
+ Ruby 1.9 or greater is required. If you need to upgrade your ruby version I recommend using [rbenv](https://github.com/sstephenson/rbenv/) and [ruby-build](https://github.com/sstephenson/ruby-build)
52
+
53
+ ## <a name="section_3"></a> 3 Usage
54
+ There are only three things you can do with the suite command: Create a new project, run the development server, or build a compiled site.
55
+
56
+ ### <a name="section_3.1"></a> 3.1 suite project
57
+ Create a new project. You will be prompted for configuration settings, which will be used to write your config/suite.yml file. All of these settings are configurable later.
58
+
59
+ `suite project my_awesome_new_project`
60
+
61
+ #### Configuration prompts
62
+ These configuration settings apply to the build phase only
63
+
64
+ * __Compress JavaScript?__ Compress javascript using the YUI Compressor
65
+ * __Shorten JavaScript Variables?__ Shorten your javascript variables
66
+ * __Compress CSS?__ Compress stylesheets using the YUI Compressor
67
+ * __Will you serve assets from a CDN?__ Will you be serving JS & CSS from another server
68
+ * __CDN Host and path__ The full path where JS & CSS will be located
69
+
70
+ These configuration settings aren’t build phase specific
71
+
72
+ * __Create git repo?__ Create a git repo in your new project dir, and a .gitignore file
73
+
74
+ ### <a name="section_3.2"></a> 3.2 suite server
75
+ Runs a development server that will render content and assets on the fly.
76
+
77
+ `suite server`
78
+
79
+ If you’re not in the root folder of a Suite project an exception will be raised, otherwise expect to see something like this
80
+
81
+ `[59769:INFO] 2012-03-06 15:59:34 :: Starting server on 0.0.0.0:9000 in development mode. Watch out for stones.`
82
+
83
+ In the background, this is a Goliath server which handles requests for both content and assets - compiling them on the fly. You should not need to restart your server when changing content, javascript or stylesheets - but you _will_ need to restart it if you change your `config/suite.yml` or `config/content.yml` files.
84
+
85
+ ### <a name="section_3.3"></a> 3.3 suite build
86
+ Building a site does a few things.
87
+
88
+ 1. Renders HAML partials into the appropriate html files
89
+ 2. Renders SASS and CoffeeScript to CSS and JavaScript
90
+ 3. Compress / minify CSS and JavaScript if your config says to
91
+ 4. Cachebust your CSS and JavaScript
92
+
93
+ The command takes an optional view name, and will default to the desktop view. For more information read the section on views further on.
94
+
95
+ __Build the default 'desktop' view__
96
+
97
+ `suite build`
98
+
99
+ __Build the 'mobile' view__
100
+
101
+ `suite build mobile`
102
+
103
+
104
+ #### A note on cachebusting
105
+ To prevent the caching of assets on the client side, the filenames of the assets are the MD5 checksum of their content. As long as you’ve used the correct include helpers in your HAML markup, your html will be rendered with the correct paths.
106
+
107
+ `<script type="text/javascript" src="/assets/c1aba2692680cbc9e958451badaa989a.js"></script>`
108
+
109
+ ## <a name="section_4"></a> 4 Creating a Site
110
+ The content of your site is located in the `content` folder, while the assets live in the `assets` folder (surprised?).
111
+
112
+ ### <a name="section_4.1"></a> 4.1 Content
113
+
114
+ __All content files have the extension .html.haml__
115
+
116
+ If you’ve never dealt with HAML before, I’d recommend checking out the [tutorial](http://haml-lang.com/tutorial.html) first.
117
+
118
+ Each page in your site is made up of one or more content partials (wrapped in a layout). How these pages are defined is explain further on.
119
+
120
+ All content partials are stored in the `content` directory. You’re allowed to have nested folders galore, so don’t feel stuck to a flat directory structure.
121
+
122
+ The default files you get are `content/homepage.html.haml` and `content/info.html.haml`. If you have a look at them, you’ll notice they’re pretty plain and boring – it’s up to you to create exciting markup!
123
+
124
+ __See content.yml below for information about how pages are defined__
125
+
126
+ ### <a name="section_4.2"></a> 4.2 Layouts
127
+
128
+ Layouts are stored in the `content/layouts` folder, although this isn’t enforced in the `config/content.yml` file. The default layout is `content/layouts/application.html.haml` and is based on the HTML5 boilerplate markup.
129
+
130
+ The content of the page is rendered and inserted with the `yield` command, see the default layout for an example.
131
+
132
+ ### <a name="section_4.3"></a> 4.3 Assets
133
+
134
+ #### Stylesheets and JavaScripts
135
+
136
+ If you want to include an asset as part of your site you need to use the asset helpers `javascript_include_tag` and `stylesheet_link_tag`. Rails developers will be familiar with the method names.
137
+
138
+ Both tags take the path to the asset, relative to their asset folder (`assets/javascripts` for js and `assets/stylesheets` for CSS), and do __not__ require their extension.
139
+
140
+ To load `assets/javascripts/application.js` you’d call `javascript_include_tag "application"`
141
+
142
+ To load `assets/stylesheets/styles.css.scss` you’d call `stylesheet_link_tag "styles"`
143
+
144
+ #### Sprockets
145
+
146
+ Internally, Suite uses [sprockets](https://https://github.com/sstephenson/sprockets/) to handle the rendering of CSS and JavaScript assets. This give you a few key features.
147
+
148
+ _Firstly,_ you can use coffeescript or sass without any headaches. If you want a new coffeescript file that renders to javascript, just create `assets/javascripts/my_script.js.coffee` and if you want a new sass file `assets/stylesheets/my_styles.css.scss`.
149
+
150
+ _Secondly,_ you can use the `//= require "file_name"` syntax to include other files. This is a killer feature of sprockets. No longer do you have to worry about multiple files and then bundling them for release – simply use your application.js as a container file for all the separate classes you need. Suite will smartly create `<script />` tags for all the required assets during development, and then bundle and minify them during the build process.
151
+
152
+ __I’d recommend reading the sprockets homepage, it’s a great bit of software.__
153
+
154
+ #### External Javascript and CSS
155
+
156
+ To include an external JS or CSS asset, use the standard HAML / HTML – no funny business here.
157
+
158
+
159
+ ### <a name="section_4.4"></a> 4.4 Images
160
+
161
+ Store images in the `assets/images/` folder. To render an image in your content, use the `image_tag` helper. Just send through the path to the file relative to the `assets/images/` directory, and an optional array of attributes.
162
+
163
+ `image_tag "raptor.jpg"` becomes `<img src="assets/images/raptor.jpg" />`
164
+
165
+ `image_tag "dinosaurs/raptor.jpg"` becomes `<img src="assets/images/dinosaurs/raptor.jpg" />`
166
+
167
+ `image_tag "cats/mog.png", class: ["cat", "thumbnail"], id: "my_kitteh"` becomes `<img src="assets/images/cats/mog.png" class="cat thumbnail" id="my_kitteh" />`
168
+
169
+ All images will be copied to the `assets/images` folder in your build directory when you run the build command. Images created with the `image_tag` will be updated with the correct paths for your cdn / asset host if you have one set (_see: 4.6 Settings_).
170
+
171
+ ### <a name="section_4.5"></a> 4.5 Pages (content.yml)
172
+
173
+ __All content files have the extension .html.haml__
174
+
175
+ Your site’s pages are defined in the files `config/content.yml`. Each page consists of a layout (if no layout is defined, it uses the default layout).
176
+
177
+ The content.yml file can be used to define several views for your site. You might have one view for the desktop browser, and another for mobile (don’t start a responsive design argument right now) – or you might just have the one view.
178
+
179
+ Here’s the default content.yml file you’ll get when you create a new project:
180
+
181
+ `desktop:
182
+ layout: "layouts/application"
183
+ pages:
184
+ index:
185
+ content: ["homepage", "info"]`
186
+
187
+ The root element is the name of the view, in this case 'desktop'. Inside that we have two elements, a layout element that defines the location of the layout that pages are wrapped in and a pages element that defines the pages the site will have.
188
+
189
+ #### Layouts
190
+
191
+ This looks for a file inside of the content folder. In this case, the file is `content/layouts/application.html.haml`.
192
+
193
+ A layout file must have a call to `yield` where the content is required in the layout.
194
+
195
+ #### Pages and Content
196
+
197
+ The default site only has one page, the index page. Inside a page element you have a content element, which has an array of content partials. The partials should be created in the `content/` directory. This means the default partials can be found at `content/homepage.html.haml` and `content/info.html.haml`. You can add as many items into each pages’ content array as you’d like.
198
+
199
+ You can also have a custom layout declared on any page, for those ‘irregular’ pages.
200
+
201
+ ` payment:
202
+ layout: "layouts/payment"
203
+ content: ["payment/form", "payment/sidebar"]`
204
+
205
+ #### Nested Pages
206
+
207
+ You’re not limited to a flat directory structure. You can also nest pages.
208
+
209
+ ` pages:
210
+ about:
211
+ content: ["about/navigation", "about/intro"] #optional content
212
+ the_team:
213
+ content: ["about/navigation", "about/team"]
214
+ the_company:
215
+ content: ["about/navigation", "about/company"] `
216
+
217
+ In this case, we end up with three valid urls: `about/`, `about/the_team/`, and `about/the_company/`. If we didn’t have a content element in the root of the 'about' element, it would still be valid - we just wouldn’t get the `about/` page.
218
+
219
+ __Note: If you change your content.yml file, you will need to restart the development server__
220
+
221
+ #### Site Views
222
+
223
+ To create multiple views of your site, simply add a new root element to `content.yml`. Here’s an example with two versions, the desktop version and a mobile version, which you would build with `suite build mobile`.
224
+
225
+ `desktop:
226
+ layout: "layouts/desktop"
227
+ pages:
228
+ index:
229
+ content: ["homepage", "info"]
230
+ contact:
231
+ content: ["contact-us"]
232
+ mobile:
233
+ layout: "layouts/mobile"
234
+ pages:
235
+ index:
236
+ content: ["homepage", "find-us", "add-to-homescreen"]
237
+ contact:
238
+ content: ["link-to-maps"]`
239
+
240
+
241
+ ### <a name="section_4.6"></a> 4.6 Settings (suite.yml)
242
+
243
+ Your build config file is `config/suite.yml`, and contains settings used during build. This is the file that’s created for you depending on the responses you give when you run the `suite project` command.
244
+
245
+ #### Compression
246
+
247
+ Please see the [YUI Compressor Documentation](http://developer.­yahoo.­com/­yui/­compressor/­) to learn why you might or might not want to use these settings.
248
+
249
+ * __compress_javascript__ Should javascript assets be minified?
250
+ * __compress_css__ Should stylesheet assets be compressed?
251
+ * __shorten_javascript_variables__ Should local javascript variables be shortened?
252
+
253
+ #### CDN / Asset Server
254
+
255
+ If you’re serving up your assets from a different server to the server where your pages will be hosted, you need to set the `asset_host` variable in your suite.yml. This needs to be a fully qualified domain name, and an optional path.
256
+
257
+ `http://s3.amazonaws.com/my-bucket-name` and `http://something.cloudfront.net` are both good.
258
+
259
+ When you build your site, in the build folder for your site view you’ll get two folders, `site` and `cdn`. Your html files and htaccess will be in `site` and in `cdn` you’ll find your javascripts, stylesheets and images folders. Just upload these to your asset host / cdn and you’re good to go.
260
+
261
+ If you’ve used the `stylesheet_link_tag` and `javascript_include_tag` view helpers (which you should have), then they will have rendered the correct location to your assets in your html files, such as:
262
+
263
+ `http://s3.amazonaws.com/my-bucket-name/javascripts/c1aba2692680cbc9e958451badaa989a.js`
264
+
265
+ ## <a name="section_5"></a> 5 About
266
+
267
+ From the very beginning, this toolkit has been designed from the ground up to scratch my own itch while developing a non dynamic site. I wanted SASS and CoffeeScript so I had them running watching for changes in two windows. I wanted HAML for my content, so I hacked together a build script and created my own way of organising partials. Eventually running sass, coffeescript and a build script became enough of a hindrance that I started to think bigger, and Suite was born.
268
+
269
+ At this point, I haven’t finished my original project so there are plenty of new features that I’ll be building when I come to need them.
270
+
271
+ ## <a name="section_6"></a> 6 Development
272
+ I’m still new at Ruby so I may have done things in a round-about fashion. If you want to add something in, or clean something up, feel free to do so and make a pull request, or file a [new issue](https://github.com/snikch/suite/issues).
273
+
274
+ ### <a name="section_6.1"></a> 6.1 Development
275
+
276
+ __0.1.0__ (March 7, 2012)
277
+
278
+ * Initial public release.
279
+
280
+
281
+ ### <a name="section_6.2"></a> 6.2 TODO
282
+
283
+ #### To Do / Roadmap
284
+
285
+ * build renders htaccess that redirects requests for .html files when no .html is added
286
+ * Handle favicons, apple touch images automatically
287
+ * Handle 404’s
288
+ * Broken assets insert exception information into the page including them
289
+ * Javascripts / Stylesheets can be inserted into the head, or body end, from any partial
290
+ * Deal with 500 errors in the server
291
+ * Nicer default style / messages
292
+ * Server reloads config files when they’re changed
293
+
294
+ ### <a name="section_6.3"></a> 6.3 License
295
+ (The MIT license)
296
+
297
+ Copyright (c) 2011 Mal Curtis
298
+
299
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
300
+
301
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
302
+
303
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
304
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/suite ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'suite'
3
+ Suite::CLI.start
@@ -0,0 +1,139 @@
1
+ require 'thor/group'
2
+ require 'digest/md5'
3
+ require 'yui/compressor'
4
+ require 'suite/renderers/page'
5
+
6
+ module Suite
7
+ class Builder < Thor::Group
8
+ include Thor::Actions
9
+ argument :type, type: :string
10
+
11
+ def render
12
+ create_directory_structure
13
+ render_content
14
+ render_assets
15
+ rescue => e
16
+ say_status :error, e.message, :red
17
+ say_status :cancelling, "Deleting built files and folders", :yellow
18
+ run "rm -rf #{build_directory}"
19
+ raise e
20
+ end
21
+
22
+ private
23
+
24
+ def render_content
25
+ render_content_array Suite.project.content["pages"]
26
+ end
27
+
28
+ def render_assets
29
+ { js: :javascripts, css: :stylesheets }.each do |type, folder|
30
+ Suite.project.asset_registry.send(type).each do |path, asset|
31
+ out_path = "#{build_directory}/#{asset_directory}/#{folder}/#{asset.build_file_name}"
32
+ if File.exists?(out_path)
33
+ say_status :unchanged, "#{path} as #{asset.build_file_name}", :black
34
+ else
35
+ File.open(out_path, 'w') do |f|
36
+ f.write asset.to_s
37
+ end
38
+ say_status :create, "#{path} as #{asset.build_file_name}", :green
39
+ end
40
+ end
41
+ end
42
+ directory "assets/images", build_directory + "/" + asset_directory + "/images"
43
+ end
44
+
45
+ def create_directory_structure
46
+ Suite.project.content
47
+ empty_directory build_directory
48
+ if using_cdn?
49
+ empty_site_directory
50
+ empty_cdn_directory
51
+ end
52
+ empty_asset_directory
53
+ empty_asset_directory "javascripts"
54
+ empty_asset_directory "stylesheets"
55
+ empty_asset_directory "images"
56
+ end
57
+
58
+ def using_cdn?
59
+ !!Suite.project.config["asset_host"]
60
+ end
61
+
62
+ def build_directory
63
+ "build/#{type}"
64
+ end
65
+
66
+ def empty_site_directory folder_name = nil
67
+ empty_directory "#{build_directory}/#{site_directory}/#{folder_name}"
68
+ end
69
+
70
+ def site_directory
71
+ using_cdn? ? "site" : ""
72
+ end
73
+
74
+ def empty_cdn_directory folder_name = nil
75
+ empty_directory("#{build_directory}/#{cdn_directory}/#{folder_name}")
76
+ end
77
+
78
+ def cdn_directory
79
+ "cdn"
80
+ end
81
+
82
+ def empty_asset_directory folder_name = nil
83
+ empty_directory "#{build_directory}/#{asset_directory}/#{folder_name}"
84
+ end
85
+
86
+ def asset_directory
87
+ using_cdn? ? cdn_directory : (site_directory ? site_directory + "/" : "") + "assets"
88
+ end
89
+
90
+ def render_content_array array, folder = nil
91
+ array.each do |name, page|
92
+ if page["content"]
93
+ render_to_file \
94
+ folder,
95
+ "#{name}.html",
96
+ page["content"],
97
+ page["layout"] || Suite.project.content["layout"]
98
+ end
99
+ page.delete "content"
100
+ render_content_array page, "#{folder}/#{name}" if page.size > 0
101
+ end
102
+ end
103
+
104
+ def render_to_file folder, file, contents, layout
105
+ renderer = Suite::Renderers::Page.new layout, contents
106
+ empty_site_directory folder if folder
107
+ out_path = build_directory + "/" + site_directory + (folder ? "/" + folder : "") + "/" + file
108
+ out_content = renderer.render
109
+ if File.exists? out_path
110
+ if file_hash(out_path) != content_hash(out_content)
111
+ write_file out_path, out_content
112
+ say_status :update, "#{folder}/#{file}", :yellow
113
+ else
114
+ say_status :unchanged, "#{folder}/#{file}", :black
115
+ end
116
+ else
117
+ write_file out_path, out_content
118
+ say_status :create, "#{folder}/#{file}"
119
+ end
120
+ end
121
+
122
+ def write_file path, content
123
+ File.open(path, 'w'){ |f| f.write content }
124
+ end
125
+
126
+ def file_hash path
127
+ content_hash IO.read path
128
+ end
129
+
130
+ def content_hash content
131
+ Digest::MD5.hexdigest content
132
+ end
133
+
134
+ def self.source_root
135
+ Suite.project.path
136
+ end
137
+ end
138
+ end
139
+
data/lib/suite/cli.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'suite/environment'
2
+ require 'thor'
3
+ require "sprockets-sass"
4
+ require 'compass'
5
+
6
+ module Suite
7
+ class CLI < Thor
8
+ include Thor::Actions
9
+
10
+ desc "project NAME", "Generates a project scaffold"
11
+ def project name
12
+ require 'suite/generators/project'
13
+ Suite::Generators::Project.start([name])
14
+ end
15
+
16
+ desc "build TYPE", "Compiles a static version of your project. View type defaults to :desktop"
17
+ def build view = :desktop
18
+ say "Build must be run in a suite project directory", :red and return unless in_project_directory?
19
+ Suite.use_project_at_path destination_root, view
20
+ Suite.env = Suite::Environment.new :build
21
+
22
+ require 'suite/builder'
23
+ Suite::Builder.start([view])
24
+ end
25
+
26
+ desc "server", "Runs the suite development server"
27
+ def server
28
+ say "Server must be run in a suite project directory", :red and return unless in_project_directory?
29
+
30
+ Suite.use_project_at_path destination_root
31
+ begin
32
+ require 'suite/server'
33
+ Suite.env = Suite::Environment.new :development
34
+ runner = Goliath::Runner.new(ARGV, nil)
35
+ runner.log_stdout = true
36
+ runner.api = Suite::Server.new
37
+ runner.app = Goliath::Rack::Builder.build(Suite::Server, runner.api)
38
+ runner.run
39
+ rescue RuntimeError => e
40
+ say "Could not start development server", :red
41
+ say "\t#{e.message}", :yellow
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def in_project_directory?
48
+ File.exists?(destination_root + "/config/suite.yml")
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,22 @@
1
+ module Suite
2
+ class Environment
3
+
4
+ attr_accessor :env
5
+
6
+ def initialize env
7
+ @env = env.to_sym
8
+ end
9
+
10
+ def == val
11
+ @env == val.to_sym
12
+ end
13
+
14
+ def development?
15
+ @env == :development
16
+ end
17
+
18
+ def build?
19
+ @env == :build
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ // This is your project's core javascript file.
2
+
3
+ // Do not write any javascript in here
4
+
5
+ // You should include files like the next line (including the slashes)
6
+
7
+ //= require core
8
+
9
+ // ^---- That line will render 'core.js' into this file
10
+
@@ -0,0 +1,5 @@
1
+ @import 'compass';
2
+
3
+ body, h1{
4
+ font-family: sans-serif
5
+ }
@@ -0,0 +1,16 @@
1
+ # desktop is the default view, you could add a mobile view etc.
2
+ desktop:
3
+ # define a default template for use in pages
4
+ layout: "layouts/application"
5
+ pages:
6
+ # a root page called index
7
+ index:
8
+ # content contains all the parts of the page, in this case one partial
9
+ content: ["homepage", "info"]
10
+
11
+ # # Here's an example of nested pages
12
+ # about:
13
+ # the_team:
14
+ # content: ["about/team"]
15
+ # the_company:
16
+ # content: ["about/company"]
@@ -0,0 +1,4 @@
1
+ document.onready = ->
2
+ document.getElementById('coffee').innerHTML = message()
3
+ message = ->
4
+ "<h2>Hey. This content was put here by JavaScript.</h2><p>You should check out <code>assets/javascripts/core.js.coffee</code>. That's the file that forced me to come into existence on your page.</p><p>If you want to know how that was loaded, check your <code>application.js</code>, and see how it includes 'core'. It's all thanks to <a href='https://github.com/sstephenson/sprockets'>Sprockets</a>.</p>"
@@ -0,0 +1 @@
1
+ .sass-cache/*
@@ -0,0 +1,6 @@
1
+ %h1 Welcome to your Suite project
2
+ %h5 I'm located here: #{Suite.project.path}
3
+ #getting-started
4
+ %h2 Getting Started
5
+ %p The first thing you'll want to do is create more pages in your <code>config/content.yml</code> file. There are examples in there. Just remember, <strong>restart your server if you update your config</strong>.
6
+ #coffee{ style: "border:2px solid #eee; padding:10px"}
@@ -0,0 +1,8 @@
1
+ #info
2
+ %h2 But where's my CSS!!
3
+ %p Funnily enough, css is found in <code>assets/stylesheets</code>. You can use plain ol' css, or SASS. Simply add .sass to the end of a css file and we'll do the rest of the work. Don't know what SASS is? <em><a href="http://sass-lang.com/">I'm about to change your life.</a></em>
4
+ %h2 Want to compile this site?
5
+ %p Run <code>suite build</code> from the project directory and you’ll get a static html, css and js output in your build folder.
6
+ %h2 Need more tips and tricks on how to get Suite running to your liking?
7
+ %p It's all here: <a href="https://github.com/snikch/suite">Suite on GitHub</a>
8
+
@@ -0,0 +1,6 @@
1
+ compress_javascript: <%= @compress_javascript %>
2
+ compress_css: <%= @compress_stylesheet %>
3
+ shorten_javascript_variables: <%= @shorten_javascript_variables %>
4
+ <% if @using_cdn %>
5
+ asset_host: <%= @asset_host %>
6
+ <% end %>
@@ -0,0 +1,44 @@
1
+ !!! 5
2
+ -# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
3
+ <!--[if lt IE 7]> <html lang="en" class="no-js ie6"> <![endif]-->
4
+ <!--[if IE 7]> <html lang="en" class="no-js ie7"> <![endif]-->
5
+ <!--[if IE 8]> <html lang="en" class="no-js ie8"> <![endif]-->
6
+ <!--[if gt IE 8]><!-->
7
+ %html.no-js{ :lang => "en" }
8
+ <!--<![endif]-->
9
+ %head
10
+ %meta{ :charset => "utf-8" }/
11
+
12
+ %title My Suite Site
13
+ %meta{ :name => "description", :content => "" }/
14
+ %meta{ :name => "author", :content => "" }/
15
+
16
+ -# Mobile viewport optimized: j.mp/bplateviewport
17
+ %meta{ :name => "viewport", :content => "width=device-width, initial-scale=1.0" }/
18
+
19
+ -# Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons
20
+
21
+ -# CSS: implied media="all"
22
+ = stylesheet_link_tag "<%= name %>"
23
+
24
+ -# All JavaScript at the bottom, except for Modernizr and Respond.
25
+ -# Modernizr enables HTML5 elements & feature detects; Respond is a polyfill for min/max-width CSS3 Media Queries
26
+ //%script{ :src => "js/libs/modernizr-2.0.6.min.js" }
27
+ = javascript_include_tag "application"
28
+ %script{ :src => "//ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js" }
29
+ :javascript
30
+ window.jQuery || document.write("<script src='js/jquery.min.js'>\x3C/script>")
31
+
32
+ %body
33
+ = yield
34
+ = yield :javascript_body
35
+ :javascript
36
+ var _gaq=[["_setAccount","UA-xxxxxx-x"],["_trackPageview"],["_trackPageLoadTime"]];
37
+ (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
38
+ g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
39
+ s.parentNode.insertBefore(g,s)}(document,"script"));
40
+
41
+ <!--[if lt IE 7 ]>
42
+ <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
43
+ <script>window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})</script>
44
+ <![endif]-->
@@ -0,0 +1 @@
1
+ blarg