moka 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.1.4. Improved explanations in README.rdoc
2
+
1
3
  v0.1.3. Some explanations in README.rdoc
2
4
 
3
5
  v0.1.2. Server now start by default on port 3333
data/README.rdoc CHANGED
@@ -1,12 +1,12 @@
1
1
  == Welcome to Moka
2
2
 
3
- Moka is a damn simple framework designed to build static websites like portfolios, showcases, minisites, HTML mockups, etc. Moka setup takes a single command, and it provides a hierarchical template system and some hyper-convenient helper functions so you never have to write more code than necessary. The result of your work is compiled to plain HTML, CSS and Javascript, so you just have to upload it to your server. Plus, don't forget the Lipsum helper functions to generate dummy text with a single line of code during development or in HTML mockups.
3
+ Moka is a damn simple framework designed to build static websites like portfolios, showcases, minisites, HTML mockups, etc. Moka setup takes a single command, and it provides you with a hierarchical template system and some hyper-convenient helper functions so you never have to write more code than necessary. The result of your work is compiled to plain HTML, CSS and Javascript: you just need to upload it to your server to deploy it. Add as a bonus the Lipsum helpers, with which you can generate dummy text with a single line of code during development or in HTML mockups.
4
4
 
5
- A taste of Moka coolness:
5
+ Moka values:
6
6
  - Don't Repeat Yourself
7
7
  - Convention Over Configuration
8
- - Learn it in 10 minutes, set it up with a single command, start your creative work!
9
- - Compile everything into plain HTML and CSS code, working on virtually every possible webserver
8
+ - Learn it in 10 minutes, set it up with a single command, start your creative work immediately
9
+ - Compile everything into plain HTML and CSS code, working on virtually any possible webserver
10
10
 
11
11
  == Installation
12
12
 
@@ -17,22 +17,22 @@ Install the gem:
17
17
 
18
18
  === Prerequisites
19
19
 
20
- Moka is really simple and straightforward, but it is intended for developers and people who already know how to code in HTML and CSS. Since Moka uses Ruby language, some knowledge of it is probably needed before getting started. For Ruby on Rails developers, using Moka should be extremely simple, since Moka uses erb (or haml) and many helper functions that work nearly the same way as in Rails.
20
+ Moka is really simple and straightforward, but it is intended for developers and people who already know how to code in HTML and CSS. Since Moka uses Ruby language, some knowledge of it is probably needed before getting started.
21
+ For Ruby on Rails developers, using Moka should be extremely simple, since Moka uses erb (or haml) and many helper methods that work nearly the same way as in Rails.
21
22
 
22
23
  === Create a new Moka project
23
24
 
24
- You can create a new Moka project with just one command. Simply navigate to your development directory, open the command line and type:
25
+ You can create a new Moka project with just one command. Simply open the command line, navigate to your development directory and type:
26
+
25
27
  moka new site your_site_name
26
28
 
27
29
  You need to replace 'your_site_name' with the actual name of your project.
28
30
 
29
31
  By the time this command executes, you'll see that a new directory named 'your_site_name' (or whatever you choose as the name of your project) was created. Into this directory you will see a file named manifest.yml, which describes the structure of your new site and gets updated automatically as you create new pages and groups. Apart from this file, you will find three directories:
30
32
 
31
- * compiled - here is where your project will be compiled to a pure HTML website, and where static assets like images, javascripts and stylesheets should be placed.
32
-
33
- * project - your development directory, where you will create all the pieces that Moka will put together to compile your project into a working website: partials, variables, groups and pages (keep reading and this will get much clearer)
34
-
35
- * script - this directory contains files needed by Moka in order to work properly. Usually you won't need to edit them.
33
+ * compiled - here is where your project will be compiled to a pure HTML website, and where static assets like images, javascripts and stylesheets should be placed.
34
+ * project - your development directory, where you will create all the pieces that Moka will put together to compile your project into a working website: partials, variables, groups and pages (keep reading and this will get much clearer)
35
+ * script - this directory contains files needed by Moka in order to work properly. Usually you won't need to edit them.
36
36
 
37
37
  === Add pages to your website
