genit 2.0 → 2.1

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.
data/NEWS CHANGED
@@ -1,3 +1,8 @@
1
+ v2.1 2013-04-02
2
+ * Support Haml
3
+ * Support Sass
4
+
5
+
1
6
  v2.0 2013-03-29
2
7
  * Improve the layout folder structure, which add interesting side effects:
3
8
  - faster compilation
@@ -6,13 +6,6 @@ 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
- **------------------------------------------------------------------------**
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
- **------------------------------------------------------------------------**
15
-
16
9
  Description
17
10
  -----------
18
11
 
@@ -50,9 +43,8 @@ Usage
50
43
 
51
44
  genit create my-site
52
45
  cd my-site
53
- (*edit some pages*)
54
-
55
46
  genit compile
47
+ genit server
56
48
 
57
49
  See the wiki for user documentation and a tutorial.
58
50
 
@@ -66,6 +58,11 @@ Dependencies
66
58
  * nokogiri (xml parser)
67
59
  * bluecloth (markdown parser)
68
60
  * clamp (command line utility)
61
+ * haml (clean markup language)
62
+ * sass (CSS extension)
63
+
64
+ See [installing nokogiri](http://nokogiri.org/tutorials/installing_nokogiri.html)
65
+ for possible dependencies depending of your operating system.
69
66
 
70
67
  ### Contributors dependencies
71
68
 
@@ -78,7 +75,7 @@ License
78
75
 
79
76
  Expat License (also known as MIT)
80
77
 
81
- Copyright (c) 2011 Xavier Nayrac
78
+ Copyright (c) 2011-2013 Xavier Nayrac
82
79
 
83
80
  Permission is hereby granted, free of charge, to any person obtaining
84
81
  a copy of this software and associated documentation files (the
data/TODO CHANGED
@@ -1,28 +1,50 @@
1
- version 2
1
+ version 2.1
2
2
  =============================================================
3
3
 
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
4
+ [ok] use haml
5
+ [ok] utiliser haml dans pages
6
+ [ok] utiliser haml dans fragments
7
+ [ok] utiliser haml dans news
8
+ [ok] utiliser haml dans templates
9
+ [ok] genit create --haml
10
+
11
+ [ok] use sass/scss
12
+ [ok] doit marcher avec sous-dossiers
13
+
10
14
 
11
15
 
12
16
  version 2.x
13
17
  ===============================================================
18
+ s'assurer que <genit class="footer"/> existe, sinon le readme ment.
19
+
20
+ tester avec la dernière version de clamp, et certainement arreter la version
21
+ dans le gemspec
22
+
23
+ Pouvoir utiliser les news avec markdown. Apparement c'est déjà possible,
24
+ il faut tester.
25
+
26
+ s'assurer qu'on puisse avoir des sous-dossiers dans fragments/.
27
+
14
28
  menu: Pouvoir changer l'id "actif". Exemple li.active avec twitter bootstrap.
15
29
  a custom class for the selected menu item
16
30
 
17
- use haml
31
+ un tuto juste pour le menu
18
32
 
19
- use sass/scss or less
33
+ think about a pager for the news
20
34
 
21
- Document the genit tag and its attributes
35
+ how to: a blog in 5 minutes
22
36
 
23
- think about a deamon to auto-compile
37
+ less support
24
38
 
25
- think about a pager for the news
39
+ --minimize option for the compile command
40
+
41
+
42
+ En attente
43
+ =========================================
44
+
45
+ un template pour les news ?
46
+
47
+ think about a deamon to auto-compile
26
48
 
27
49
  Think about i18n
28
50
 
@@ -30,8 +52,6 @@ per page script
30
52
 
31
53
  per page style
32
54
 
33
- --minimize option for the compile command
34
-
35
55
  si j'écris <h1>news page (en oubliant le tag de fin) Genit ne dis
36
56
  rien et ajoute silencieusement le </h1>. Voir si on peut lui faire
37
57
  cracher une erreur.
@@ -42,15 +62,15 @@ d'avoir une erreur
42
62
  si j'écris </br> (au lieu de <br/>) Genit ne dis rien, le tag est ignoré.
43
63
  Voir si on peut lui faire cracher une erreur.
44
64
 
45
- Pouvoir utiliser les news avec markdown.
46
-
47
65
  dans le dossier page on accepte uniquement .html et .markdown (sinon erreur)
48
66
 
67
+ refaire toutes les copies d'écran du site
49
68
 
69
+ refactor ProjectCreator si j'ajoute un autre moteur de template.
50
70
 
51
71
 
52
72
  Project guidelines
53
- ==================
73
+ =====================================================================
54
74
 
55
75
  Basic objectives
56
76
  ----------------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0
1
+ 2.1
data/bin/genit CHANGED
@@ -45,9 +45,12 @@ module Genit
45
45
  :attribute_name => :project_name
46
46
  option ["-e", "--empty"], :flag, "Do not produce smoke test",
47
47
  :default => false
48
+ option ["-H", "--haml"], :flag, "Create project files with haml",
49
+ :default => false
48
50
 
51
+ # TODO faire un hash d'option pour empty?, etc.
49
52
  def execute
50
- project = ProjectCreator.new project_name, empty?
53
+ project = ProjectCreator.new project_name, empty?, haml?
51
54
  project.create
52
55
  end
53
56
  end
@@ -0,0 +1,29 @@
1
+ %h1 Welcome to Genit !
2
+ %p
3
+ Genit is a framework to build a
4
+ = succeed "," do
5
+ %strong static web site
6
+ that is a web site without server
7
+ side programing language and database. A genit site consists only of xhtml code (+ css, medias and
8
+ eventually javascript).
9
+ %br/
10
+ %br/
11
+ %em Genit is written in Ruby but there is no needs to know the Ruby language.
12
+ %br/
13
+ %br/
14
+ The Genit project is hosted on
15
+ %a{:href => "https://github.com/lkdjiin/genit", :title => "Source code of Genit"} GitHub
16
+ under the terms
17
+ of the MIT license. Feel free to fork it. Each new release will be announced on the
18
+ %a{:href => "http://freshmeat.net/projects/genit", :title => "Genit project on freshmeat"} freshmeat
19
+ site.
20
+ The development progress will be announced on
21
+ = succeed "." do
22
+ %a{:href => "http://twitter.com/lkdjiin"} Twitter
23
+ %h1 Get started
24
+ %p
25
+ Read the <a href="http://lkdjiin.github.com/genit/documentation/tutorial.html"
26
+ "A short get started tutorial for Genit">tutorial
27
+ first, then have a look at the
28
+ = succeed "." do
29
+ %a{:href => "http://lkdjiin.github.com/genit/documentation/index.html"} documentation
@@ -0,0 +1 @@
1
+ %h1 home page
@@ -0,0 +1,10 @@
1
+ !!! 5
2
+ %html{:lang => "en"}
3
+ %head
4
+ %meta{:charset => "UTF-8"}/
5
+ %title Genit - Static web site framework
6
+ %link{:href => "styles/screen.css", :media => "screen", :rel => "stylesheet", :type => "text/css"}/
7
+ %link{:href => "styles/print.css", :media => "print", :rel => "stylesheet", :type => "text/css"}/
8
+ %body
9
+ %genit.menu/
10
+ %genit.pages/
@@ -0,0 +1,3 @@
1
+ %ul#menu
2
+ %li
3
+ %a{:href => "index.html"} home
@@ -7,6 +7,8 @@ require 'genit/builders'
7
7
  require 'genit/tags'
8
8
  require 'genit/server'
9
9
 
10
+ require 'sass'
11
+
10
12
  module Errors
11
13
 
12
14
  def error message
@@ -27,4 +29,5 @@ module Genit
27
29
  TEMPLATES_DIR = "src/templates"
28
30
  FRAGMENTS_DIR = "src/fragments"
29
31
  NEWS_DIR = "src/news"
32
+ STYLES_DIR = "styles"
30
33
  end
@@ -2,12 +2,13 @@
2
2
 
3
3
  require 'nokogiri'
4
4
  require 'bluecloth'
5
+ require 'haml'
5
6
 
6
7
  module Genit
7
8
 
8
9
  # Open an html file in various format.
9
10
  class HtmlDocument
10
-
11
+
11
12
  # Public: Open an entire html document.
12
13
  # If the file does not contain a <bogy> tag, a doctype, etc, they will be
13
14
  # automatically added.
@@ -18,7 +19,7 @@ module Genit
18
19
  def self.open file
19
20
  Nokogiri::HTML(File.open(file))
20
21
  end
21
-
22
+
22
23
  # Public: Open a fragment of html document.
23
24
  #
24
25
  # file - Full path String filename.
@@ -28,7 +29,7 @@ module Genit
28
29
  string = IO.read file
29
30
  Nokogiri::HTML.fragment string
30
31
  end
31
-
32
+
32
33
  # Public: Open a file as a string.
33
34
  #
34
35
  # file - Full path String name of a html or markdown file.
@@ -38,26 +39,31 @@ module Genit
38
39
  string = IO.read file
39
40
  if file.markdown_ext?
40
41
  BlueCloth.new(string).to_html
42
+ elsif file.haml_ext?
43
+ Haml::Engine.new(string, :format => :xhtml).render
41
44
  else
42
45
  string
43
46
  end
44
47
  end
45
-
48
+
46
49
  # Public: Open a file as a string, taking care of fragment tags.
47
50
  # All fragment tags are replaced by a new content.
48
51
  #
49
- # file - Full path String name of a html or markdown file.
52
+ # file - Full path String name of a (html|markdown|haml) file.
50
53
  #
51
54
  # Returns a String.
52
55
  def self.build_page_content(file, working_dir)
53
56
  # TODO éviter le working_dir
57
+ str = IO.read(file)
54
58
  if file.markdown_ext?
55
- BlueCloth.new(IO.read(file)).to_html
59
+ BlueCloth.new(str).to_html
60
+ elsif file.haml_ext?
61
+ Haml::Engine.new(str, :format => :xhtml).render
56
62
  else
57
63
  Fragment.new(file, working_dir).to_html
58
64
  end
59
65
  end
60
-
66
+
61
67
  # Public: Get the list of <genit> tag in a document.
62
68
  #
63
69
  # file - Nokogiri::HTML or Nokogiri::XML document.
@@ -66,7 +72,7 @@ module Genit
66
72
  def self.genit_tags_from file
67
73
  file.css "genit"
68
74
  end
69
-
75
+
70
76
  end
71
77
 
72
78
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'nokogiri'
4
4
  require 'bluecloth'
5
+ require 'haml'
5
6
 
6
7
  module Genit
7
8
 
@@ -16,10 +17,20 @@ module Genit
16
17
  def self.open file
17
18
  begin
18
19
  Nokogiri::XML(File.open(file)){|config| config.strict}
19
- rescue Nokogiri::XML::SyntaxError => e
20
- error "Malformed xhtml in file #{file} : #{e}"
20
+ rescue Nokogiri::XML::SyntaxError => ex
21
+ error "Malformed xhtml in file #{file} : #{ex}"
21
22
  end
22
23
  end
24
+
25
+ # Public: Open a (xml) document from a haml file.
26
+ #
27
+ # file - Full path String filename of haml file.
28
+ #
29
+ # Returns a Nokogiri::XML document.
30
+ def self.open_via_haml file
31
+ tmp = Haml::Engine.new(File.open(file).read, :format => :xhtml).render
32
+ Nokogiri::XML(tmp)
33
+ end
23
34
 
24
35
  # Public: Open a fragment of xml document.
25
36
  #
@@ -3,15 +3,18 @@
3
3
  class String
4
4
 
5
5
  def force_html_extension
6
- self.gsub /markdown$/, 'html'
6
+ self.gsub /(markdown|haml)$/, 'html'
7
7
  end
8
8
 
9
9
  def force_html_extension!
10
- self.gsub! /markdown$/, 'html'
10
+ self.gsub! /(markdown|haml)$/, 'html'
11
11
  end
12
12
 
13
13
  def markdown_ext?
14
14
  self.end_with?('.markdown')
15
15
  end
16
16
 
17
+ def haml_ext?
18
+ self.end_with?('.haml')
19
+ end
17
20
  end
@@ -5,3 +5,4 @@ require 'genit/project/page_compiler'
5
5
  require 'genit/project/rss_feed'
6
6
  require 'genit/project/pages_finder'
7
7
  require 'genit/project/root_cleaner'
8
+ require 'genit/project/css'
@@ -18,6 +18,7 @@ module Genit
18
18
  def compile
19
19
  RootCleaner.new(@working_dir).clean
20
20
  compile_site
21
+ Css.new(@working_dir).render
21
22
  end
22
23
 
23
24
  private
@@ -0,0 +1,50 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'sass'
4
+
5
+ module Genit
6
+
7
+ # Deals with the styles directory.
8
+ class Css
9
+
10
+ # Public: Constructor.
11
+ #
12
+ # working_dir - The String working directory, where live the project.
13
+ def initialize working_dir
14
+ @working_dir = working_dir
15
+ end
16
+
17
+ # Public: Render css in the styles directory.
18
+ #
19
+ # Returns nothing.
20
+ def render
21
+ Dir.glob(File.join(@working_dir, STYLES_DIR, '**/*')) do |filename|
22
+ @filename = filename
23
+ if @filename.end_with?(".sass")
24
+ render_sass :sass
25
+ elsif @filename.end_with?(".scss")
26
+ render_sass :scss
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ # Render css from sass in the styles directory.
34
+ #
35
+ # type - A Symbol for the sass syntax, either :sass or :scss.
36
+ #
37
+ # Returns nothing.
38
+ def render_sass type
39
+ template = File.open(@filename).read
40
+ begin
41
+ css = Sass::Engine.new(template, syntax: type).render
42
+ rescue Exception => ex
43
+ error "In #{@filename}\n #{ex}"
44
+ end
45
+ @filename.gsub!(/(sass|scss)$/, 'css')
46
+ File.open(@filename, "w") {|out| out.puts css }
47
+ end
48
+ end
49
+ end
50
+
@@ -12,8 +12,18 @@ module Genit
12
12
  def initialize working_dir, filename
13
13
  @working_dir = working_dir
14
14
  @filename = filename
15
- file = File.join(@working_dir, 'src/templates/main.html')
16
- @template = XmlDocument.open(file)
15
+ # file = File.join(@working_dir, 'src/templates/main.html')
16
+ # @template = XmlDocument.open(file)
17
+ file = File.join(@working_dir, 'src/templates/main')
18
+ if File.exists?("#{file}.html")
19
+ file = file + ".html"
20
+ @template = XmlDocument.open(file)
21
+ elsif File.exists?("#{file}.haml")
22
+ file = file + ".haml"
23
+ @template = XmlDocument.open_via_haml(file)
24
+ else
25
+ error "No template found"
26
+ end
17
27
  end
18
28
 
19
29
  # Public: Compile the page.
@@ -12,9 +12,12 @@ module Genit
12
12
  #
13
13
  # name - The String name of the future project folder.
14
14
  # empty - A Boolean telling if we produce a smoke test or not.
15
- def initialize name, empty
15
+ # haml - A Boolean telling if we want project's files in haml or
16
+ # not.
17
+ def initialize name, empty, haml
16
18
  @project_name = name
17
19
  @empty = empty
20
+ @haml = haml
18
21
  end
19
22
 
20
23
  # Public: Create the structure of the project, that is many
@@ -103,13 +106,30 @@ module Genit
103
106
 
104
107
  # TODO document
105
108
  def copy_index
106
- dest = File.join @project_name, 'src/pages/index.html'
109
+ dest = index_destination
110
+ src = index_source
111
+ FileUtils.cp src, dest
112
+ end
113
+
114
+ def index_destination
115
+ if @haml
116
+ File.join @project_name, 'src/pages/index.haml'
117
+ else
118
+ File.join @project_name, 'src/pages/index.html'
119
+ end
120
+ end
121
+
122
+ def index_source
107
123
  if @empty
108
- src = File.join $GENIT_PATH, 'data/pages/index2.html'
124
+ src = File.join $GENIT_PATH, 'data/pages/index2.'
109
125
  else
110
- src = File.join $GENIT_PATH, 'data/pages/index.html'
126
+ src = File.join $GENIT_PATH, 'data/pages/index.'
127
+ end
128
+ if @haml
129
+ "#{src}haml"
130
+ else
131
+ "#{src}html"
111
132
  end
112
- FileUtils.cp src, dest
113
133
  end
114
134
 
115
135
  # TODO document
@@ -125,14 +145,33 @@ module Genit
125
145
 
126
146
  # TODO document
127
147
  def copy_main_template
148
+ if @haml
149
+ copy_main_template_haml
150
+ else
151
+ copy_main_template_html
152
+ end
153
+ end
154
+
155
+ def copy_main_template_haml
156
+ dest = File.join @project_name, 'src/templates', 'main.haml'
157
+ src = File.join $GENIT_PATH, 'data', 'templates', "html_5.haml"
158
+ FileUtils.cp src, dest
159
+ end
160
+
161
+ def copy_main_template_html
128
162
  dest = File.join @project_name, 'src/templates', 'main.html'
129
163
  copy_first_part dest
130
164
  ProjectCreator.append_last_part dest
131
165
  end
132
166
 
133
167
  def copy_menu_template
134
- dest = File.join @project_name, 'src/templates', 'menu.html'
135
- src = File.join $GENIT_PATH, 'data', 'templates', 'menu.html'
168
+ if @haml
169
+ dest = File.join @project_name, 'src/templates', 'menu.haml'
170
+ src = File.join $GENIT_PATH, 'data', 'templates', 'menu.haml'
171
+ else
172
+ dest = File.join @project_name, 'src/templates', 'menu.html'
173
+ src = File.join $GENIT_PATH, 'data', 'templates', 'menu.html'
174
+ end
136
175
  FileUtils.cp src, dest
137
176
  end
138
177
 
@@ -26,11 +26,20 @@ module Genit
26
26
  private
27
27
 
28
28
  def build_menu
29
- file = File.join(@working_dir, TEMPLATES_DIR, "menu.html")
30
- menu = XmlDocument.open(file)
31
- builder = MenuBuilder.new(menu)
29
+ builder = MenuBuilder.new(menu_document)
32
30
  @menu = builder.build_for_page(@filename)
33
31
  end
32
+
33
+ def menu_document
34
+ file = File.join(@working_dir, TEMPLATES_DIR, "menu.")
35
+ if File.exists?("#{file}html")
36
+ XmlDocument.open("#{file}html")
37
+ elsif File.exists?("#{file}haml")
38
+ XmlDocument.open_via_haml("#{file}haml")
39
+ else
40
+ error "No menu template"
41
+ end
42
+ end
34
43
 
35
44
  end
36
45
 
@@ -4,7 +4,7 @@ module Genit
4
4
 
5
5
  # A Genit general tag.
6
6
  class ClassTag < Tag
7
-
7
+
8
8
  # Public: Constructor.
9
9
  #
10
10
  # working_dir - The String working directory, where live the project.
@@ -14,7 +14,7 @@ module Genit
14
14
  def initialize working_dir, template, filename, tag
15
15
  super working_dir, template, filename, tag
16
16
  end
17
-
17
+
18
18
  # Public: Replace something in the template.
19
19
  #
20
20
  # Returns the template as a Nokogiri::XML::Document
@@ -28,7 +28,7 @@ module Genit
28
28
  error "Unknown tag #{@tag}"
29
29
  end
30
30
  end
31
-
31
+
32
32
  end
33
33
 
34
34
  end
@@ -5,7 +5,7 @@ require './spec/helper'
5
5
  describe Compiler do
6
6
 
7
7
  before :each do
8
- @project = ProjectCreator.new('spec/project-name', false)
8
+ @project = ProjectCreator.new('spec/project-name', false, false)
9
9
  @project.create
10
10
  @compiler = Compiler.new test_project_path
11
11
  end
@@ -20,9 +20,26 @@ describe Compiler do
20
20
  end
21
21
  end
22
22
 
23
- it "should build an index.html page" do
24
- @compiler.compile
25
- File.exist?('spec/project-name/index.html').should be_true
23
+ context "after compilation" do
24
+ before :each do
25
+ @compiler.compile
26
+ end
27
+
28
+ it "should build an index.html page" do
29
+ File.exist?('spec/project-name/index.html').should be_true
30
+ end
31
+
32
+ it "should set the menu in index page" do
33
+ doc = Nokogiri::HTML(File.open("spec/project-name/index.html"))
34
+ doc.at_css("ul#menu a#selected")['href'].should == 'index.html'
35
+ end
36
+
37
+ describe "RSS feed" do
38
+ it "should build the rss.xml file" do
39
+ File.exist?('spec/project-name/rss.xml').should be_true
40
+ end
41
+ end
42
+
26
43
  end
27
44
 
28
45
  it "should build two pages" do
@@ -32,19 +49,13 @@ describe Compiler do
32
49
  File.exist?('spec/project-name/doc.html').should be_true
33
50
  end
34
51
 
35
- it "should set the menu in index page" do
36
- @compiler.compile
37
- doc = Nokogiri::HTML(File.open("spec/project-name/index.html"))
38
- doc.at_css("ul#menu a#selected")['href'].should == 'index.html'
39
- end
40
-
41
52
  context "with no '.genit' file" do
42
53
  it "should exit" do
43
54
  $stdout.should_receive(:puts).with(/Not a genit project folder/i)
44
55
  lambda{Compiler.new File.expand_path('.')}.should raise_error(SystemExit)
45
56
  end
46
57
  end
47
-
58
+
48
59
  context "with no 'config' file" do
49
60
  it "should exit" do
50
61
  $stdout.should_receive(:puts).with(/Missing config file/i)
@@ -52,14 +63,7 @@ describe Compiler do
52
63
  lambda{Compiler.new test_project_path}.should raise_error(SystemExit)
53
64
  end
54
65
  end
55
-
56
- describe "RSS feed" do
57
- it "should build the rss.xml file" do
58
- @compiler.compile
59
- File.exist?('spec/project-name/rss.xml').should be_true
60
- end
61
- end
62
-
66
+
63
67
  describe "Sitemap XML" do
64
68
  it "should build the 'sitemap.xml'" do
65
69
  a_news = %q{<h1>title</h1>}
@@ -71,6 +75,54 @@ describe Compiler do
71
75
  end
72
76
  end
73
77
 
78
+ context "with sass as stylesheet" do
79
+ before :each do
80
+ # remove screen.css
81
+ FileUtils.rm "spec/project-name/styles/screen.css"
82
+ # create screen.sass
83
+ file = %q{
84
+ .content-navigation
85
+ border-color: blue
86
+ }
87
+ File.open('spec/project-name/styles/screen.sass', "w") do |out|
88
+ out.puts file
89
+ end
90
+ @compiler.compile
91
+ end
92
+
93
+ it "should produce css file" do
94
+ File.exists?("spec/project-name/styles/screen.css").should be_true
95
+ end
96
+
97
+ it "should not remove sass file" do
98
+ File.exists?("spec/project-name/styles/screen.sass").should be_true
99
+ end
100
+ end
101
+
102
+ context "with scss as stylesheet" do
103
+ before :each do
104
+ # remove screen.css
105
+ FileUtils.rm "spec/project-name/styles/screen.css"
106
+ # create screen.scss
107
+ file = "
108
+ .content-navigation {
109
+ border-color: blue;
110
+ color: darken(blue, 9%); }"
111
+ File.open('spec/project-name/styles/screen.scss', "w") do |out|
112
+ out.puts file
113
+ end
114
+ @compiler.compile
115
+ end
116
+
117
+ it "should produce css file" do
118
+ File.exists?("spec/project-name/styles/screen.css").should be_true
119
+ end
120
+
121
+ it "should not remove scss file" do
122
+ File.exists?("spec/project-name/styles/screen.scss").should be_true
123
+ end
124
+ end
125
+
74
126
  context "with bad tag syntax" do
75
127
  context "with unknown class into template" do
76
128
  it "should exit" do
@@ -188,7 +240,6 @@ describe Compiler do
188
240
  main = %q{
189
241
  <html>
190
242
  <body>
191
-
192
243
  <genit class="pages"/>
193
244
  <genit here="foo"/>
194
245
  </body>
@@ -5,31 +5,49 @@ require './spec/helper'
5
5
  describe "Standard class String extensions" do
6
6
 
7
7
  it "should replace a markdown file ext" do
8
- string = "file.markdown"
9
- result = string.force_html_extension
10
- result.should == "file.html"
8
+ "file.markdown".force_html_extension.should == "file.html"
9
+ end
10
+
11
+ it "should replace a haml file ext" do
12
+ "file.haml".force_html_extension.should == "file.html"
11
13
  end
12
-
14
+
13
15
  it "should replace a markdown file ext !" do
14
16
  string = "file.markdown"
15
17
  string.force_html_extension!
16
18
  string.should == "file.html"
17
19
  end
18
-
20
+
21
+ it "should replace a haml file ext !" do
22
+ string = "file.haml"
23
+ string.force_html_extension!
24
+ string.should == "file.html"
25
+ end
26
+
19
27
  it "should not replace an other file ext" do
28
+ "file.txt".force_html_extension.should == "file.txt"
29
+ end
30
+
31
+ it "should not replace an other file ext !" do
20
32
  string = "file.txt"
21
33
  string.force_html_extension!
22
34
  string.should == "file.txt"
23
35
  end
24
-
36
+
25
37
  it "should say if it has a markdown file extension" do
26
- string = "file.markdown"
27
- string.markdown_ext?.should be_true
38
+ "file.markdown".markdown_ext?.should be_true
28
39
  end
29
-
40
+
41
+ it "should say if it has a haml file extension" do
42
+ "file.haml".haml_ext?.should be_true
43
+ end
44
+
30
45
  it "should say if it has not a markdown file extension" do
31
- string = "file.other"
32
- string.markdown_ext?.should be_false
46
+ "file.other".markdown_ext?.should be_false
47
+ end
48
+
49
+ it "should say if it has not a haml file extension" do
50
+ "file.other".haml_ext?.should be_false
33
51
  end
34
52
 
35
53
  end
@@ -4,28 +4,28 @@ require './spec/helper'
4
4
 
5
5
  describe Fragment do
6
6
 
7
- # it "should replace one fragment tag" do
8
- # fragment = Fragment.new("spec/test-files/fragment.html", 'spec/test-files')
9
- # fragment.to_html.start_with?('<h1>title</h1>').should be_true
10
- # end
7
+ it "should replace one fragment tag" do
8
+ fragment = Fragment.new("spec/test-files/fragment.html", 'spec/test-files')
9
+ fragment.to_html.start_with?('<h1>title</h1>').should be_true
10
+ end
11
11
 
12
- # it "should replace one fragment tag among other tags" do
13
- # fragment = Fragment.new("spec/test-files/fragment4.html", 'spec/test-files')
14
- # result = fragment.to_html
15
- # result.gsub!("\n", '')
16
- # result.should == '<h1>title</h1><p>para</p><p>footer</p>'
17
- # end
12
+ it "should replace one fragment tag among other tags" do
13
+ fragment = Fragment.new("spec/test-files/fragment4.html", 'spec/test-files')
14
+ result = fragment.to_html
15
+ result.gsub!("\n", '')
16
+ result.should == '<h1>title</h1><p>para</p><p>footer</p>'
17
+ end
18
18
 
19
- # it "should replace one fragment tag in markdown" do
20
- # fragment = Fragment.new("spec/test-files/fragment3.html", 'spec/test-files')
21
- # fragment.to_html.start_with?('<h1>title</h1>').should be_true
22
- # end
19
+ it "should replace one fragment tag in markdown" do
20
+ fragment = Fragment.new("spec/test-files/fragment3.html", 'spec/test-files')
21
+ fragment.to_html.start_with?('<h1>title</h1>').should be_true
22
+ end
23
23
 
24
- # it "should replace some fragment tags" do
25
- # fragment = Fragment.new("spec/test-files/fragment2.html", 'spec/test-files')
26
- # result = fragment.to_html.gsub("\n", '')
27
- # result.should == ("<p>abcde</p>")
28
- # end
24
+ it "should replace some fragment tags" do
25
+ fragment = Fragment.new("spec/test-files/fragment2.html", 'spec/test-files')
26
+ result = fragment.to_html.gsub("\n", '')
27
+ result.should == ("<p>abcde</p>")
28
+ end
29
29
 
30
30
  it "should not change a file without fragment tag" do
31
31
  fragment = Fragment.new("spec/test-files/nothing.html", 'spec/test-files')
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require './spec/helper'
4
+
5
+ describe "Haml expectations" do
6
+
7
+ before :all do
8
+ Haml::Options.defaults[:format] = :xhtml
9
+ end
10
+
11
+ it "should accept and close the genit tag" do
12
+ e = Haml::Engine.new("%genit")
13
+ e.render.should == "<genit></genit>\n"
14
+ end
15
+ end
@@ -27,13 +27,22 @@ describe HtmlDocument do
27
27
  end
28
28
 
29
29
  it "should build a page content from markdown" do
30
- content = HtmlDocument.build_page_content("spec/test-files/test.markdown", 'spec/test-files')
30
+ content = HtmlDocument.build_page_content("spec/test-files/test.markdown",
31
+ 'spec/test-files')
31
32
  content.should == '<h1>title</h1>'
32
33
  end
33
34
 
34
- # it "should build page content from html" do
35
- # content = HtmlDocument.build_page_content("spec/test-files/fragment.html", 'spec/test-files')
36
- # content.start_with?('<h1>title</h1>').should be_true
37
- # end
35
+ it "should build a page content from haml" do
36
+ content = HtmlDocument.build_page_content("spec/test-files/test.haml",
37
+ 'spec/test-files')
38
+ content.should == "<h1>title</h1>\n"
39
+ end
40
+
41
+ it "should build page content from html" do
42
+ content = HtmlDocument.build_page_content(
43
+ "spec/test-files/fragment.html",
44
+ 'spec/test-files')
45
+ content.start_with?('<h1>title</h1>').should be_true
46
+ end
38
47
 
39
48
  end
@@ -5,7 +5,7 @@ require './spec/helper'
5
5
  describe PagesFinder do
6
6
 
7
7
  before :each do
8
- @project = ProjectCreator.new('spec/project-name', false)
8
+ @project = ProjectCreator.new('spec/project-name', false, false)
9
9
  @project.create
10
10
  @finder = PagesFinder.new 'spec/project-name'
11
11
  end
@@ -5,7 +5,7 @@ require './spec/helper'
5
5
  describe ProjectCreator do
6
6
 
7
7
  before :all do
8
- @project = ProjectCreator.new('spec/project-name', false)
8
+ @project = ProjectCreator.new('spec/project-name', false, false)
9
9
  @project.create
10
10
  end
11
11
 
@@ -26,7 +26,7 @@ describe ProjectCreator do
26
26
  end
27
27
 
28
28
  it "should say it if it cannot create a project" do
29
- project = ProjectCreator.new('/root/project', false)
29
+ project = ProjectCreator.new('/root/project', false, false)
30
30
  $stdout.should_receive(:puts).with("Cannot create project...")
31
31
  project.create
32
32
  end
@@ -0,0 +1,11 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require './spec/helper'
4
+
5
+ describe "sass expectations" do
6
+
7
+ it "should keep the render API" do
8
+ e = Sass::Engine.new ""
9
+ e.should respond_to :render
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ <p>footer</p>
@@ -0,0 +1 @@
1
+ <h1>title</h1>
@@ -0,0 +1,2 @@
1
+ title
2
+ ======
@@ -0,0 +1 @@
1
+ %h1 title
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genit
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -59,6 +59,38 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.2.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: haml
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 4.0.1
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 4.0.1
78
+ - !ruby/object:Gem::Dependency
79
+ name: sass
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 3.2.7
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 3.2.7
62
94
  description: ! "Genit builds a **static web site**, that is a web site without server
63
95
  side \nprograming language and database. The site consists only of xhtml code (+
64
96
  css and medias) and \neventually of javascript. It is a command line framework,
@@ -73,6 +105,7 @@ extra_rdoc_files: []
73
105
  files:
74
106
  - lib/genit/project/pages_finder.rb
75
107
  - lib/genit/project/rss_feed.rb
108
+ - lib/genit/project/css.rb
76
109
  - lib/genit/project/project_creator.rb
77
110
  - lib/genit/project/page_compiler.rb
78
111
  - lib/genit/project/root_cleaner.rb
@@ -113,11 +146,15 @@ files:
113
146
  - lib/genit.rb
114
147
  - bin/genit
115
148
  - data/templates/html_5
149
+ - data/templates/menu.haml
150
+ - data/templates/html_5.haml
116
151
  - data/templates/menu.html
117
152
  - data/templates/main.html
118
153
  - data/styles/handheld.css
119
154
  - data/styles/print.css
120
155
  - data/styles/screen.css
156
+ - data/pages/index.haml
157
+ - data/pages/index2.haml
121
158
  - data/pages/index.html
122
159
  - data/pages/index2.html
123
160
  - spec/file_writer_spec.rb
@@ -126,6 +163,7 @@ files:
126
163
  - spec/builder_spec.rb
127
164
  - spec/fragment_spec.rb
128
165
  - spec/menu_builder_spec.rb
166
+ - spec/haml_spec.rb
129
167
  - spec/helper.rb
130
168
  - spec/html_document_spec.rb
131
169
  - spec/builder_base_spec.rb
@@ -138,9 +176,15 @@ files:
138
176
  - spec/test-files/malformed.html
139
177
  - spec/test-files/fragment4.html
140
178
  - spec/test-files/fragment3.html
179
+ - spec/test-files/test.haml
141
180
  - spec/test-files/test.markdown
142
181
  - spec/test-files/fragment2.html
143
182
  - spec/test-files/fragment.html
183
+ - spec/test-files/src/fragments/footer.html
184
+ - spec/test-files/src/fragments/b.html
185
+ - spec/test-files/src/fragments/title.html
186
+ - spec/test-files/src/fragments/title.markdown
187
+ - spec/test-files/src/fragments/d.html
144
188
  - spec/test-files/fragments/footer.html
145
189
  - spec/test-files/fragments/b.html
146
190
  - spec/test-files/fragments/title.html
@@ -152,6 +196,7 @@ files:
152
196
  - spec/class_tag_spec.rb
153
197
  - spec/pages_finder_spec.rb
154
198
  - spec/xml_document_spec.rb
199
+ - spec/sass_spec.rb
155
200
  - VERSION
156
201
  - NEWS
157
202
  - README.markdown