genit 0.5 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/NEWS +20 -0
  2. data/TODO +40 -4
  3. data/VERSION +1 -1
  4. data/bin/genit +10 -2
  5. data/data/pages/index.html +10 -11
  6. data/data/pages/index2.html +1 -0
  7. data/data/styles/screen.css +12 -3
  8. data/data/templates/html_5 +5 -0
  9. data/data/templates/main.html +0 -6
  10. data/data/templates/xhtml_1.0_strict +5 -0
  11. data/data/templates/xhtml_1.0_transitional +5 -0
  12. data/lib/genit.rb +5 -18
  13. data/lib/genit/builders.rb +8 -0
  14. data/lib/genit/{body_link_builder.rb → builders/body_link_builder.rb} +7 -3
  15. data/lib/genit/{builder.rb → builders/builder.rb} +0 -0
  16. data/lib/genit/{builder_base.rb → builders/builder_base.rb} +0 -0
  17. data/lib/genit/{head_link_builder.rb → builders/head_link_builder.rb} +5 -0
  18. data/lib/genit/builders/img_builder.rb +39 -0
  19. data/lib/genit/{menu_builder.rb → builders/menu_builder.rb} +0 -0
  20. data/lib/genit/builders/script_builder.rb +37 -0
  21. data/lib/genit/documents.rb +5 -0
  22. data/lib/genit/{document_writer.rb → documents/document_writer.rb} +0 -0
  23. data/lib/genit/{fragment.rb → documents/fragment.rb} +0 -0
  24. data/lib/genit/{html_document.rb → documents/html_document.rb} +0 -0
  25. data/lib/genit/{xml_document.rb → documents/xml_document.rb} +0 -0
  26. data/lib/genit/extensions.rb +2 -44
  27. data/lib/genit/extensions/nokogiri_extension.rb +37 -0
  28. data/lib/genit/extensions/string_extension.rb +17 -0
  29. data/lib/genit/project.rb +4 -0
  30. data/lib/genit/{compiler.rb → project/compiler.rb} +12 -0
  31. data/lib/genit/{page_compiler.rb → project/page_compiler.rb} +21 -2
  32. data/lib/genit/project/project_creator.rb +119 -0
  33. data/lib/genit/tags.rb +9 -0
  34. data/lib/genit/tags/class_fragment_tag.rb +30 -0
  35. data/lib/genit/tags/class_menu_tag.rb +36 -0
  36. data/lib/genit/tags/class_news_tag.rb +52 -0
  37. data/lib/genit/tags/class_pages_tag.rb +34 -0
  38. data/lib/genit/tags/class_tag.rb +38 -0
  39. data/lib/genit/{var_tag.rb → tags/here_tag.rb} +10 -5
  40. data/lib/genit/{tag.rb → tags/tag.rb} +0 -0
  41. data/lib/genit/{tag_processor.rb → tags/tag_processor.rb} +4 -3
  42. data/lib/genit/utils.rb +2 -0
  43. data/lib/genit/{file_writer.rb → utils/file_writer.rb} +0 -0
  44. data/spec/class_news_tag_spec.rb +36 -0
  45. data/spec/class_tag_spec.rb +13 -0
  46. data/spec/compiler_spec.rb +1 -1
  47. data/spec/menu_builder_spec.rb +0 -14
  48. data/spec/page_compiler_spec.rb +3 -4
  49. data/spec/project_creator_spec.rb +6 -2
  50. data/spec/tag_processor_spec.rb +8 -0
  51. metadata +46 -27
  52. data/lib/genit/class_tag.rb +0 -66
  53. data/lib/genit/project_creator.rb +0 -72
data/NEWS CHANGED
@@ -1,3 +1,23 @@
1
+ v0.9 2011-09-04
2
+
3
+ * You can add news to your site with ease
4
+
5
+ * The tag 'var' does not exist anymore. It is replaced by the two-part tag
6
+ 'here' & 'what'
7
+
8
+ * Put your public files (photo, text, pdf, etc.) in the 'public' folder
9
+
10
+ * Put your javascript in the 'scripts' folder
11
+
12
+ * Relative links should be written relative to the root (the index.hmtl file)
13
+
14
+ * New '--empty' switch for the 'create' command
15
+
16
+ * New '--doctype' option for the 'create' command
17
+
18
+ * Fix bug #38: named anchor crashes the compiler
19
+
20
+
1
21
  v0.5 2011-08-06
2
22
 
3
23
  * You can pass string variables from page to template
data/TODO CHANGED
@@ -1,9 +1,45 @@
1
- dans la doc : tous les liens internes doivent être relatifs au dossier de base (fichier index.html)
2
1
 
3
2
 
4
3
 
5
- -------------
6
- news
7
4
 
5
+ BUG
6
+ ==================
8
7
 
9
- -------------
8
+
9
+
10
+
11
+ LES NEWS
12
+ ====================
13
+
14
+ D'abord simple, en html et en markdown:
15
+
16
+ <genit class="news" number="4" />
17
+ <genit class="news" />
18
+
19
+
20
+ Puis avec un wrapper:
21
+
22
+ <genit class="news" number="4" wrapper="a_news" />
23
+ <genit class="news" wrapper="a_news" />
24
+
25
+
26
+ TAG HERE & WHAT remplacent var
27
+ ===============================
28
+
29
+ DOSSIER PUBLIC
30
+ ================================
31
+
32
+ SCRIPTS
33
+ =============================
34
+
35
+ Les liens <img src> doivent être relativisés (comme les <a>)
36
+ ============================================================
37
+
38
+ les scripts doivent être relativisés
39
+ ==========================================================
40
+
41
+ switch --empty pour commande create
42
+ ======================================
43
+
44
+ supprimer le contenu de www/ avant compilation
45
+ ==================================================
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5
1
+ 0.9
data/bin/genit CHANGED
@@ -37,15 +37,23 @@ module Genit
37
37
  puts "genit #{File.read(File.join($GENIT_PATH, 'VERSION')).strip}"
38
38
  exit 0
39
39
  end
40
-
40
+
41
41
  end
42
42
 
43
43
  class CreateCommand < AbstractCommand
44
44
 
45
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
+
46
49
 
47
50
  def execute
48
- project = ProjectCreator.new project_name
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?
49
57
  project.create
50
58
  end
51
59
 
@@ -4,25 +4,24 @@
4
4
  Genit is a framework to build a <strong>static web site</strong>, that is a web site without server
5
5
  side programing language and database. A genit site consists only of xhtml code (+ css, medias and
6
6
  eventually javascript).
7
- </p>
8
-
9
- <p>
7
+ <br/>
8
+ <br/>
10
9
  <em>Genit is written in Ruby but there is no needs to know the Ruby language.</em>
11
- </p>
12
-
13
- <p>
10
+ <br/>
11
+ <br/>
14
12
  The Genit project is hosted on
15
13
  <a href="https://github.com/lkdjiin/genit" title="Source code of Genit">GitHub</a> under the terms
16
14
  of the MIT license. Feel free to fork it. Each new release will be announced on the
17
15
  <a href="http://freshmeat.net/projects/genit" title="Genit project on freshmeat">freshmeat</a> site.
18
- The development progress will be announced on Twitter:<br/>
19
- <a href="http://twitter.com/lkdjiin" class="twitter-follow-button" data-show-count="false">Follow @lkdjiin</a>
20
- <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
16
+ The development progress will be announced on
17
+ <a href="http://twitter.com/lkdjiin">Twitter</a>.
18
+
21
19
  </p>
22
20
 
23
21
  <h1>Get started</h1>
24
22
 
25
23
  <p>
26
- Read the <a href="https://github.com/lkdjiin/genit/blob/master/documentation/tutorial.markdown"
27
- "A short get started tutorial for Genit">tutorial</a> and make your site !
24
+ Read the <a href="http://lkdjiin.github.com/genit/documentation/tutorial.html"
25
+ "A short get started tutorial for Genit">tutorial</a> first, then have a look at the
26
+ <a href="http://lkdjiin.github.com/genit/documentation/index.html">documentation</a>.
28
27
  </p>
@@ -0,0 +1 @@
1
+ <h1>home page</h1>
@@ -1,9 +1,14 @@
1
1
  /* Delete this content and write your own rules */
2
2
 
3
3
  body {
4
- width:600px;
4
+ width:300px;
5
5
  margin:0 auto;
6
6
  font-family: Arial, Helvetica, FreeSans, sans-serif;
7
+ -webkit-border-radius:10px;
8
+ -moz-border-radius:10px;
9
+ -o-border-radius:10px;
10
+ border-radius:10px;
11
+ margin-top:50px;
7
12
  }
8
13
 
9
14
  #menu { display:none;}
@@ -13,10 +18,10 @@ font-size:1.2em;
13
18
  color:#555;
14
19
  }
15
20
 
16
- p:hover {color:#001;}
21
+ p:hover {color:#003;}
17
22
 
18
23
  p:hover a {
19
- background-color:#001 !important;
24
+ background-color:#003 !important;
20
25
  color:white !important;
21
26
  text-decoration:none !important;
22
27
  }
@@ -24,3 +29,7 @@ text-decoration:none !important;
24
29
  a {
25
30
  color:#334 !important;
26
31
  }
32
+
33
+ h1{color:#003;}
34
+
35
+ html{background-color:#336;}
@@ -0,0 +1,5 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
@@ -1,10 +1,4 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
1
  <title>Genit - Static web site framework</title>
7
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
8
2
  <link rel="stylesheet" type="text/css" media="all" href="styles/alsa/all.css" />
9
3
  <link rel="stylesheet" type="text/css" media="screen" href="styles/screen.css" />
10
4
  <link rel="stylesheet" type="text/css" media="print" href="styles/print.css" />
@@ -0,0 +1,5 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@@ -0,0 +1,5 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
data/lib/genit.rb CHANGED
@@ -1,23 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
-
3
2
  require 'genit/extensions'
4
- require 'genit/project_creator'
5
- require 'genit/html_document'
6
- require 'genit/xml_document'
7
- require 'genit/file_writer'
8
- require 'genit/document_writer'
9
- require 'genit/compiler'
10
- require 'genit/page_compiler'
11
- require 'genit/builder'
12
- require 'genit/builder_base'
13
- require 'genit/menu_builder'
14
- require 'genit/head_link_builder'
15
- require 'genit/body_link_builder'
16
- require 'genit/fragment'
17
- require 'genit/tag_processor'
18
- require 'genit/tag'
19
- require 'genit/var_tag'
20
- require 'genit/class_tag'
3
+ require 'genit/project'
4
+ require 'genit/documents'
5
+ require 'genit/utils'
6
+ require 'genit/builders'
7
+ require 'genit/tags'
21
8
 
22
9
  module Genit
23
10
  end
@@ -0,0 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'genit/builders/builder'
3
+ require 'genit/builders/builder_base'
4
+ require 'genit/builders/menu_builder'
5
+ require 'genit/builders/head_link_builder'
6
+ require 'genit/builders/body_link_builder'
7
+ require 'genit/builders/img_builder'
8
+ require 'genit/builders/script_builder'
@@ -7,9 +7,9 @@ module Genit
7
7
  # Modify links.
8
8
  class BodyLinkBuilder < BuilderBase
9
9
 
10
- # Public: Build the menu of a particular page.
10
+ # Public: Relativize links.
11
11
  #
12
- # page_name - The string filename of the page to build menu for.
12
+ # page_name - The string filename of the page.
13
13
  #
14
14
  # Returns the modified Nokogiri::XML::Document
15
15
  def build_for_page page_name
@@ -24,11 +24,15 @@ module Genit
24
24
 
25
25
  def update link
26
26
  @path = link['href']
27
- return if @path =~ URI::regexp
27
+ return if not_an_internal_link?
28
28
  nb = BuilderBase::get_number_of_base_dirs @page_name
29
29
  make_relative nb
30
30
  link['href'] = @path
31
31
  end
32
+
33
+ def not_an_internal_link?
34
+ @path.nil? or @path =~ URI::regexp
35
+ end
32
36
 
33
37
  end
34
38
 
File without changes
@@ -22,11 +22,16 @@ module Genit
22
22
 
23
23
  def update link
24
24
  @path = link['href']
25
+ return if not_an_internal_link?
25
26
  nb = BuilderBase::get_number_of_base_dirs @page_name
26
27
  make_relative nb
27
28
  link['href'] = @path
28
29
  end
29
30
 
31
+ def not_an_internal_link?
32
+ @path.nil? or @path =~ URI::regexp
33
+ end
34
+
30
35
  end
31
36
 
32
37
  end
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'uri'
4
+
5
+ module Genit
6
+
7
+ # Modify img src.
8
+ class ImgBuilder < BuilderBase
9
+
10
+ # Public: Relativize image source.
11
+ #
12
+ # page_name - The string filename of the page.
13
+ #
14
+ # Returns the modified Nokogiri::XML::Document
15
+ def build_for_page page_name
16
+ build page_name, get_links
17
+ end
18
+
19
+ private
20
+
21
+ def get_links
22
+ @document.css("body img")
23
+ end
24
+
25
+ def update link
26
+ @path = link['src']
27
+ return if not_an_internal_link?
28
+ nb = BuilderBase::get_number_of_base_dirs @page_name
29
+ make_relative nb
30
+ link['src'] = @path
31
+ end
32
+
33
+ def not_an_internal_link?
34
+ @path.nil? or @path =~ URI::regexp
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Genit
4
+
5
+ # Modify script tags.
6
+ class ScriptBuilder < BuilderBase
7
+
8
+ # Public: Relativize the <script src=""> tags of a particular page.
9
+ #
10
+ # page_name - The string filename of the page.
11
+ #
12
+ # Returns the modified Nokogiri::XML::Document
13
+ def build_for_page page_name
14
+ build page_name, head_links
15
+ end
16
+
17
+ private
18
+
19
+ def head_links
20
+ @document.css("script")
21
+ end
22
+
23
+ def update link
24
+ @path = link['src']
25
+ return if not_an_internal_link?
26
+ nb = BuilderBase::get_number_of_base_dirs @page_name
27
+ make_relative nb
28
+ link['src'] = @path
29
+ end
30
+
31
+ def not_an_internal_link?
32
+ @path.nil? or @path =~ URI::regexp
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'genit/documents/html_document'
3
+ require 'genit/documents/xml_document'
4
+ require 'genit/documents/fragment'
5
+ require 'genit/documents/document_writer'
File without changes
@@ -1,45 +1,3 @@
1
1
  # -*- encoding: utf-8 -*-
2
-
3
- class String
4
-
5
- def force_html_extension
6
- self.gsub /markdown$/, 'html'
7
- end
8
-
9
- def force_html_extension!
10
- self.gsub! /markdown$/, 'html'
11
- end
12
-
13
- def markdown_ext?
14
- self.end_with?('.markdown')
15
- end
16
-
17
- end
18
-
19
- module Nokogiri
20
- module XML
21
-
22
- # I think it's a bad idea to extend the Nokogiri library cause it makes a
23
- # too big dependency on Genit.
24
- # It will be much better to do a little wrapper over Nokogiri::XML::Node.
25
- class Node
26
-
27
- def genit_class?
28
- if self['class']
29
- true
30
- else
31
- false
32
- end
33
- end
34
-
35
- def genit_var?
36
- if self['var']
37
- true
38
- else
39
- false
40
- end
41
- end
42
-
43
- end
44
- end
45
- end
2
+ require 'genit/extensions/string_extension'
3
+ require 'genit/extensions/nokogiri_extension'