38
38
 
@@ -62,49 +62,98 @@ Now that you created your first page, you probably want to edit its layout and c
62
62
 
63
63
  But what files do you need to create/edit? When you create a page using the new page command, Moka creates into the project/site directory a new directory named as the group your page belongs to ('root' if you didn't specify it), and into that it creates another directory named as the page. Also, it updates the manifest.yml file with the info about the new group and page. Note that the directories are structured as a tree (the sitetree, again): the site directory contains the group directories, and each of these group directories contains the directories of pages belonging to that group.
64
64
 
65
- All the files you need to create or edit to change the HTML code of your new page are placed in these new directories. But where precisely?
65
+ Moka is all about placing pieces of code in the right directory, as where you place your file determines how these files are used to compose your pages.
66
66
 
67
+ ==== Layouts
67
68
  Think of pages in a Moka project as jigsaw puzzles: every page is composed of various pieces, and Moka uses its conventions in order to select the right pieces when assembling the puzzle. When Moka compiles a page, first of all it looks for a file named layout.erb (or .haml) which defines the basic HTML layout and structure of the page. Moka looks for this file first in the page directory (project/site/root/index in the case of our first page). If it can't find it there, it looks into the group directory (project/site/root), and then, if there is no layout file in the group directory, it looks for it in the site directory (project/site).
68
69
 
69
- Apart from defining the basic HTML structure of a page, the layout file may request one or more partials (through the Ruby method partial(:partial_name) ). As the name indicates, partials are simply parts of the HTML code of a page, or pieces of the puzzle in our analogy. As it does with the layout file, Moka looks for each partial first in the page directory, than in the group directory, and finally, if all else failed, in the site directory.
70
+ ==== Partials
71
+ Apart from defining the basic HTML structure of a page, the layout file may request one or more partials (through the Ruby method partial(:partial_name) ). Partials are erb (or haml) files too, and define parts of the HTML code of a page. In our analpogy, they are the pieces of the puzzle. As it does with the layout file, Moka looks for each partial first in the page directory, than in the group directory, and finally, if all else failed, in the site directory.
70
72
 
73
+ ==== Variables
71
74
  In your layout or partials, you can also use some variables, that you define in a file named variables.yml. Again, Moka decides the value of each variable looking for its definition (in a variables.yml file) first in the page directory, then in the group directory and finally in the site directory until it finds it.
72
75
 
73
- Now the advantage you get from this hierarchical structure provided by Moka should be clear: you place all the page-specific elements in the page directory, the elements that are used in multiple pages in the same group in the group directory, and all the elements that are used by many pages all over the site in the site directory. Moka always assembles your pages using the most specific elements (layout, partials and variables). This means that you never have to write duplicated code.
76
+ Now the advantage you get from this hierarchical structure provided by Moka should be clear: you place all the page-specific elements in the appropriate page directory, the elements that are used by multiple pages in the same group in the group directory, and all the elements that are used all over the site in the site directory. Basically, the directory where you put an element determines its scope: Moka always assembles your pages choosing the most specific version of an element (being it a layout, partial or variable). This means that you never have to write duplicated code.
77
+
78
+ === Sitetree and variables
79
+
80
+ As mentioned before, in your layout and partials you have access to some instance variables. These are @site, @current_group and @current_page. As the names suggest, these variables point to the current page, group and site in the sitetree. The same layout or partial may be used by many different pages, but when you compile your project, the @current_page (@current_group) variable will always be referencing the right page (group) being compiled.
81
+
82
+ You can navigate through the sitetree:
83
+
84
+ @site.groups
85
+ # Returns an Array of all groups
86
+
87
+ @current_group.pages
88
+ # Returns an Array of all pages in the current group
89
+
90
+ @current_page.group
91
+ # Returns an object referencing the group to which @current_page belongs. Same as @current_group
92
+
93
+ @site.mygroup.mypage
94
+ # Returns an object referencing the page 'mypage' in group 'mygroup'
95
+
96
+ @site.find_group('mygroup').find_page('mypage')
97
+ # Same as above, but the strings passed as arguments to the find_* methods may be variables
98
+ # declared somewhere else in your code
99
+
100
+ You can cycle through nodes:
74
101
 
75
- === Pagetree variables
102
+ <% @current_group.pages.each do |page| %>
103
+ # do something with each page
104
+ <% end %>
76
105
 
77
- In your layout and partials you have access to some instance variables. These are @site, @current_group and @current_page. As the names suggest, these variables point to the current page, group and site in the sitetree. The same layout or partial may be used by many different pages, but when you compile your project, the @current_page (@current_group) variable will always be referencing the right page (group) being compiled.
78
- You can navigate through them:
106
+ Nodes in the sitetree (site, groups and pages) let you access the variables defined in the variables.yml files. Thus, you can do something like:
79
107
 
80
- @site.groups # Returns an Array of all groups
81
- @current_group.pages # Returns an Array of all pages in the current group
82
- @current_page.group # Returns an object referencing the group to which @current_page belongs. Same as @current_group
83
- @site.mygroup.mypage # Returns an object referencing the page 'mypage' in group 'mygroup'
84
- @site.find_group('mygroup').find_page('mypage') # Same as above, but the strings passed as arguments to the find_*
85
- # methods may be variables declared somewhere else in your code
108
+ @current_page.name
109
+ # The name of the current page. 'index' in the case of our first example.
110
+
111
+ @current_page.my_variable
112
+ # Returns the most specific value of variable my_variable defined in a variables.yml file in the current page directory,
113
+ # or in its group directory, or in the site directory.
86
114
 
87
- The object in the sitetree (site, groups and pages) let you access the variables defined in the variables.yml files. Thus, you can do something like:
115
+ Sitetree nodes provide you with a way to use page-specific or group-specific variables in your code. Making good use of sitetree variables lets you write less code and makes your design more robust. An example is when you code navigation menus:
88
116
 
89
- @current_page.name # The name of the current page. 'index' in the case of our first example.
90
- @current_page.my_variable # Returns the value of variable my_variable defined in the variables.yml file in the
91
- # current page directory, or in its group directory, or in the site directory.
117
+ <ul>
118
+ <% @current_group.pages.each do |page| %>
119
+ <li><%= link_to(page.name.titleize, page) %></li>
120
+ <% end %>
121
+ </ul>
92
122
 
93
- Making good use of sitetree nodes and their variables you can easily employ page-specific values in your code.
123
+ Creating the menu in this way is not only incredibly fast, but also robust to changes: should you add new pages to the group or delete some existing pages, you don't need to rewrite the navigation menu, as it adapts to your changes.
94
124
 
95
125
  === Helpers
96
126
 
97
- Moka provides you with a bunch of super useful helper methods that you can use in your layouts and partials. Some of these helpers are link_to, path_to, image_tag, include_javascript_tag, stylesheet_link_tag and many more (Rails developers, do some of these methods sound familiar?). Read the docs and find out how these methods can help you making your code extremely efficient.
127
+ Moka provides you with a bunch of super useful helper methods that you can use in your layouts and partials. Some of these helpers are link_to, path_to, image_tag, include_javascript_tag, stylesheet_link_tag and many others (Rails developers, do some of these methods sound familiar?). Read the docs and find out how these methods can help you making your code extremely efficient.
128
+
129
+ You have also among your weapons the convenient Lipsum class, with which you can generate dummy text at the speed of light:
130
+
131
+ Lipsum.paragraphs 4
132
+ # Generate four paragraphs of dummy text, enclosed by <p> tags
133
+
134
+ Lipsum.sentences 3
135
+ # Generate three sentences of dummy text
136
+
137
+ Lipsum.words 10
138
+ # Generate 10 words of dummy text
139
+
140
+ All these Lipsum methods can also be passed a block:
141
+
142
+ <ul>
143
+ <% Lipsum.sentences(7) do |sentence| %>
144
+ <li><%= sentence %></li>
145
+ <% end %>
146
+ </ul>
98
147
 
99
148
  Need even more kung fu? Then you can code your own helper methods. Just code your methods into project/lib/helpers.rb and you will be able to use them in your layout and partials.
100
149
 
101
150
  === Writing CSS
102
151
 
103
- You are probably wondering now "OK, but what about CSS?". Well, you can code your CSS inline or place CSS files into the compiled/stylesheets directory and import them in your HTML. Alternatively, if you are a fan of the awesome SASS syntax, you can write SASS or SCSS files into the project/styles directory, and they will be magically compiled into CSS stylesheets into compile/stylesheets.
152
+ You are probably wondering now "OK, but what about CSS?". Well, you can code your CSS inline, or place CSS files into the compiled/stylesheets directory and import them in your HTML. Alternatively, if you are a fan of the awesome SASS syntax, you can write SASS or SCSS files into the project/styles directory, and they will be magically compiled into CSS stylesheets into compile/stylesheets.
104
153
 
105
154
  === Compiling the project into a website
106
155
 
107
- When you finished coding your pages (which, thanks to Moka awesomeness, look like haiku poetry) you are ready to release your website. It is as simple as typing:
156
+ When you are done coding your pages (which, thanks to Moka awesomeness, will look clean and simple like haiku poetry) you are ready to release your website. It is as simple as typing:
108
157
 
109
158
  moka compile
110
159
 
@@ -112,14 +161,24 @@ Moka will compile all your project code into pure HTML and CSS into the compiled
112
161
 
113
162
  === More Moka awesomeness
114
163
 
115
- Try to type in the command line something like:
164
+ Try typing in the command line something like:
116
165
 
117
- moka new site --template=another/project/path # Create a new moka project using another one as a template
118
- moka new group [--template=another_group] # Create a new group [using an existing one as a template]
119
- moka new page my_group:my_page -v title:"My Page Title" exclamation:yeah! # Create a page named my_page in group my_group
120
- # and define its variables title (with value "My
121
- # Page Title") and exclamation (with value "yeah!")
122
- moka inspect site # Show groups and variables defined at the site level
123
- moka inspect group my_group # Show pages and variables defined at the level of group my_group
124
- moka inspect page my_group:my_page # Show variables defined at the level of page my_page in group my_group
166
+ moka new site --template=another/project/path
167
+ # Create a new moka project using another one as a template
168
+
169
+ moka new group [--template=another_group]
170
+ # Create a new group [using an existing one as a template]
171
+
172
+ moka new page my_group:my_page -v title:"My Page Title" other_variable:"Moka Rocks!"
173
+ # Create a page named my_page in group my_group and define its variables title (with value "My Page Title")
174
+ # and other_variable (with value "Moka Rocks!") writing into the project/site/my_group/my_page/variables.yml file
175
+
176
+ moka inspect site
177
+ # Show groups and variables defined at the site level
178
+
179
+ moka inspect group my_group
180
+ # Show pages and variables defined at the level of group my_group
181
+
182
+ moka inspect page my_group:my_page
183
+ # Show variables defined at the level of page my_page in group my_group
125
184
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  MOKA_ROOT = File.expand_path("../../", File.dirname(__FILE__))
4
4
  require "rubygems"
5
- gem "moka", "0.1.3"
5
+ gem "moka", "0.1.4"
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module Moka
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 3
5
+ TINY = 4
6
6
  BUILD = "beta"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
data/moka.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{moka}
5
- s.version = "0.1.3"
5
+ s.version = "0.1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Luca Ongaro"]
9
- s.date = %q{2010-11-25}
9
+ s.date = %q{2010-11-29}
10
10
  s.default_executable = %q{moka}
11
11
  s.description = %q{Moka is a damn simple framework designed to build static websites like portfolios, showcases, minisites, HTML mockups, etc. Moka setup takes a single command, and it provides a hierarchical template system and some hyper-convenient helper functions so you never have to write more code than necessary. The result of your work is compiled to plain HTML, CSS and Javascript, so you just have to upload it to your server. Plus, don't forget the Lipsum helper functions to generate dummy text with a single line of code during development or in HTML mockups.}
12
12
  s.email = %q{mail@lucaongaro.eu}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luca Ongaro
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-25 00:00:00 +01:00
17
+ date: 2010-11-29 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency