awestruct 0.2.18 → 0.4.2.x1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/bin/awestruct +2 -274
  2. data/lib/awestruct/astruct.rb +22 -0
  3. data/lib/awestruct/astruct_mixin.rb +81 -0
  4. data/lib/awestruct/cli/auto.rb +34 -0
  5. data/lib/awestruct/cli/deploy.rb +38 -0
  6. data/lib/awestruct/{commands → cli}/generate.rb +3 -3
  7. data/lib/awestruct/cli/invoker.rb +120 -0
  8. data/lib/awestruct/cli/options.rb +116 -0
  9. data/lib/awestruct/{commands → cli}/server.rb +1 -1
  10. data/lib/awestruct/config.rb +20 -8
  11. data/lib/awestruct/context.rb +22 -0
  12. data/lib/awestruct/dependencies.rb +102 -0
  13. data/lib/awestruct/deploy/github_pages_deploy.rb +61 -0
  14. data/lib/awestruct/{commands/deploy.rb → deploy/rsync_deploy.rb} +10 -6
  15. data/lib/awestruct/deployers.rb +15 -0
  16. data/lib/awestruct/engine.rb +172 -411
  17. data/lib/awestruct/extensions/atomizer.rb +7 -4
  18. data/lib/awestruct/extensions/coffeescripttransform.rb +42 -0
  19. data/lib/awestruct/extensions/minify.rb +21 -23
  20. data/lib/awestruct/extensions/paginator.rb +6 -4
  21. data/lib/awestruct/extensions/partial.rb +0 -1
  22. data/lib/awestruct/extensions/pipeline.rb +5 -0
  23. data/lib/awestruct/extensions/posts.rb +11 -9
  24. data/lib/awestruct/extensions/sitemap.rb +2 -1
  25. data/lib/awestruct/extensions/tagger.rb +0 -2
  26. data/lib/awestruct/extensions/template.atom.haml +4 -3
  27. data/lib/awestruct/handler_chain.rb +28 -0
  28. data/lib/awestruct/handler_chains.rb +48 -0
  29. data/lib/awestruct/handlers/asciidoc_handler.rb +57 -0
  30. data/lib/awestruct/handlers/base_handler.rb +111 -0
  31. data/lib/awestruct/handlers/base_sass_handler.rb +42 -0
  32. data/lib/awestruct/handlers/coffeescript_handler.rb +48 -0
  33. data/lib/awestruct/handlers/erb_handler.rb +44 -0
  34. data/lib/awestruct/handlers/file_handler.rb +64 -0
  35. data/lib/awestruct/handlers/front_matter_handler.rb +85 -0
  36. data/lib/awestruct/handlers/haml_handler.rb +54 -0
  37. data/lib/awestruct/handlers/interpolation_handler.rb +28 -0
  38. data/lib/awestruct/handlers/layout_handler.rb +63 -0
  39. data/lib/awestruct/handlers/markdown_handler.rb +50 -0
  40. data/lib/awestruct/handlers/no_op_handler.rb +34 -0
  41. data/lib/awestruct/handlers/orgmode_handler.rb +48 -0
  42. data/lib/awestruct/handlers/page_delegating_handler.rb +54 -0
  43. data/lib/awestruct/handlers/restructuredtext_handler.rb +67 -0
  44. data/lib/awestruct/handlers/sass_handler.rb +21 -0
  45. data/lib/awestruct/handlers/scss_handler.rb +21 -0
  46. data/lib/awestruct/handlers/string_handler.rb +29 -0
  47. data/lib/awestruct/handlers/textile_handler.rb +58 -0
  48. data/lib/awestruct/handlers/yaml_handler.rb +25 -0
  49. data/lib/awestruct/layouts.rb +16 -0
  50. data/lib/awestruct/page.rb +141 -0
  51. data/lib/awestruct/page_loader.rb +82 -0
  52. data/lib/awestruct/pipeline.rb +56 -0
  53. data/lib/awestruct/site.rb +29 -35
  54. data/lib/awestruct/version.rb +1 -1
  55. data/lib/guard/awestruct.rb +38 -0
  56. metadata +115 -88
  57. data/lib/awestruct.rb +0 -2
  58. data/lib/awestruct/asciidoc_file.rb +0 -24
  59. data/lib/awestruct/asciidocable.rb +0 -35
  60. data/lib/awestruct/commands/frameworks/960/base_layout.html.haml +0 -10
  61. data/lib/awestruct/commands/frameworks/base_index.html.haml +0 -5
  62. data/lib/awestruct/commands/frameworks/base_pipeline.rb +0 -6
  63. data/lib/awestruct/commands/frameworks/blueprint/base_layout.html.haml +0 -12
  64. data/lib/awestruct/commands/frameworks/bootstrap/base_index.html.haml +0 -27
  65. data/lib/awestruct/commands/frameworks/bootstrap/base_layout.html.haml +0 -29
  66. data/lib/awestruct/commands/git_hub_pages.rb +0 -55
  67. data/lib/awestruct/commands/init.rb +0 -40
  68. data/lib/awestruct/commands/manifest.rb +0 -205
  69. data/lib/awestruct/erb_file.rb +0 -24
  70. data/lib/awestruct/erbable.rb +0 -19
  71. data/lib/awestruct/front_matter_file.rb +0 -54
  72. data/lib/awestruct/haml/filters/asciidoc.rb +0 -8
  73. data/lib/awestruct/haml_file.rb +0 -27
  74. data/lib/awestruct/hamlable.rb +0 -19
  75. data/lib/awestruct/markdown_file.rb +0 -23
  76. data/lib/awestruct/markdownable.rb +0 -18
  77. data/lib/awestruct/orgmode_file.rb +0 -23
  78. data/lib/awestruct/orgmodeable.rb +0 -15
  79. data/lib/awestruct/renderable.rb +0 -18
  80. data/lib/awestruct/renderable_file.rb +0 -39
  81. data/lib/awestruct/restructuredtext_file.rb +0 -23
  82. data/lib/awestruct/restructuredtextable.rb +0 -38
  83. data/lib/awestruct/sass_file.rb +0 -24
  84. data/lib/awestruct/sassable.rb +0 -33
  85. data/lib/awestruct/scss_file.rb +0 -24
  86. data/lib/awestruct/textilable.rb +0 -22
  87. data/lib/awestruct/textile_file.rb +0 -23
  88. data/lib/awestruct/verbatim_file.rb +0 -12
