genit 1.0.1 → 2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/NEWS +12 -28
  2. data/README.markdown +6 -2
  3. data/Rakefile +1 -1
  4. data/TODO +177 -12
  5. data/VERSION +1 -1
  6. data/bin/genit +18 -20
  7. data/data/styles/screen.css +5 -9
  8. data/data/templates/main.html +0 -1
  9. data/lib/genit.rb +9 -4
  10. data/lib/genit/builders/body_link_builder.rb +8 -8
  11. data/lib/genit/builders/builder_base.rb +11 -11
  12. data/lib/genit/builders/head_link_builder.rb +8 -8
  13. data/lib/genit/builders/relativizer.rb +12 -12
  14. data/lib/genit/builders/script_builder.rb +7 -7
  15. data/lib/genit/documents/document_writer.rb +14 -14
  16. data/lib/genit/documents/fragment.rb +23 -22
  17. data/lib/genit/documents/xml_document.rb +5 -1
  18. data/lib/genit/project.rb +1 -0
  19. data/lib/genit/project/compiler.rb +54 -73
  20. data/lib/genit/project/page_compiler.rb +41 -41
  21. data/lib/genit/project/pages_finder.rb +6 -6
  22. data/lib/genit/project/project_creator.rb +116 -111
  23. data/lib/genit/project/root_cleaner.rb +31 -0
  24. data/lib/genit/project/rss_feed.rb +14 -14
  25. data/lib/genit/server.rb +2 -0
  26. data/lib/genit/server/server.rb +33 -0
  27. data/lib/genit/tags/class_fragment_tag.rb +2 -2
  28. data/lib/genit/tags/class_menu_tag.rb +2 -1
  29. data/lib/genit/tags/class_news_tag.rb +24 -24
  30. data/lib/genit/tags/class_pages_tag.rb +1 -1
  31. data/lib/genit/tags/here_tag.rb +22 -18
  32. data/lib/genit/utils/news_utils.rb +3 -3
  33. data/spec/class_news_tag_spec.rb +5 -5
  34. data/spec/compiler_spec.rb +51 -60
  35. data/spec/fragment_spec.rb +19 -19
  36. data/spec/html_document_spec.rb +10 -10
  37. data/spec/page_compiler_spec.rb +13 -9
  38. data/spec/pages_finder_spec.rb +11 -11
  39. data/spec/project_creator_spec.rb +53 -102
  40. data/spec/test-files/malformed.html +5 -0
  41. data/spec/xml_document_spec.rb +5 -0
  42. metadata +6 -9
  43. data/data/styles/alsa/all.css +0 -130
  44. data/data/styles/yui/all.css +0 -3
  45. data/data/styles/yui/base.css +0 -80
  46. data/data/styles/yui/fonts.css +0 -47
  47. data/data/styles/yui/reset.css +0 -126
  48. data/data/templates/xhtml_1.0_strict +0 -5
  49. data/data/templates/xhtml_1.0_transitional +0 -5
data/NEWS CHANGED
@@ -1,89 +1,73 @@
1
- v1.0.1 2013-03-13
1
+ v2.0 2013-03-29
2
+ * Improve the layout folder structure, which add interesting side effects:
3
+ - faster compilation
4
+ - less use of compile command
5
+ - takes less size on disk
6
+ * Genit is now html5 only
7
+ * Genit provide a web server for development
8
+ * Config file is no longer an hidden file
9
+ * I remove all css templates
10
+ * Genit put an error message when the main template is malformed
11
+
2
12
 
13
+ v1.0.1 2013-03-13
3
14
  * Fix a bug that creates a bad html5 doctype
4
15
 
5
16
 
6
17
  v1.0 2011-10-02
7
-
8
18
  * Genit creates a sitemap.xml
9
-
10
19
  * Genit puts an error message when:
11
20
  - config file not present
12
21
  - unknown tag
13
22
  - bad or incomplete fragment tag
14
23
  - syntax error in .config
15
-
16
24
  * Genit puts a warning message when a here tag is used without its counterpart
17
-
18
25
  * Version is added to the .genit file
19
26
 
20
27
 
21
28
  v0.99 2011-09-25
22
-
23
29
  * Genit creates an RSS feed for your news articles
24
30
 
25
31
 
26
32
  v0.9 2011-09-04
27
-
28
33
  * You can add news to your site with ease
29
-
30
34
  * The tag 'var' does not exist anymore. It is replaced by the two-part tag
31
35
  'here' & 'what'
32
-
33
36
  * Put your public files (photo, text, pdf, etc.) in the 'public' folder
34
-
35
37
  * Put your javascript in the 'scripts' folder
36
-
37
38
  * Relative links should be written relative to the root (the index.hmtl file)
38
-
39
39
  * New '--empty' switch for the 'create' command
40
-
41
40
  * New '--doctype' option for the 'create' command
42
-
43
41
  * Fix bug #38: named anchor crashes the compiler
44
42
 
45
43
 
46
44
  v0.5 2011-08-06
47
-
48
45
  * You can pass string variables from page to template
49
-
50
46
  * Pages can be organized into subfolders
51
-
52
47
  * fix a bug where the cli option -v crashed
53
48
 
54
49
 
55
50
  v0.4.1 2011-07-30
56
-
57
51
  * Fix a bug where the closing part of auto-closing tags were forgotten.
58
52
 
59
53
 
60
54
  v0.4 2011-07-25
61
-
62
55
  * better smoke test
63
-
64
56
  * basic user documentation
65
-
66
57
  * genit use a simple project file
67
-
68
58
  * use clamp as a command line framework
69
59
 
70
60
 
71
61
  v0.3 2011-07-23
72
-
73
62
  * You can split a page in a multitude of fragments.
74
63
 
75
64
 
76
65
  v0.2 2011-07-02
77
-
78
66
  * Globally styling your site
79
-
80
67
  * Manage a main menu
81
68
 
82
69
 
83
70
  v0.1 2011-06-25
84
-
85
71
  * Create a project
86
-
87
72
  * Compile a project (one template, multiple pages)
88
-
89
73
  * A page can be in html or in markdown format
