henshin 0.4.2 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/LICENCE +18 -0
  2. data/README.md +133 -0
  3. data/Rakefile +6 -51
  4. data/bin/henshin +127 -134
  5. data/lib/henshin.rb +163 -38
  6. data/lib/henshin/compressor.rb +31 -0
  7. data/lib/henshin/compressors/css.rb +20 -0
  8. data/lib/henshin/compressors/js.rb +20 -0
  9. data/lib/henshin/core_ext.rb +69 -0
  10. data/lib/henshin/error.rb +28 -0
  11. data/lib/henshin/file.rb +67 -0
  12. data/lib/henshin/files/abstract.rb +102 -0
  13. data/lib/henshin/files/attributes.rb +31 -0
  14. data/lib/henshin/files/empty_template.rb +24 -0
  15. data/lib/henshin/files/physical.rb +117 -0
  16. data/lib/henshin/files/post.rb +64 -0
  17. data/lib/henshin/files/templatable.rb +29 -0
  18. data/lib/henshin/files/template.rb +45 -0
  19. data/lib/henshin/files/tilt.rb +50 -0
  20. data/lib/henshin/files/tilt_template.rb +45 -0
  21. data/lib/henshin/package.rb +27 -0
  22. data/lib/henshin/packages/script.rb +23 -0
  23. data/lib/henshin/packages/style.rb +20 -0
  24. data/lib/henshin/path.rb +143 -0
  25. data/lib/henshin/publisher.rb +42 -0
  26. data/lib/henshin/publishers/sftp.rb +79 -0
  27. data/lib/henshin/reader.rb +68 -0
  28. data/lib/henshin/safety.rb +74 -0
  29. data/lib/henshin/scope.rb +55 -0
  30. data/lib/henshin/site.rb +291 -228
  31. data/lib/henshin/ui.rb +35 -0
  32. data/lib/henshin/version.rb +3 -0
  33. data/lib/henshin/writer.rb +43 -0
  34. data/lib/rack/henshin.rb +113 -0
  35. data/site/assets/scripts/config.js +11 -0
  36. data/site/assets/styles/_mixins.sass +16 -0
  37. data/site/assets/styles/screen.sass +198 -0
  38. data/site/config.yml +13 -0
  39. data/site/drafts/a-work-in-progress.md +5 -0
  40. data/site/feed.xml.slim +19 -0
  41. data/site/index.html.slim +28 -0
  42. data/site/init.rb +33 -0
  43. data/site/posts/1-hello-world.md +46 -0
  44. data/site/posts/2-code-testing.md +36 -0
  45. data/site/posts/3-style-test.md +80 -0
  46. data/site/templates/default.slim +11 -0
  47. data/site/templates/post.slim +30 -0
  48. data/site/test.html.md +7 -0
  49. data/spec/helper.rb +70 -0
  50. data/spec/henshin/compressor_spec.rb +25 -0
  51. data/spec/henshin/compressors/css_spec.rb +22 -0
  52. data/spec/henshin/compressors/js_spec.rb +22 -0
  53. data/spec/henshin/core_ext_spec.rb +59 -0
  54. data/spec/henshin/error_spec.rb +22 -0
  55. data/spec/henshin/file_spec.rb +28 -0
  56. data/spec/henshin/files/abstract_spec.rb +98 -0
  57. data/spec/henshin/files/attributes_spec.rb +25 -0
  58. data/spec/henshin/files/empty_template_spec.rb +11 -0
  59. data/spec/henshin/files/physical_spec.rb +55 -0
  60. data/spec/henshin/files/post_spec.rb +66 -0
  61. data/spec/henshin/files/template_spec.rb +53 -0
  62. data/spec/henshin/files/tilt_spec.rb +59 -0
  63. data/spec/henshin/package_spec.rb +24 -0
  64. data/spec/henshin/packages/script_spec.rb +17 -0
  65. data/spec/henshin/packages/style_spec.rb +17 -0
  66. data/spec/henshin/path_spec.rb +56 -0
  67. data/spec/henshin/publisher_spec.rb +44 -0
  68. data/spec/henshin/publishers/sftp_spec.rb +21 -0
  69. data/spec/henshin/reader_spec.rb +55 -0
  70. data/spec/henshin/safety_spec.rb +66 -0
  71. data/spec/henshin/scope_spec.rb +33 -0
  72. data/spec/henshin/site_spec.rb +142 -0
  73. data/spec/henshin/ui_spec.rb +26 -0
  74. data/spec/henshin/writer_spec.rb +26 -0
  75. metadata +352 -197
  76. data/.gitignore +0 -27
  77. data/LICENSE +0 -20
  78. data/README.markdown +0 -35
  79. data/VERSION +0 -1
  80. data/henshin.gemspec +0 -121
  81. data/lib/henshin/archive.rb +0 -133
  82. data/lib/henshin/exec/files.rb +0 -46
  83. data/lib/henshin/ext.rb +0 -55
  84. data/lib/henshin/gen.rb +0 -154
  85. data/lib/henshin/labels.rb +0 -144
  86. data/lib/henshin/plugin.rb +0 -100
  87. data/lib/henshin/plugins/highlight.rb +0 -24
  88. data/lib/henshin/plugins/liquid.rb +0 -61
  89. data/lib/henshin/plugins/maruku.rb +0 -18
  90. data/lib/henshin/plugins/sass.rb +0 -24
  91. data/lib/henshin/plugins/textile.rb +0 -18
  92. data/lib/henshin/post.rb +0 -156
  93. data/lib/henshin/static.rb +0 -33
  94. data/test/helper.rb +0 -44
  95. data/test/site/css/_reset.sass +0 -34
  96. data/test/site/css/print.css +0 -12
  97. data/test/site/css/screen.sass +0 -70
  98. data/test/site/includes/head.html +0 -1
  99. data/test/site/index.html +0 -23
  100. data/test/site/layouts/archive_date.html +0 -20
  101. data/test/site/layouts/archive_month.html +0 -24
  102. data/test/site/layouts/archive_year.html +0 -26
  103. data/test/site/layouts/category_index.html +0 -27
  104. data/test/site/layouts/category_page.html +0 -20
  105. data/test/site/layouts/main.html +0 -13
  106. data/test/site/layouts/post.html +0 -36
  107. data/test/site/layouts/tag_index.html +0 -27
  108. data/test/site/layouts/tag_page.html +0 -20
  109. data/test/site/options.yaml +0 -17
  110. data/test/site/plugins/test.rb +0 -3
  111. data/test/site/posts/Testing-Stuff.markdown +0 -14
  112. data/test/site/posts/Textile-Test.textile +0 -7
  113. data/test/site/posts/cat/test.markdown +0 -6
  114. data/test/site/posts/lorem-ipsum.markdown +0 -7
  115. data/test/site/posts/same-date.markdown +0 -7
  116. data/test/site/static.html +0 -19
  117. data/test/suite.rb +0 -4
  118. data/test/test_gen.rb +0 -98
  119. data/test/test_options.rb +0 -73
  120. data/test/test_post.rb +0 -67
  121. data/test/test_site.rb +0 -197
  122. data/test/test_static.rb +0 -13
