tdreyno-staticmatic 2.0.3 → 2.1.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.
@@ -0,0 +1,74 @@
1
+ class StaticmaticGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ default_options :template => nil
7
+
8
+ attr_reader :name
9
+
10
+ def initialize(runtime_args, runtime_options = {})
11
+ super
12
+ usage if args.empty?
13
+ @destination_root = File.expand_path(args.shift)
14
+ @name = base_name
15
+ extract_options
16
+ end
17
+
18
+ def manifest
19
+ record do |m|
20
+ # Ensure appropriate folder(s) exists
21
+ m.directory ''
22
+
23
+ # Create stubs
24
+ m.file_copy_each ["Rakefile"]
25
+ BASEDIRS.each do |path|
26
+ m.directory path
27
+ m.folder path, path
28
+ end
29
+
30
+ # m.template "template.rb", "some_file_after_erb.rb"
31
+ # m.template_copy_each ["Rakefile"]
32
+ # m.file "file", "some_file_copied"
33
+
34
+ # Rubigen script/generate
35
+ # m.dependency "install_rubigen_scripts", [destination_root, 'staticmatic'],
36
+ # :shebang => options[:shebang], :collision => :force
37
+ end
38
+ end
39
+
40
+ protected
41
+ def banner
42
+ <<-EOS
43
+ Creates a scaffold for building a staticmatic website
44
+ USAGE: #{spec.name} name
45
+
46
+ EOS
47
+ end
48
+
49
+ def add_options!(opts)
50
+ opts.separator ''
51
+ opts.separator 'Options:'
52
+ # For each option below, place the default
53
+ # at the top of the file next to "default_options"
54
+ opts.on("-t", "--template=\"Your Template Directory\"", String,
55
+ "Use a custom template for this project") { |options[:template]| }
56
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
57
+ end
58
+
59
+ def extract_options
60
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
61
+ # Templates can access these value via the attr_reader-generated methods, but not the
62
+ # raw instance variable value.
63
+ @source_root = File.expand_path(options[:template]) if options[:template]
64
+ end
65
+
66
+ # Installation skeleton. Intermediate directories are automatically
67
+ # created so don't sweat their absence here.
68
+ BASEDIRS = %w(
69
+ src/helpers
70
+ src/layouts
71
+ src/pages
72
+ src/stylesheets
73
+ )
74
+ end
data/bin/staticmatic CHANGED
@@ -1,12 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.dirname(__FILE__) + '/../lib/staticmatic'
3
+ require 'rubygems'
4
+ require 'rubigen'
4
5
 
5
- directory = ARGV[0]
6
-
7
- if !directory
8
- puts "Usage: #{$0} <directory>"
9
- exit
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'staticmatic/version'
8
+ puts "#{File.basename($0)} #{Staticmatic::VERSION::STRING}"
9
+ exit(0)
10
10
  end
11
11
 
12
- StaticMatic::Creator.setup(directory)
12
+ require 'rubigen/scripts/generate'
13
+ source = RubiGen::PathSource.new(:application,
14
+ File.join(File.dirname(__FILE__), "../app_generators"))
15
+ RubiGen::Base.reset_sources
16
+ RubiGen::Base.append_sources source
17
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'staticmatic')
@@ -1,6 +1,5 @@
1
1
  module StaticMatic
2
2
  autoload :Builder, 'staticmatic/builder'
3
- autoload :Creator, 'staticmatic/creator'
4
3
  autoload :Config, 'staticmatic/config'
5
4
  autoload :Deprecation, 'staticmatic/deprecation'
6
5
  autoload :Previewer, 'staticmatic/previewer'
@@ -15,4 +14,5 @@ module StaticMatic
15
14
  end
16
15
 
17
16
  require 'staticmatic/actionpack_support/mime'
18
- require 'staticmatic/actionpack_support/remove_partial_benchmark'
17
+ require 'staticmatic/actionpack_support/remove_partial_benchmark'
18
+ require 'staticmatic/actionpack_support/remove_controller_caching'
@@ -65,7 +65,7 @@ module StaticMatic
65
65
  # Clean @layout variable for next request
66
66
  @template.instance_variable_set("@layout", nil)
67
67
 
68
- layout ||= determine_default_layout
68
+ layout ||= "site"
69
69
 
70
70
  render("layouts/#{layout}")
71
71
  end
@@ -117,17 +117,6 @@ module StaticMatic
117
117
  end
118
118
 