@@ -6,8 +6,12 @@ and database. A genit site consists only of xhtml code (+ css, medias and eventu
6
6
 
7
7
  Genit is written in Ruby but there is no needs to know the Ruby language.
8
8
 
9
- The project is in early development stage, see
10
- [project guidelines](https://github.com/lkdjiin/genit/blob/master/project_guidelines.markdown).
9
+ **------------------------------------------------------------------------**
10
+
11
+ **This readme file and all the documentation refers to version 1.0 of genit.
12
+ I'm currently writing the doc for genit version 2.0**
13
+
14
+ **------------------------------------------------------------------------**
11
15
 
12
16
  Description
13
17
  -----------
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ task :default => :spec
13
13
 
14
14
  desc 'Test genit with rspec'
15
15
  RSpec::Core::RakeTask.new(:spec) do |t|
16
- t.rspec_opts = ['--color --format documentation']
16
+ t.rspec_opts = ['--color']
17
17
  end
18
18
 
19
19
  desc 'Check for code smells'
data/TODO CHANGED
@@ -1,25 +1,190 @@
1
- BUG
2
- ================
1
+ version 2
2
+ =============================================================
3
3
 
4
- Un site HTML5 compilé -> le résultat du doctype, head, etc. est un mélange
5
- de html5 et xhtml.
4
+ [done] improve the layout folder structure
5
+ [done] html5 uniquement
6
+ [done] ajouter un serveur
7
+ [done] config file should not be hidden
8
+ [done] retirer alsa et yui
9
+ [done] error msg when template is malformed
6
10
 
7
- Update docs to reflect the fact that all tags MUST be closed.
8
11
 
12
+ version 2.x
13
+ ===============================================================
14
+ menu: Pouvoir changer l'id "actif". Exemple li.active avec twitter bootstrap.
15
+ a custom class for the selected menu item
9
16
 
10
- messages warning
11
- ----------------
17
+ use haml
18
+
19
+ use sass/scss or less
20
+
21
+ Document the genit tag and its attributes
22
+
23
+ think about a deamon to auto-compile
24
+
25
+ think about a pager for the news
26
+
27
+ Think about i18n
28
+
29
+ per page script
30
+
31
+ per page style
12
32
 
33
+ --minimize option for the compile command
13
34
 
14
35
  si j'écris <h1>news page (en oubliant le tag de fin) Genit ne dis
15
36
  rien et ajoute silencieusement le </h1>. Voir si on peut lui faire
16
- cracher un warning (ou une erreur si pas possible warning).
37
+ cracher une erreur.
17
38
 
18
39
  Quand je fais reférence à une url interne inexistante, il serait bon
19
- d'avoir un warning.
20
-
21
- dans le dossier page on accepte uniquement .html et .markdown (warning)
40
+ d'avoir une erreur
22
41
 
23
42
  si j'écris </br> (au lieu de <br/>) Genit ne dis rien, le tag est ignoré.
24
- Voir si on peut lui faire cracher un warning (ou une erreur si pas possible warning).
43
+ Voir si on peut lui faire cracher une erreur.
44
+
45
+ Pouvoir utiliser les news avec markdown.
46
+
47
+ dans le dossier page on accepte uniquement .html et .markdown (sinon erreur)
48
+
49
+
50
+
51
+
52
+ Project guidelines
53
+ ==================
54
+
55
+ Basic objectives
56
+ ----------------
57
+
58
+ At a minimum, Genit should allow to do this :
59
+
60
+ + include typical sections:
61
+ - header
62
+ - footer
63
+ - sitemap
64
+ - menu
65
+ + generate the RSS feed (with all news, or only a certain number)
66
+ + generate news section (with all news, or only a certain number)
67
+ + include different css files per page
68
+ + include different script files per page
69
+ + generate different `<meta>` per page (title, keywords, etc.)
70
+
71
+ Implementation
72
+ --------------
73
+
74
+ ### Create a project
75
+
76
+ We use the following command line :
77
+
78
+ genit create my-site
79
+ cd my-site
80
+
81
+ #### Project structure
82
+
83
+ my-site/
84
+ fragments/
85
+ news/
86
+ 2011-06-19.markdown
87
+ pages/
88
+ index.markdown
89
+ scripts/
90
+ styles/
91
+ alsa/
92
+ all.css
93
+ yui/
94
+ all.css
95
+ handheld.css
96
+ print.css
97
+ screen.css
98
+ images/
99
+ templates/
100
+ main.html
101
+ menu.html
102
+ www/
103
+
104
+ #### Fragments folder
105
+
106
+ Here we are some fragments, pieces of page.
107
+
108
+ <genit class="fragment" file="foo.markdown" />
109
+
110
+ A fragment can be included in any page you want.
111
+
112
+ Thinking in page fragment help to modularize the xthml code, like any other "real" programing language.
113
+
114
+ #### News folder
115
+
116
+ To include the X latest news:
117
+
118
+ <genit class="news" number="5" />
119
+
120
+ Without number attribute, we include all news.
121
+
122
+ The news are marked with the file name, which is the date.
123
+ I know it allows only one daily news, but for a static web site, I see
124
+ no problem.
125
+
126
+ #### Pages folder
127
+
128
+ All site pages are in this folder. Written in .html or .markdown.
129
+
130
+
131
+ #### Scripts folder
132
+
133
+ I think to include prototype and scriptaculous by default, but:
134
+
135
+ * If you don't want to use javascript, don't use it.
136
+ * You can use any framework you want.
137
+
138
+ To include a script in the `<head></head>` tag of a particular page,
139
+ we can write (anywhere in the page but it's more readable at the beginning):
140
+
141
+ <genit class="script" file="foo.js" />
142
+
143
+
144
+ #### Styles folder
145
+
146
+ Everything that is related to the design of the site goes here.
147
+
148
+ To include a particular css file in the `<head></head>` tag of a particular page,
149
+ we can write (anywhere in the page but it's more readable at the beginning):
150
+
151
+ <genit class="css" file="foo.css" />
152
+
153
+ #### Templates folder
154
+
155
+ This is the wrapper(s) for all your site pages. Other frameworks may call it 'layout'.
156
+
157
+ Only written in .html.
158
+ For now, there is only two templates: the 'main.html' and the 'menu.html'.
159
+
160
+ To include a page in the template:
161
+
162
+ <genit class="pages" />
163
+
164
+ Some sections are found on the vast majority of web sites : header, footer,
165
+ main menu, bottom menu, left side, right side and sitemap. To include those
166
+ sections we'll write
167
+
168
+ <genit class="header" />
169
+ <genit class="footer" />
170
+ etc.
171
+
172
+ #### www folder
173
+
174
+ The "compiled" project will go here.
175
+
176
+ TODO il serait peut-être bien d'avoir une option pour changer ce nom de dossier ?
177
+
178
+ ### Compiling the project
179
+
180
+ The following command will generate the web site in the www folder:
181
+
182
+ genit compile
183
+
184
+ A shortcut:
185
+
186
+ genit cc
187
+
188
+ The --minimize option minimize the size of the file, good for production phase:
25
189
 
190
+ genit compile --minimize
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 2.0
data/bin/genit CHANGED
@@ -32,48 +32,46 @@ include Genit
32
32
  module Genit
33
33
 
34
34
  class AbstractCommand < Clamp::Command
35
-
36
35
  option ['-v', '--version'], :flag, "print version" do
37
36
  puts "genit #{File.read(File.join($GENIT_PATH, 'VERSION')).strip}"
38
37
  exit 0
39
38
  end
40
-
41
39
  end
42
-
40
+
41
+ # Command to create a project.
43
42
  class CreateCommand < AbstractCommand
44
43
 
45
- parameter "NAME", "the name of the project", :attribute_name => :project_name
46
- option ["-d", "--doctype"], "DOCTYPE", "The Document Type Definition", :default => "html_5"
47
- option ["-e", "--empty"], :flag, "Do not produce smoke test", :default => false
48
-
44
+ parameter "NAME", "the name of the project",
45
+ :attribute_name => :project_name
46
+ option ["-e", "--empty"], :flag, "Do not produce smoke test",
47
+ :default => false
49
48
 
50
49
  def execute
51
- valid_doctypes = ['xhtml_1.0_strict', 'xhtml_1.0_transitional', 'html_5']
52
- unless valid_doctypes.include? doctype
53
- puts 'Valid doctypes are ' + valid_doctypes.inspect
54
- exit 1
55
- end
56
- project = ProjectCreator.new project_name, doctype, empty?
50
+ project = ProjectCreator.new project_name, empty?
57
51
  project.create
58
52
  end
59
-
60
53
  end
61
-
62
- class CompileCommand < AbstractCommand
63
54
 
55
+ # Command to compile a project.
56
+ class CompileCommand < AbstractCommand
64
57
  def execute
65
58
  compiler = Compiler.new Dir.getwd
66
59
  compiler.compile
67
60
  end
68
-
69
61
  end
70
-
62
+
63
+ # Command to start the web server.
64
+ class ServerCommand < AbstractCommand
65
+ def execute
66
+ Server.new(Dir.getwd).start
67
+ end
68
+ end
69
+
71
70
  class MainCommand < AbstractCommand
72
-
73
71
  subcommand "create", "Create a project.", CreateCommand
74
72
  subcommand "compile", "Compile the web site.", CompileCommand
75
73
  subcommand "cc", "Compile the web site.", CompileCommand
76
-
74
+ subcommand "server", "Run WEBrick.", ServerCommand
77
75
  end
78
76
 
79
77
  end
@@ -14,22 +14,18 @@ margin-top:50px;
14
14
  #menu { display:none;}
15
15
 
16
16
  p {
17
- font-size:1.2em;
18
- color:#555;
17
+ font-size:16px;
18
+ color:#bbb;
19
19
  }
20
20
 
21
- p:hover {color:#003;}
21
+ p:hover {color:#fff;}
22
22
 
23
- p:hover a {
23
+ a {
24
24
  background-color:#003 !important;
25
25
  color:white !important;
26
26
  text-decoration:none !important;
27
27
  }
28
28
 
29
- a {
30
- color:#334 !important;
31
- }
32
-
33
- h1{color:#003;}
29
+ h1{color:#fff;}
34
30
 
35
31
  html{background-color:#336;}
@@ -1,5 +1,4 @@
1
1
  <title>Genit - Static web site framework</title>
2
- <link rel="stylesheet" type="text/css" media="all" href="styles/alsa/all.css" />
3
2
  <link rel="stylesheet" type="text/css" media="screen" href="styles/screen.css" />
4
3
  <link rel="stylesheet" type="text/css" media="print" href="styles/print.css" />
5
4
  </head>
@@ -5,6 +5,7 @@ require 'genit/documents'
5
5
  require 'genit/utils'
6
6
  require 'genit/builders'
7
7
  require 'genit/tags'
8
+ require 'genit/server'
8
9
 
9
10
  module Errors
10
11
 
@@ -12,14 +13,18 @@ module Errors
12
13
  puts "Error: #{message}"
13
14
  exit 1
14
15
  end
15
-
16
+
16
17
  def warning message
17
18
  puts "Warning: #{message}"
18
19
  end
19
-
20
+
20
21
  end
21
-
22
+
22
23
  module Genit
23
24
  include Errors
24
-
25
+
26
+ PAGES_DIR = "src/pages"
27
+ TEMPLATES_DIR = "src/templates"
28
+ FRAGMENTS_DIR = "src/fragments"
29
+ NEWS_DIR = "src/news"
25
30
  end