data/.gitignore DELETED
@@ -1,27 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
- .yardoc
21
-
22
- ## PROJECT::SPECIFIC
23
- _site/
24
- .sass-cache/
25
- docs-github/
26
- hmm/
27
- doc/
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 Joshua Hawxwell
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,35 +0,0 @@
1
- # Henshin
2
-
3
- Henshin is a static site generator. It takes in posts, or just pages, runs them through plugins and layouts and gives you a folder to put on a webserver. It makes it easy to write archive pages, tags and categories.
4
-
5
-
6
- ## How To
7
-
8
- Install with
9
-
10
- (sudo) gem install henshin
11
-
12
- Then create a new site
13
-
14
- cd [some directory]
15
- henshin create
16
-
17
- And build your new site with
18
-
19
- henshin
20
-
21
-
22
- ## Note on Patches/Pull Requests
23
-
24
- - Fork the project
25
- - Make your feature addition or bug fix
26
- - Add tests for it. This is important so I don't break it in a
27
- future version unintentionally.
28
- - Commit, do not mess with rakefile, version, or history.
29
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
30
- - Send me a pull request. Bonus points for topic branches.
31
-
32
-
33
- ## License
34
-
35
- Copyright (c) 2010 Joshua Hawxwell. See LICENSE for details.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.4.2
@@ -1,121 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{henshin}
8
- s.version = "0.4.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["hawx"]
12
- s.date = %q{2010-07-17}
13
- s.default_executable = %q{henshin}
14
- s.description = %q{Henshin is a static site generator, with a plugin system and more}
15
- s.email = %q{m@hawx.me}
16
- s.executables = ["henshin"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.markdown"
20
- ]
21
- s.files = [
22
- ".gitignore",
23
- "LICENSE",
24
- "README.markdown",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/henshin",
28
- "henshin.gemspec",
29
- "lib/henshin.rb",
30
- "lib/henshin/archive.rb",
31
- "lib/henshin/exec/files.rb",
32
- "lib/henshin/ext.rb",
33
- "lib/henshin/gen.rb",
34
- "lib/henshin/labels.rb",
35
- "lib/henshin/plugin.rb",
36
- "lib/henshin/plugins/highlight.rb",
37
- "lib/henshin/plugins/liquid.rb",
38
- "lib/henshin/plugins/maruku.rb",
39
- "lib/henshin/plugins/sass.rb",
40
- "lib/henshin/plugins/textile.rb",
41
- "lib/henshin/post.rb",
42
- "lib/henshin/site.rb",
43
- "lib/henshin/static.rb",
44
- "test/helper.rb",
45
- "test/site/css/_reset.sass",
46
- "test/site/css/print.css",
47
- "test/site/css/screen.sass",
48
- "test/site/includes/head.html",
49
- "test/site/index.html",
50
- "test/site/layouts/archive_date.html",
51
- "test/site/layouts/archive_month.html",
52
- "test/site/layouts/archive_year.html",
53
- "test/site/layouts/category_index.html",
54
- "test/site/layouts/category_page.html",
55
- "test/site/layouts/main.html",
56
- "test/site/layouts/post.html",
57
- "test/site/layouts/tag_index.html",
58
- "test/site/layouts/tag_page.html",
59
- "test/site/options.yaml",
60
- "test/site/plugins/test.rb",
61
- "test/site/posts/Testing-Stuff.markdown",
62
- "test/site/posts/Textile-Test.textile",
63
- "test/site/posts/cat/test.markdown",
64
- "test/site/posts/lorem-ipsum.markdown",
65
- "test/site/posts/same-date.markdown",
66
- "test/site/static.html",
67
- "test/suite.rb",
68
- "test/test_gen.rb",
69
- "test/test_options.rb",
70
- "test/test_post.rb",
71
- "test/test_site.rb",
72
- "test/test_static.rb"
73
- ]
74
- s.homepage = %q{http://github.com/hawx/henshin}
75
- s.rdoc_options = ["--charset=UTF-8"]
76
- s.require_paths = ["lib"]
77
- s.rubygems_version = %q{1.3.7}
78
- s.summary = %q{Henshin is a static site generator}
79
- s.test_files = [
80
- "test/helper.rb",
81
- "test/site/plugins/test.rb",
82
- "test/suite.rb",
83
- "test/test_gen.rb",
84
- "test/test_options.rb",
85
- "test/test_post.rb",
86
- "test/test_site.rb",
87
- "test/test_static.rb"
88
- ]
89
-
90
- if s.respond_to? :specification_version then
91
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
92
- s.specification_version = 3
93
-
94
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
95
- s.add_runtime_dependency(%q<titlecase>, [">= 0.1.0"])
96
- s.add_runtime_dependency(%q<directory_watcher>, [">= 1.3.1"])
97
- s.add_runtime_dependency(%q<maruku>, [">= 0.6.0"])
98
- s.add_runtime_dependency(%q<liquid>, [">= 2.0.0"])
99
- s.add_runtime_dependency(%q<parsey>, [">= 0.1.3"])
100
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
101
- s.add_development_dependency(%q<yard>, [">= 0"])
102
- else
103
- s.add_dependency(%q<titlecase>, [">= 0.1.0"])
104
- s.add_dependency(%q<directory_watcher>, [">= 1.3.1"])
105
- s.add_dependency(%q<maruku>, [">= 0.6.0"])
106
- s.add_dependency(%q<liquid>, [">= 2.0.0"])
107
- s.add_dependency(%q<parsey>, [">= 0.1.3"])
108
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
109
- s.add_dependency(%q<yard>, [">= 0"])
110
- end
111
- else
112
- s.add_dependency(%q<titlecase>, [">= 0.1.0"])
113
- s.add_dependency(%q<directory_watcher>, [">= 1.3.1"])
114
- s.add_dependency(%q<maruku>, [">= 0.6.0"])
115
- s.add_dependency(%q<liquid>, [">= 2.0.0"])
116
- s.add_dependency(%q<parsey>, [">= 0.1.3"])
117
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
118
- s.add_dependency(%q<yard>, [">= 0"])
119
- end
120
- end
121
-
@@ -1,133 +0,0 @@
1
- module Henshin
2
-
3
- # This should really be a hash which just holds post objects, when #to_hash is
4
- # called, each post object held is turned has Post#to_hash called and this is
5
- # returned. It also controls writing of the archive pages.
6
- #
7
- class Archive < Hash
8
-
9
- attr_accessor :site
10
-
11
- # Create a new instance of Archive
12
- def initialize(site)
13
- @site = site
14
- end
15
-
16
- # Adds the post to the correct year array, month array and day array within the archive
17
- #
18
- # @param [Post] post to be added to the archive
19
- def <<(post)
20
- return nil unless post.data['date']
21
- date = post.data['date']
22
- year, month, day = date.year, date.month, date.day
23
-
24
- self[year] ||= {}
25
- self[year][month] ||= {}
26
- self[year][month][day] ||= []
27
- self[year][month][day] << post
28
- end
29
-
30
- # Converts the archive to a hash suitable for putting in a layout by
31
- # calling #to_hash for all of the posts it contains
32
- #
33
- # @return [Hash]
34
- def to_hash
35
- r = {}
36
- self.each do |y, i|
37
- r[y] = {}
38
- i.each do |m, i|
39
- r[y][m] = {}
40
- i.each do |d, i|
41
- r[y][m][d] = []
42
- i.each do |j|
43
- r[y][m][d] << j.to_hash
44
- end
45
- end
46
- end
47
- end
48
-
49
- r
50
- end
51
-
52
- # Writes the archives if the correct layouts are present
53
- def write
54
- self.write_years if @site.layouts['archive_year']
55
- self.write_months if @site.layouts['archive_month']
56
- self.write_dates if @site.layouts['archive_date']
57
- end
58
-
59
- # This writes all the archives for years
60
- def write_years
61
- self.to_hash.each do |year, v|
62
- # need to fake the file loc so that gen automatically creates permalink
63
- t = @site.root + year.to_s + 'index.html'
64
-
65
- payload = {
66
- :name => 'archive',
67
- :payload => {
68
- 'posts' => self.to_hash,
69
- 'year' => year
70
- }
71
- }
72
- page = Gen.new(t, @site, payload)
73
- page.read
74
- page.data['layout'] = @site.layouts['archive_year']
75
-
76
- page.render
77
- page.write
78
- end
79
- end
80
-
81
- # Writes all of the archives for the months
82
- def write_months
83
- self.to_hash.each do |year, v|
84
- v.each do |month, v|
85
- t = @site.root + year.to_s + month.to_s + 'index.html'
86
-
87
- payload = {
88
- :name => 'archive',
89
- :payload => {
90
- 'posts' => self.to_hash,
91
- 'year' => year,
92
- 'month' => month
93
- }
94
- }
95
- page = Gen.new(t, @site, payload)
96
- page.read
97
- page.data['layout'] = @site.layouts['archive_month']
98
-
99
- page.render
100
- page.write
101
- end
102
- end
103
- end
104
-
105
- # Writes all of the archives for the days
106
- def write_dates
107
- self.to_hash.each do |year, v|
108
- v.each do |month, v|
109
- v.each do |date, v|
110
- t = @site.root + year.to_s + month.to_s + date.to_s + 'index.html'
111
-
112
- payload = {
113
- :name => 'archive',
114
- :payload => {
115
- 'posts' => self.to_hash,
116
- 'year' => year,
117
- 'month' => month,
118
- 'day' => date
119
- }
120
- }
121
- page = Gen.new(t, @site, payload)
122
- page.read
123
- page.data['layout'] = @site.layouts['archive_date']
124
-
125
- page.render
126
- page.write
127
- end
128
- end
129
- end
130
- end
131
-
132
- end
133
- end
@@ -1,46 +0,0 @@
1
- opt_content = <<EOS
2
- title: Test Site
3
- author: John Doe
4
- layout: main
5
- EOS
6
-
7
- index_content = <<EOS
8
- ---
9
- title: The Home Page
10
- ---
11
-
12
- Well you might want to change this!
13
- EOS
14
-
15
- layout_content = <<EOS
16
- <!DOCTYPE html>
17
- <html lang="en">
18
- <head>
19
- <meta charset="utf-8" />
20
- <title>{{ site.title }}</title>
21
- </head>
22
- <body>
23
-
24
- {{ yield }}
25
-
26
- <h4>A List of Posts</h4>
27
- <ul>
28
- {% for post in site.posts %}
29
- <li><a href="{{ post.url }}">{{ post.title }}</a> - {{ post.date }}</li>
30
- {% endfor %}
31
- </ul>
32
-
33
- <span>Copyright &copy; {{ site.author }}</span>
34
- </body>
35
- </html>
36
- EOS
37
-
38
- post_content = <<EOS
39
- ---
40
- title: Hello World
41
- date: #{Time.now.strftime("%Y-%m-%d at %H:%M:%S")}
42
- tags: test, hello
43
- ---
44
-
45
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
46
- EOS
@@ -1,55 +0,0 @@
1
- class String
2
-
3
- # Turns the string to a slug
4
- #
5
- # @return [String] the created slug
6
- def slugify
7
- slug = self.clone
8
- slug.gsub!(/[']+/, '')
9
- slug.gsub!(/\W+/, ' ')
10
- slug.strip!
11
- slug.downcase!
12
- slug.gsub!(' ', '-')
13
- slug
14
- end
15
-
16
- # Converts the String to a Pathname object
17
- #
18
- # @return [Pathname]
19
- def to_p
20
- Pathname.new(self)
21
- end
22
-
23
- # Checks whether it is a valid number in a string, or not
24
- # @see http://www.railsforum.com/viewtopic.php?id=19081
25
- def numeric?
26
- true if Float(self) rescue false
27
- end
28
-
29
- end
30
-
31
- class Hash
32
-
33
- # Converts string hash keys to symbol keys
34
- #
35
- # @see http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html
36
- # stolen from rails
37
- def to_options
38
- inject({}) do |options, (key, value)|
39
- options[(key.to_sym rescue key) || key] = value
40
- options
41
- end
42
- end
43
-
44
- end
45
-
46
- class Pathname
47
-
48
- # Gets just the extension of the pathname
49
- #
50
- # @return [String] the extension of the path, without the '.'
51
- def extension
52
- self.extname[1..-1]
53
- end
54
-
55
- end