119
119
  extension
120
- end
121
-
122
- # Default layout is 'site' but we'll also accept 'application'
123
- def determine_default_layout
124
- layout = "site"
125
-
126
- Dir["#{@src_dir}/layouts/**"].each do |layout_file|
127
- layout = "application" if layout_file.match /application/
128
- end
129
-
130
- layout
131
120
  end
132
121
 
133
122
  # Remove the extension from a given template path
@@ -1,37 +1,11 @@
1
1
  module StaticMatic
2
2
  module Helpers
3
3
  module AssetTagHelper
4
- def stylesheet_link_tag(*sources)
5
- options = sources.extract_options!.stringify_keys
6
- expand_stylesheet_sources(sources).collect do |source|
7
- stylesheet_tag(source, options)
8
- end.join("\n")
9
- end
10
-
11
- def javascript_include_tag(*sources)
12
- options = sources.extract_options!.stringify_keys
13
- expand_javascript_sources(sources).collect do |source|
14
- javascript_src_tag(source, options)
15
- end.join("\n")
16
- end
17
-
18
- def javascript_src_tag(source, options)
19
- content_tag("script", "", { "type" => Mime::JS, "src" => compute_public_path(source, "javascripts", "js") }.merge(options))
20
- end
21
-
22
- def stylesheet_tag(source, options)
23
- tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => compute_public_path(source, "stylesheets", "css") }.merge(options), false, false)
24
- end
25
-
26
4
  def compute_public_path(source, dir, ext = nil, include_host = true)
27
- path = "#{relative_path_to_root}#{dir}/#{source}"
5
+ path = "#{@relative_path_to_root}#{dir}/#{source}"
28
6
  path << ".#{ext}" if ext
29
7
  path
30
8
  end
31
-
32
- def relative_path_to_root
33
- @relative_path_to_root
34
- end
35
9
  end
36
10
  end
37
11
  end
@@ -10,38 +10,29 @@ module StaticMatic
10
10
  end
11
11
 
12
12
  def process(request, response)
13
- @staticmatic.load_helpers
14
- path_info = request.params[Mongrel::Const::PATH_INFO]
13
+ path_info = request.params[Mongrel::Const::PATH_INFO].chomp("/")
15
14
  get_or_head = @@file_only_methods.include? request.params[Mongrel::Const::REQUEST_METHOD]
16
15
 