data/lib/awestruct.rb DELETED
@@ -1,2 +0,0 @@
1
-
2
- require 'awestruct/engine'
@@ -1,24 +0,0 @@
1
- require 'open3'
2
- require 'pathname'
3
- require 'awestruct/front_matter_file'
4
- require 'awestruct/asciidocable'
5
-
6
- module Awestruct
7
- class AsciiDocFile < FrontMatterFile
8
-
9
- include AsciiDocable
10
-
11
- def initialize(site, source_path, relative_source_path, options = {})
12
- super(site, source_path, relative_source_path, options)
13
- end
14
-
15
- def output_filename
16
- File.basename(self.source_path.gsub(/\.(asciidoc|adoc)$/, output_extension))
17
- end
18
-
19
- def output_extension
20
- '.html'
21
- end
22
-
23
- end
24
- end
@@ -1,35 +0,0 @@
1
- module Awestruct
2
- module AsciiDocable
3
-
4
- def render(context)
5
- _render(context.interpolate_string(raw_page_content), context.page.relative_source_path, site)
6
- end
7
-
8
- def content
9
- context = site.engine.create_context( self )
10
- render( context )
11
- end
12
-
13
- def _render(content, relative_source_path, site)
14
- # TODO replace with site.engine.config.images_dir once available
15
- imagesdir = Pathname.new('/images').relative_path_from(Pathname.new(File.dirname(relative_source_path)))
16
- iconsdir = File.join(imagesdir, 'icons')
17
- conffile = File.join(site.engine.config.config_dir, 'asciidoc.conf')
18
- confopt = File.exist?(conffile) ? '-f ' + conffile : ''
19
- execute("asciidoc -s -b html5 -a pygments -a icons -a iconsdir='#{iconsdir}' -a imagesdir='#{imagesdir}' #{confopt} -o - -", content)
20
- end
21
-
22
- def execute(command, target)
23
- out = ''
24
- Open3.popen3(command) do |stdin, stdout, _|
25
- stdin.puts target
26
- stdin.close
27
- out = stdout.read
28
- end
29
- out.gsub("\r", '')
30
- rescue Errno::EPIPE
31
- ""
32
- end
33
-
34
- end
35
- end
@@ -1,10 +0,0 @@
1
- !!!
2
- %html
3
- %head
4
- %title
5
- An awesome site
6
- %link{ :rel=>'stylesheet', :type=>'text/css', :href=>'/stylesheets/grid.css', :media=>'screen, projection' }
7
- %link{ :rel=>'stylesheet', :type=>'text/css', :href=>'/stylesheets/text.css', :media=>'print' }
8
- %body.ninesixty
9
- #container
10
- ~ content
@@ -1,5 +0,0 @@
1
- ---
2
- layout: base
3
- ---
4
-
5
- %h1 You're awestruct.
@@ -1,6 +0,0 @@
1
-
2
- Awestruct::Extensions::Pipeline.new do
3
- # extension Awestruct::Extensions::Posts.new( '/news' )
4
- # extension Awestruct::Extensions::Indexifier.new
5
- end
6
-
@@ -1,12 +0,0 @@
1
- !!!
2
- %html
3
- %head
4
- %title
5
- An awesome site
6
- %link{ :rel=>'stylesheet', :type=>'text/css', :href=>'/stylesheets/screen.css', :media=>'screen, projection' }
7
- %link{ :rel=>'stylesheet', :type=>'text/css', :href=>'/stylesheets/print.css', :media=>'print' }
8
- /[if lt IE 8]
9
- %link{ :rel=>'stylesheet', :type=>'text/css', :href=>'/stylesheets/ie.css', :media=>'screen, projection' }
10
- %body.bp
11
- #container
12
- ~ content
@@ -1,27 +0,0 @@
1
- ---
2
- layout: base
3
- ---
4
- .hero-unit
5
- %h1 You're awestruct!
6
- %p Your site is all setup to use Twitter Bootstrap with Awestruct.
7
- %p
8
- %a.btn.btn-primary.btn-large{ :href=>'http://awestruct.org' }
9
- %i.icon-info-sign.icon-white
10
- Learn more &raquo;
11
- .row
12
- .span4
13
- %h2 About
14
- %p Awestruct is a framework for creating static HTML sites. It's inspired by the awesome Jekyll utility in the same genre.
15
- %p Additionally, Awestruct integrates technologies such as Compass, Markdown and Haml.
16
- %p
17
- %a.btn{ :href=>'http://awestruct.org' } View details &raquo;
18
- .span4
19
- %h2 Goal
20
- %p The goal of Awestruct is to make it trivially easy to bake out non-trivial static websites. In addition to providing template-driven site creation (using Haml), Awestruct provides facilities for easily priming the site creation with additional non-page data.
21
- %p
22
- %a.btn{ :href=>'http://awestruct.org' } View details &raquo;
23
- .span4
24
- %h2 Concept
25
- %p The core concept of Awestruct is that of structures, specifically Ruby OpenStruct structures. The struct aspect allows arbitrary, schema-less data to be associated with a specific page or the entire site.
26
- %p
27
- %a.btn{ :href=>'http://awestruct.org' } View details &raquo;
@@ -1,29 +0,0 @@
1
- !!!5
2
- %html
3
- %head
4
- %meta{ :charset=>'utf-8' }
5
- %title An awesome site
6
- %meta{ :name=>'viewport', :content=>'width=device-width, initial-scale=1.0' }
7
- :css
8
- body {
9
- padding-top: 60px;
10
- }
11
- %link{ :rel=>'stylesheet', :type=>'text/css', :href=>"#{site.base_url}/stylesheets/styles.css" }
12
- /[if lt IE 9]
13
- %script{ :type=>'text/javascript', :src=>'//html5shim.googlecode.com/svn/trunk/html5.js' }
14
- %body
15
- .navbar.navbar-fixed-top
16
- .navbar-inner
17
- .container
18
- %a.brand{ :href=>"#{site.base_url}" } Project Name
19
- %ul.nav
20
- %li
21
- %a{ :href=>"#{site.base_url}" } Home
22
- .container
23
- ~ content
24
- %hr
25
- %footer
26
- %p &copy; Organization #{Date.today.year}
27
- -# Uncomment script tags (remove leading -#) when you're ready to use behaviors
28
- -# %script{ :type=>'text/javascript', :src=>'//cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js' }
29
- -# %script{ :type=>'text/javascript', :src=>"#{site.base_url}/javascripts/bootstrap-collapse.js" }
@@ -1,55 +0,0 @@
1
- require 'git'
2
-
3
- module Awestruct
4
- module Commands
5
-
6
- class GitHubPages
7
- def initialize( site_path )
8
- @site_path = site_path
9
- @git = Git.open(".")
10
- end
11
-
12
- def run
13
- @git.status.changed.empty? ? publish_site : message_for(:existing_changes)
14
- end
15
-
16
- private
17
- def publish_site
18
- current_branch = @git.branch
19
- checkout_pages_branch
20
- add_and_commit_site @site_path
21
- push_and_restore current_branch
22
- end
23
-
24
- def checkout_pages_branch
25
- @git.branch('gh-pages').checkout
26
- end
27
-
28
- def add_and_commit_site( path )
29
- @git.with_working( path ) do
30
- @git.add(".")
31
- begin
32
- @git.commit("Published to gh-pages.")
33
- rescue Git::GitExecuteError => e
34
- $stderr.puts "Can't commit. #{e}."
35
- end
36
- end
37
- end
38
-
39
- def push_and_restore( branch )
40
- @git.reset_hard
41
- @git.push( 'origin', 'gh-pages' )
42
- @git.checkout( branch )
43
- end
44
-
45
- def message_for( key )
46
- $stderr.puts case key
47
- when :existing_changes
48
- "You have uncommitted changes in the working branch. Please commit or stash them."
49
- else
50
- "An error occured."
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,40 +0,0 @@
1
- require 'awestruct'
2
- require 'awestruct/commands/manifest'
3
-
4
- module Awestruct
5
- module Commands
6
- class Init
7
-
8
- BASE_MANIFEST = Manifest.new {
9
- mkdir( '_config' )
10
- mkdir( '_layouts' )
11
- mkdir( '_ext' )
12
- copy_file( '_ext/pipeline.rb', File.join( File.dirname(__FILE__), 'frameworks/base_pipeline.rb' ) )
13
- mkdir( 'stylesheets' )
14
- }
15
-
16
- def initialize(dir=Dir.pwd,framework='compass',scaffold=true)
17
- @dir = dir
18
- @framework = framework
19
- @scaffold = scaffold
20
- end
21
-
22
- def run()
23
- manifest = Manifest.new( BASE_MANIFEST )
24
- manifest.install_compass( @framework )
25
- scaffold_name = ( @framework == 'compass' ? 'blueprint' : @framework )
26
- if ( @scaffold )
27
- manifest.copy_file( '_layouts/base.html.haml', File.join( File.dirname(__FILE__), "/frameworks/#{scaffold_name}/base_layout.html.haml" ) )
28
- if ( File.file? File.join( File.dirname(__FILE__), "/frameworks/#{scaffold_name}/base_index.html.haml" ) )
29
- manifest.copy_file( 'index.html.haml', File.join( File.dirname(__FILE__), "/frameworks/#{scaffold_name}/base_index.html.haml" ) )
30
- else
31
- manifest.copy_file( 'index.html.haml', File.join( File.dirname(__FILE__), "/frameworks/base_index.html.haml" ) )
32
- end
33
- manifest.touch_file( '_config/site.yml' )
34
- end
35
- manifest.perform( @dir )
36
- end
37
-
38
- end
39
- end
40
- end
@@ -1,205 +0,0 @@
1
- require 'compass/logger'
2
- require 'compass/actions'
3
- require 'compass/commands/base'
4
- require 'compass/commands/registry'
5
- require 'compass/commands/create_project'
6
- require 'compass/installers/bare_installer'
7
-
8
- module Compass::AppIntegration::StandAlone
9
- end
10
-
11
- class Compass::AppIntegration::StandAlone::Installer
12
- def write_configuration_files(config_file = nil)
13
- # no!
14
- end
15
- def finalize(opts={})
16
- puts <<-END.gsub(/^ {6}/, '')
17
-
18
- Now you're awestruct!
19
-
20
- To generate your site continuous during development, simply run:
21
-
22
- awestruct -d
23
-
24
- and visit your site at
25
-
26
- http://localhost:4242/
27
-
28
- END
29
- end
30
- end
31
-
32
- module Awestruct
33
- module Commands
34
- class Manifest
35
-
36
- attr_reader :parent
37
- attr_reader :steps
38
-
39
- def initialize(parent=nil,&block)
40
- @parent = parent
41
- @steps = []
42
- instance_eval &block if block
43
- end
44
-
45
- def mkdir(path)
46
- steps << MkDir.new( path )
47
- end
48
-
49
- def copy_file(path, input_path)
50
- steps << CopyFile.new( path, input_path )
51
- end
52
-
53
- def touch_file(path)
54
- steps << TouchFile.new(path)
55
- end
56
-
57
- def install_compass(framework)
58
- steps << InstallCompass.new(framework)
59
- end
60
-
61
- def perform(dir)
62
- parent.perform(dir) if parent
63
- steps.each do |step|
64
- begin
65
- step.perform( dir )
66
- rescue => e
67
- puts e
68
- puts e.backtrace
69
- end
70
- end
71
- end
72
-
73
- def unperform(dir)
74
- steps.each do |step|
75
- begin
76
- step.unperform( dir )
77
- rescue => e
78
- puts e
79
- puts e.backtrace
80
- end
81
- end
82
- end
83
-
84
- ##
85
- ##
86
- ##
87
- ##
88
-
89
- class MkDir
90
- def initialize(path)
91
- @path = path
92
- end
93
-
94
- def perform(dir)
95
- p = File.join( dir, @path )
96
- if ( File.exist?( p ) )
97
- $stderr.puts "Exists: #{p}"
98
- return
99
- end
100
- if ( ! File.directory?( File.dirname( p ) ) )
101
- $stderr.puts "Does not exist: #{File.dirname(p)}"
102
- return
103
- end
104
- $stderr.puts "Create directory: #{p}"
105
- FileUtils.mkdir( p )
106
- end
107
-
108
- def unperform(dir)
109
- p = File.join( dir, @path )
110
- if ( ! File.exist?( p ) )
111
- $stderr.puts "Does not exist: #{p}"
112
- return
113
- end
114
- if ( ! File.directory?( p ) )
115
- $stderr.puts "Not a directory: #{p}"
116
- return
117
- end
118
- if ( Dir.entries( p ) != 2 )
119
- $stderr.puts "Not empty: #{p}"
120
- return
121
- end
122
- $stderr.puts "Remove: #{p}"
123
- FileUtils.rmdir( p )
124
- end
125
- end
126
-
127
- class TouchFile
128
- def initialize(path)
129
- @path = path
130
- end
131
-
132
- def perform(dir)
133
- FileUtils.touch(File.join(dir, @path))
134
- end
135
-
136
- def unperform(dir)
137
- #nothing
138
- end
139
- end
140
-
141
- class CopyFile
142
- def initialize(path, input_path)
143
- @path = path
144
- @input_path = input_path
145
- end
146
-
147
- def perform(dir )
148
- p = File.join( dir, @path )
149
- if ( File.exist?( p ) )
150
- $stderr.puts "Exists: #{p}"
151
- return
152
- end
153
- if ( ! File.directory?( File.dirname( p ) ) )
154
- $stderr.puts "No directory: #{File.dirname( p )}"
155
- return
156
- end
157
- $stderr.puts "Create file: #{p}"
158
- File.open( p, 'w' ){|f| f.write( File.read( @input_path ) ) }
159
- end
160
-
161
- def unperform(dir)
162
- # nothing
163
- end
164
-
165
- def notunperform(dir)
166
- p = File.join( @dir, p )
167
- if ( ! File.exist?( p ) )
168
- $stderr.puts "Does not exist: #{p}"
169
- return
170
- end
171
- $stderr.puts "Remove: #{p}"
172
- FileUtils.rm( p )
173
- end
174
-
175
- end
176
-
177
- class InstallCompass
178
- def initialize(framework='compass')
179
- @framework = framework
180
- end
181
-
182
- def perform(dir)
183
- Compass.configuration.sass_dir = 'stylesheets'
184
- Compass.configuration.css_dir = '_site/stylesheets'
185
- Compass.configuration.images_dir = 'images'
186
-
187
- cmd = Compass::Commands::CreateProject.new( dir, {
188
- :framework=>@framework,
189
- :project_type=>:stand_alone,
190
- :css_dir=>'_site/stylesheets',
191
- :sass_dir=>'stylesheets',
192
- :images_dir=>'images',
193
- :javascripts_dir=>'javascripts',
194
- } )
195
- cmd.perform
196
- end
197
-
198
- def unperform(dir)
199
- # nothing
200
- end
201
- end
202
-
203
- end
204
- end
205
- end