17
- file_ext = File.extname(path_info).gsub(/^\./, '')
18
- file_ext = "html" if file_ext.blank?
19
-
20
- file_name = path_info.chomp(".#{file_ext}")
21
- file_name = CGI::unescape(file_name)
22
- file_name.gsub!(/^\//, '')
23
-
24
- if file_ext && file_ext.match(/html|css/)
16
+ if get_or_head and @files.can_serve(path_info)
17
+ @files.process(request, response) # try to serve static file from site dir
18
+ elsif @staticmatic.can_render? path_info
25
19
  response.start(200) do |head, out|
20
+ file_ext = File.extname(path_info).gsub(/^\./, '')
21
+ file_ext = "html" if file_ext.blank?
22
+
23
+ file_name = path_info.chomp(".#{file_ext}")
24
+ file_name = CGI::unescape(file_name)
25
+ file_name.gsub!(/^\//, '')
26
+
26
27
  head["Content-Type"] = "text/#{file_ext}"
27
28
  output = ""
28
-
29
- if @staticmatic.can_render? path_info
30
- output = (file_ext == "css") ?
31
- @staticmatic.render(path_info) :
32
- @staticmatic.render_with_layout(file_name)
33
- else
34
- if @files.can_serve(path_info)
35
- @files.process(request,response)
36
- else
37
- output = "File not Found"
38
- end
39
- end
29
+
30
+ @staticmatic.load_helpers
31
+ output = (file_ext == "css") ?
32
+ @staticmatic.render(path_info) :
33
+ @staticmatic.render_with_layout(file_name)
40
34
  out.write output
41
35
  end
42
- else
43
- # try to serve static file from site dir
44
- @files.process(request,response) if @files.can_serve(path_info)
45
36
  end
46
37
  end
47
38
 
@@ -51,9 +42,10 @@ module StaticMatic
51
42
  staticmatic = StaticMatic::Base.new(staticmatic) if staticmatic.is_a? String
52
43
 
53
44
  config = Mongrel::Configurator.new :host => StaticMatic::Config[:host] do
54
- puts "Running Preview of #{staticmatic.root_dir} on port #{StaticMatic::Config[:post]}"
45
+ puts "Running Preview of #{staticmatic.root_dir} on port #{StaticMatic::Config[:port]}"
55
46
  listener :port => StaticMatic::Config[:port] do
56
47
  uri "/", :handler => Previewer.new(staticmatic)
48
+ uri "/favicon", :handler => Mongrel::Error404Handler.new("")
57
49
  end
58
50
  trap("INT") { stop }
59
51
  run
data/lib/staticmatic.rb CHANGED
@@ -10,7 +10,7 @@ require 'staticmatic/autoload'
10
10
  require 'staticmatic/base'
11
11
 
12
12
  # Load template handlers
13
- Dir['lib/staticmatic/template_handlers/*.rb'].each do |handler|
13
+ Dir[File.dirname(__FILE__) + '/staticmatic/template_handlers/*.rb'].each do |handler|
14
14
  begin
15
15
  require "staticmatic/template_handlers/#{File.basename(handler)}"
16
16
  rescue
@@ -20,9 +20,8 @@ end
20
20
 
21
21
  ActionView::Base.class_eval do
22
22
  include StaticMatic::Helpers::AssetTagHelper
23
- include StaticMatic::Helpers::DeprecatedHelpers
24
23
  include StaticMatic::Helpers::PageHelper
25
24
  include StaticMatic::Helpers::UrlHelper
26
- include Mime
27
25
  include StaticMatic::Deprecation
26
+ include Mime
28
27
  end
data/staticmatic.gemspec CHANGED
@@ -1,53 +1,52 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = "staticmatic"
3
- s.version = "2.0.3"
4
- s.date = "2008-07-31"
5
- s.authors = ["Stephen Bartholomew", "Thomas Reynolds"]
6
- s.email = "steve@curve21.com"
7
- s.homepage = "http://github.com/tdreyno/staticmatic"
8
- s.summary = "Static sites, the Rails Way"
9
- s.files = ["LICENSE",
10
- "Rakefile",
11
- "staticmatic.gemspec",
12
- "bin/staticmatic",
13
- "lib/staticmatic.rb",
14
- "lib/staticmatic/autoload.rb",
15
- "lib/staticmatic/base.rb",
16
- "lib/staticmatic/builder.rb",
17
- "lib/staticmatic/config.rb",
18
- "lib/staticmatic/creator.rb",
19
- "lib/staticmatic/deprecation.rb",
20
- "lib/staticmatic/previewer.rb",
21
- "lib/staticmatic/rescue.rb",
22
- "lib/staticmatic/actionpack_support/mime.rb",
23
- "lib/staticmatic/actionpack_support/remove_partial_benchmark.rb",
24
- "lib/staticmatic/helpers/asset_tag_helper.rb",
25
- "lib/staticmatic/helpers/deprecated_helpers.rb",
26
- "lib/staticmatic/helpers/page_helper.rb",
27
- "lib/staticmatic/helpers/url_helper.rb",
28
- "lib/staticmatic/template_handlers/haml.rb",
29
- "lib/staticmatic/template_handlers/liquid.rb",
30
- "lib/staticmatic/template_handlers/markdown.rb",
31
- "lib/staticmatic/template_handlers/sass.rb",
32
- "lib/staticmatic/template_handlers/textile.rb",
33
- "lib/staticmatic/templates/default/Rakefile",
34
- "lib/staticmatic/templates/default/config.rb",
35
- "lib/staticmatic/templates/default/src/helpers/site_helper.rb",
36
- "lib/staticmatic/templates/default/src/layouts/site.html.haml",
37
- "lib/staticmatic/templates/default/src/pages/index.html.haml",
38
- "lib/staticmatic/templates/default/src/stylesheets/site.css.sass",
39
- "lib/staticmatic/templates/rescues/default_error.html.erb",
40
- "lib/staticmatic/templates/rescues/template_error.html.erb",
41
- "lib/tasks/staticmatic.rb",
42
- "vendor/html-scanner/html/document.rb",
43
- "vendor/html-scanner/html/node.rb",
44
- "vendor/html-scanner/html/sanitizer.rb",
45
- "vendor/html-scanner/html/selector.rb",
46
- "vendor/html-scanner/html/tokenizer.rb",
47
- "vendor/html-scanner/html/version.rb"]
2
+ s.name = "staticmatic"
3
+ s.version = "2.1.0"
4
+ s.date = "2008-08-15"
5
+ s.authors = ["Stephen Bartholomew", "Thomas Reynolds"]
6
+ s.email = "tdreyno@gmail.com"
7
+ s.homepage = "http://github.com/tdreyno/staticmatic"
8
+ s.summary = "Static sites, the Rails Way"
9
+ s.files = ["LICENSE",
10
+ "Rakefile",
11
+ "staticmatic.gemspec",
12
+ "app_generators/staticmatic/staticmatic_generator.rb",
13
+ "app_generators/staticmatic/templates/Rakefile",
14
+ "app_generators/staticmatic/templates/src/helpers/site_helper.rb",
15
+ "app_generators/staticmatic/templates/src/layouts/site.html.haml",
16
+ "app_generators/staticmatic/templates/src/pages/index.html.haml",
17
+ "app_generators/staticmatic/templates/src/stylesheets/site.css.sass",
18
+ "bin/staticmatic",
19
+ "lib/staticmatic.rb",
20
+ "lib/staticmatic/autoload.rb",
21
+ "lib/staticmatic/base.rb",
22
+ "lib/staticmatic/builder.rb",
23
+ "lib/staticmatic/config.rb",
24
+ "lib/staticmatic/deprecation.rb",
25
+ "lib/staticmatic/previewer.rb",
26
+ "lib/staticmatic/rescue.rb",
27
+ "lib/staticmatic/actionpack_support/mime.rb",
28
+ "lib/staticmatic/actionpack_support/remove_partial_benchmark.rb",
29
+ "lib/staticmatic/helpers/asset_tag_helper.rb",
30
+ "lib/staticmatic/helpers/page_helper.rb",
31
+ "lib/staticmatic/helpers/url_helper.rb",
32
+ "lib/staticmatic/template_handlers/haml.rb",
33
+ "lib/staticmatic/template_handlers/liquid.rb",
34
+ "lib/staticmatic/template_handlers/markdown.rb",
35
+ "lib/staticmatic/template_handlers/sass.rb",
36
+ "lib/staticmatic/template_handlers/textile.rb",
37
+ "lib/staticmatic/templates/rescues/default_error.html.erb",
38
+ "lib/staticmatic/templates/rescues/template_error.html.erb",
39
+ "lib/tasks/staticmatic.rb",
40
+ "vendor/html-scanner/html/document.rb",
41
+ "vendor/html-scanner/html/node.rb",
42
+ "vendor/html-scanner/html/sanitizer.rb",
43
+ "vendor/html-scanner/html/selector.rb",
44
+ "vendor/html-scanner/html/tokenizer.rb",
45
+ "vendor/html-scanner/html/version.rb"]
48
46
  s.executables = %w(staticmatic)
49
- s.add_dependency("haml", ">=2.0.1")
47
+ s.add_dependency("rubigen")
50
48
  s.add_dependency("mongrel")
51
- s.add_dependency("actionpack", ">=2.1.0")
49
+ s.add_dependency("haml", ">=2.0.1")
50
+ s.add_dependency("actionpack", ">=2.1.0")
52
51
  s.add_dependency("activesupport", ">=2.1.0")
53
- end
52
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdreyno-staticmatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Bartholomew
@@ -10,17 +10,17 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-07-31 00:00:00 -07:00
13
+ date: 2008-08-15 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: haml
17
+ name: rubigen
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.0.1
23
+ version: "0"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mongrel
@@ -31,6 +31,15 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: "0"
33
33
  version:
34
+ - !ruby/object:Gem::Dependency
35
+ name: haml
36
+ version_requirement:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 2.0.1
42
+ version:
34
43
  - !ruby/object:Gem::Dependency
35
44
  name: actionpack
36
45
  version_requirement:
@@ -50,7 +59,7 @@ dependencies:
50
59
  version: 2.1.0
51
60
  version:
52
61
  description:
53
- email: steve@curve21.com
62
+ email: tdreyno@gmail.com
54
63
  executables:
55
64
  - staticmatic
56
65
  extensions: []
@@ -61,20 +70,24 @@ files:
61
70
  - LICENSE
62
71
  - Rakefile
63
72
  - staticmatic.gemspec
73
+ - app_generators/staticmatic/staticmatic_generator.rb
74
+ - app_generators/staticmatic/templates/Rakefile
75
+ - app_generators/staticmatic/templates/src/helpers/site_helper.rb
76
+ - app_generators/staticmatic/templates/src/layouts/site.html.haml
77
+ - app_generators/staticmatic/templates/src/pages/index.html.haml
78
+ - app_generators/staticmatic/templates/src/stylesheets/site.css.sass
64
79
  - bin/staticmatic
65
80
  - lib/staticmatic.rb
66
81
  - lib/staticmatic/autoload.rb
67
82
  - lib/staticmatic/base.rb
68
83
  - lib/staticmatic/builder.rb
69
84
  - lib/staticmatic/config.rb
70
- - lib/staticmatic/creator.rb
71
85
  - lib/staticmatic/deprecation.rb
72
86
  - lib/staticmatic/previewer.rb
73
87
  - lib/staticmatic/rescue.rb
74
88
  - lib/staticmatic/actionpack_support/mime.rb
75
89
  - lib/staticmatic/actionpack_support/remove_partial_benchmark.rb
76
90
  - lib/staticmatic/helpers/asset_tag_helper.rb
77
- - lib/staticmatic/helpers/deprecated_helpers.rb
78
91
  - lib/staticmatic/helpers/page_helper.rb
79
92
  - lib/staticmatic/helpers/url_helper.rb
80
93
  - lib/staticmatic/template_handlers/haml.rb
@@ -82,12 +95,6 @@ files:
82
95
  - lib/staticmatic/template_handlers/markdown.rb
83
96
  - lib/staticmatic/template_handlers/sass.rb
84
97
  - lib/staticmatic/template_handlers/textile.rb
85
- - lib/staticmatic/templates/default/Rakefile
86
- - lib/staticmatic/templates/default/config.rb
87
- - lib/staticmatic/templates/default/src/helpers/site_helper.rb
88
- - lib/staticmatic/templates/default/src/layouts/site.html.haml
89
- - lib/staticmatic/templates/default/src/pages/index.html.haml
90
- - lib/staticmatic/templates/default/src/stylesheets/site.css.sass
91
98
  - lib/staticmatic/templates/rescues/default_error.html.erb
92
99
  - lib/staticmatic/templates/rescues/template_error.html.erb
93
100
  - lib/tasks/staticmatic.rb
@@ -1,18 +0,0 @@
1
- module StaticMatic
2
- class Creator
3
- class << self
4
- def setup(directory)
5
- FileUtils.mkdir(directory) unless File.exists?(directory)
6
-
7
- template_directory = Dir.glob(File.dirname(__FILE__) + "/templates/default/**")
8
-
9
- FileUtils.cp_r(template_directory, directory)
10
-
11
- unless File.exists?(directory + "/build")
12
- FileUtils.mkdir(directory + "/build")
13
- FileUtils.mkdir(directory + "/build/stylesheets")
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,48 +0,0 @@
1
- module StaticMatic
2
- module Helpers
3
- module DeprecatedHelpers
4
- def stylesheets(*params)
5
- deprecate :alt => "stylesheet_link_tag"
6
-
7
- if params.blank?
8
- glob = File.join(@staticmatic.src_dir, 'stylesheets', '*.sass')
9
- stylesheets = Dir[glob].inject([]) do |sum, stylesheet|
10
- sum << File.basename(stylesheet).chomp(File.extname(stylesheet))
11
- end
12
-
13
- stylesheets.concat assets_from_build_directory("stylesheets", "css", stylesheets)
14
-
15
- params = stylesheets
16
- end
17
-
18
- stylesheet_link_tag(params)
19
- end
20
-
21
- def link(title, href = "", options = {})
22
- deprecate :alt => "link_to"
23
- link_to(title, href, options)
24
- end
25
-
26
- def img(name, options = {})
27
- deprecate :alt => "image_tag"
28
- image_tag(name, options)
29
- end
30
-
31
- def javascripts(*files)
32
- javascript_include_tag(files)
33
- end
34
-
35
- private
36
- # Return an array of asset files from a given build directory
37
- #
38
- # Optionally pass in an array to exclude files served dynamically
39
- def assets_from_build_directory(dir, ext, exclude = [])
40
- glob = File.join(@staticmatic.build_dir, dir, "*.#{ext}")
41
- Dir[glob].inject([]) do |sum, file|
42
- file = File.basename(file).chomp(File.extname(file))
43
- sum << file unless exclude && exclude.include?(file)
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,3 +0,0 @@
1
- StaticMatic::Config.setup(
2
- :use_build_tracking => true
3
- )