gumdrop 0.2.16 → 0.3

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.
Files changed (90) hide show
  1. data/ChangeLog.md +11 -1
  2. data/Rakefile +9 -1
  3. data/bin/gumdrop +3 -1
  4. data/lib/gumdrop.rb +45 -73
  5. data/lib/gumdrop/build.rb +92 -0
  6. data/lib/gumdrop/content.rb +3 -2
  7. data/lib/gumdrop/generator.rb +64 -7
  8. data/lib/gumdrop/logging.rb +35 -0
  9. data/lib/gumdrop/pager.rb +4 -4
  10. data/lib/gumdrop/server.rb +26 -10
  11. data/lib/gumdrop/template/default/Gemfile +4 -2
  12. data/lib/gumdrop/template/default/Rakefile +4 -1
  13. data/lib/gumdrop/template/default/config.ru +6 -2
  14. data/lib/gumdrop/template/default/lib/site.rb +15 -5
  15. data/lib/gumdrop/template/default/powrc +2 -0
  16. data/lib/gumdrop/version.rb +2 -2
  17. data/specs/content_spec.rb +31 -0
  18. data/specs/deferred_loader_spec.rb +31 -0
  19. data/specs/hash_object_spec.rb +31 -0
  20. metadata +19 -83
  21. data/lib/gumdrop/template/twitter/Gemfile +0 -28
  22. data/lib/gumdrop/template/twitter/Rakefile +0 -35
  23. data/lib/gumdrop/template/twitter/config.ru +0 -17
  24. data/lib/gumdrop/template/twitter/data/config.yml +0 -4
  25. data/lib/gumdrop/template/twitter/lib/site.rb +0 -43
  26. data/lib/gumdrop/template/twitter/lib/view_helpers.rb +0 -17
  27. data/lib/gumdrop/template/twitter/source/_sidebar.html.slim +0 -1
  28. data/lib/gumdrop/template/twitter/source/container-app.html.slim +0 -89
  29. data/lib/gumdrop/template/twitter/source/default.htaccess +0 -16
  30. data/lib/gumdrop/template/twitter/source/favicon.ico +0 -0
  31. data/lib/gumdrop/template/twitter/source/feed.xml.builder.txt +0 -23
  32. data/lib/gumdrop/template/twitter/source/fluid.html.slim +0 -134
  33. data/lib/gumdrop/template/twitter/source/hero.html.slim +0 -49
  34. data/lib/gumdrop/template/twitter/source/index.html.erb +0 -10
  35. data/lib/gumdrop/template/twitter/source/theme/screen.css.sass +0 -3
  36. data/lib/gumdrop/template/twitter/source/theme/scripts/app.js.coffee +0 -4
  37. data/lib/gumdrop/template/twitter/source/theme/scripts/jquery.js +0 -4
  38. data/lib/gumdrop/template/twitter/source/theme/styles/_tools.scss +0 -434
  39. data/lib/gumdrop/template/twitter/source/theme/templates/site.template.slim +0 -19
  40. data/lib/gumdrop/template/twitter/source/theme/twitter/LICENSE +0 -13
  41. data/lib/gumdrop/template/twitter/source/theme/twitter/Makefile +0 -30
  42. data/lib/gumdrop/template/twitter/source/theme/twitter/README.md +0 -115
  43. data/lib/gumdrop/template/twitter/source/theme/twitter/bootstrap-min.css +0 -330
  44. data/lib/gumdrop/template/twitter/source/theme/twitter/bootstrap.css +0 -2362
  45. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/css/docs.css +0 -317
  46. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/ico/bootstrap-apple-114x114.png +0 -0
  47. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/ico/bootstrap-apple-57x57.png +0 -0
  48. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/ico/bootstrap-apple-72x72.png +0 -0
  49. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/ico/favicon.ico +0 -0
  50. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/bird.png +0 -0
  51. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/browsers.png +0 -0
  52. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/example-diagram-01.png +0 -0
  53. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/example-diagram-02.png +0 -0
  54. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/example-diagram-03.png +0 -0
  55. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/grid-18px.png +0 -0
  56. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/img/twitter-logo-no-bird.png +0 -0
  57. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/js/application.js +0 -52
  58. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/js/google-code-prettify/prettify.css +0 -41
  59. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/assets/js/google-code-prettify/prettify.js +0 -28
  60. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/index.html +0 -1932
  61. data/lib/gumdrop/template/twitter/source/theme/twitter/docs/javascript.html +0 -676
  62. data/lib/gumdrop/template/twitter/source/theme/twitter/examples/container-app.html +0 -119
  63. data/lib/gumdrop/template/twitter/source/theme/twitter/examples/fluid.html +0 -126
  64. data/lib/gumdrop/template/twitter/source/theme/twitter/examples/hero.html +0 -79
  65. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-alerts.js +0 -104
  66. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-dropdown.js +0 -50
  67. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-modal.js +0 -238
  68. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-popover.js +0 -77
  69. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-scrollspy.js +0 -105
  70. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-tabs.js +0 -62
  71. data/lib/gumdrop/template/twitter/source/theme/twitter/js/bootstrap-twipsy.js +0 -307
  72. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/index.html +0 -38
  73. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-alerts.js +0 -41
  74. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-dropdown.js +0 -52
  75. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-modal.js +0 -151
  76. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-popover.js +0 -76
  77. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-scrollspy.js +0 -31
  78. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-tabs.js +0 -49
  79. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/unit/bootstrap-twipsy.js +0 -81
  80. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/vendor/qunit.css +0 -232
  81. data/lib/gumdrop/template/twitter/source/theme/twitter/js/tests/vendor/qunit.js +0 -1510
  82. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/bootstrap.less +0 -26
  83. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/forms.less +0 -465
  84. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/mixins.less +0 -217
  85. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/patterns.less +0 -1005
  86. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/reset.less +0 -141
  87. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/scaffolding.less +0 -135
  88. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/tables.less +0 -171
  89. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/type.less +0 -187
  90. data/lib/gumdrop/template/twitter/source/theme/twitter/lib/variables.less +0 -60
@@ -1,3 +1,13 @@
1
+ # v0.3
2
+ - Better logging support
3
+ - Removed twitter-bootstrap template
4
+ - Initial support for stitch-rb via a `stitch` generator command.
5
+
6
+ # v0.2.17
7
+ - Updated syntax to Ruby 1.9
8
+ - Tweaked template Rakefile(s)
9
+ - Added some initial specs
10
+
1
11
  # v0.2.16
2
12
  - Added option to specify output folder, still defaults to "output"
3
13
  - Bugfix: content wasn't looking for layouts right, causing exception
@@ -55,4 +65,4 @@
55
65
  - Fixed bug where partials weren't rendered via the dev server.
56
66
 
57
67
  # v0.2.1
58
- - Initial release. Yay!
68
+ - Initial release. Yay!
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
2
  require "gumdrop/version"
3
-
3
+ require 'rake/testtask'
4
+
4
5
  desc "builds gem"
5
6
  task :build do
6
7
  system "gem build gumdrop.gemspec"
@@ -20,3 +21,10 @@ desc "uninstalls gem"
20
21
  task :uninstall do
21
22
  system "gem uninstall gumdrop"
22
23
  end
24
+
25
+
26
+ Rake::TestTask.new do |t|
27
+ t.libs.push "lib"
28
+ t.test_files = FileList['specs/*_spec.rb']
29
+ t.verbose = true
30
+ end
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
2
4
  # Copyright (c) 2011 M@ McCray. All rights reserved.
3
5
 
4
6
  $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
@@ -8,4 +10,4 @@ require 'rubygems'
8
10
  # require 'bundler/setup'
9
11
 
10
12
  require "gumdrop"
11
- require "gumdrop/cli"
13
+ require "gumdrop/cli"
@@ -1,31 +1,29 @@
1
+ # coding: utf-8
2
+
1
3
  require 'tilt'
2
4
  require 'fileutils'
3
5
  require 'active_support/all'
4
6
 
5
7
  DEFAULT_OPTIONS= {
6
- :cache_data => false,
7
- :relative_paths => true,
8
- :auto_run => false,
9
- :force_reload => false,
10
- :root => ".",
11
- :log_level => :info,
12
- :output_dir => "./output"
8
+ cache_data: false,
9
+ relative_paths: true,
10
+ auto_run: false,
11
+ force_reload: false,
12
+ root: ".",
13
+ log_level: :info,
14
+ output_dir: "./output",
15
+ log: 'logs/build.log'
13
16
  }
14
17
 
15
18
  LOG_LEVELS = {
16
- :info => 0,
17
- :warning => 1,
18
- :error => 2
19
+ info: 0,
20
+ warning: 1,
21
+ error: 2
19
22
  }
20
23
 
21
- # LOG_LEVELS = {
22
- # info: 0,
23
- # warning: 1,
24
- # error: 2
25
- # }
26
-
27
24
  module Gumdrop
28
25
 
26
+ autoload :Build, "gumdrop/build"
29
27
  autoload :Context, "gumdrop/context"
30
28
  autoload :Content, "gumdrop/content"
31
29
  autoload :DeferredLoader, "gumdrop/deferred_loader"
@@ -33,6 +31,7 @@ module Gumdrop
33
31
  autoload :Generator, "gumdrop/generator"
34
32
  autoload :GeneratedrContent, "gumdrop/generator"
35
33
  autoload :HashObject, "gumdrop/hash_object"
34
+ autoload :Logging, "gumdrop/logging"
36
35
  autoload :Pager, "gumdrop/pager"
37
36
  autoload :Server, "gumdrop/server"
38
37
  autoload :Utils, "gumdrop/utils"
@@ -41,7 +40,18 @@ module Gumdrop
41
40
 
42
41
  class << self
43
42
 
44
- attr_accessor :root_path, :source_path, :site, :layouts, :generators, :partials, :config, :data, :content_filters, :blacklist
43
+ attr_accessor :root_path,
44
+ :source_path,
45
+ :site,
46
+ :layouts,
47
+ :generators,
48
+ :partials,
49
+ :config,
50
+ :data,
51
+ :content_filters,
52
+ :blacklist,
53
+ :log,
54
+ :last_run
45
55
 
46
56
  def run(opts={})
47
57
  # Opts
@@ -62,6 +72,16 @@ module Gumdrop
62
72
  @root_path = root.split '/'
63
73
  @source_path = src.split '/'
64
74
  @data = Gumdrop::DeferredLoader.new()
75
+ @last_run = Time.now
76
+
77
+ begin
78
+ @log = Logger.new Gumdrop.config.log, 'daily'
79
+ rescue
80
+ @log = Logger.new STDOUT
81
+ end
82
+ @log.formatter = proc do |severity, datetime, progname, msg|
83
+ "#{datetime}: #{msg}\n"
84
+ end
65
85
 
66
86
  @content_filters= []
67
87
  @blacklist = []
@@ -71,61 +91,10 @@ module Gumdrop
71
91
  source= IO.readlines("#{root}/lib/site.rb").join('')
72
92
  DSL.class_eval source
73
93
  end
74
-
75
- # Scan
76
- #puts "Running in: #{root}"
77
- Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).each do |path|
78
- unless File.directory? path or File.basename(path) == '.DS_Store' # should be smarter about this?
79
- file_path = (path.split('/') - @root_path).join '/'
80
- node= Content.new(file_path)
81
- @site[node.to_s]= node
82
- end
83
- end
84
-
85
- # Layouts, Generators, and Partials
86
- @site.keys.each do |path|
87
- if File.extname(path) == ".template"
88
- @layouts[File.basename(path)]= @site.delete(path)
89
94
 
90
- elsif File.extname(path) == ".generator"
91
- @generators[File.basename(path)]= Generator.new( @site.delete(path) )
92
-
93
- elsif File.basename(path).starts_with?("_")
94
- partial_name= File.basename(path)[1..-1].gsub(File.extname(File.basename(path)), '')
95
- # puts "Creating partial #{partial_name} from #{path}"
96
- @partials[partial_name]= @site.delete(path)
97
- end
98
- end
99
-
100
- @generators.each_pair do |path, generator|
101
- generator.execute()
102
- end
103
-
104
- @blacklist.each do |skip_path|
105
- @site.keys.each do |source_path|
106
- if source_path.starts_with? skip_path
107
- Gumdrop.report " -ignoring: #{source_path}", :info
108
- @site.delete source_path
109
- end
110
- end
111
- end
112
-
113
- # Render
114
- unless opts[:dry_run]
115
- output_base_path= File.expand_path(Gumdrop.config.output_dir)
116
- site.keys.sort.each do |path|
117
- #unless @blacklist.detect {|p| path.starts_with?(p) }
118
- node= site[path]
119
- output_path= File.join(output_base_path, node.to_s)
120
- FileUtils.mkdir_p File.dirname(output_path)
121
- node.renderTo output_path, @content_filters
122
- # else
123
- # Gumdrop.report " -ignoring: #{path}", :info
124
- # end
125
- end
126
- puts "Done."
127
- end
95
+ Build.run root, src, opts
128
96
 
97
+ puts "Done."
129
98
  end
130
99
 
131
100
  # levels: info, warning, error
@@ -133,15 +102,18 @@ module Gumdrop
133
102
  ll= Gumdrop.config.log_level
134
103
  case level
135
104
  when :info
136
- puts msg if ll == :info
105
+ #puts msg if ll == :info
106
+ @log.info msg
137
107
  when :warning
138
- puts msg if ll == :info or ll == :warning
108
+ #puts msg if ll == :info or ll == :warning
109
+ @log.warn msg
139
110
  else
140
111
  puts msg
112
+ @log.error msg
141
113
  end
142
114
  end
143
115
  end
144
116
 
145
117
  Gumdrop.config= Gumdrop::HashObject.new(DEFAULT_OPTIONS)
146
118
 
147
- end
119
+ end
@@ -0,0 +1,92 @@
1
+
2
+ module Gumdrop
3
+
4
+ class Build
5
+ attr_reader :root, :src, :opts
6
+
7
+ SKIP= %w(.DS_Store .gitignore .git .svn .sass-cache)
8
+
9
+ def initialize(root, src, opts={})
10
+ @root= root
11
+ @root_path= root.split('/')
12
+ @src= src
13
+ @opts= opts
14
+ # if opts[:auto_run]
15
+ # run()
16
+ # end
17
+ end
18
+
19
+ def build_tree
20
+ # Scan Filesystem
21
+ #puts "Running in: #{root}"
22
+ Dir.glob("#{src}/**/*", File::FNM_DOTMATCH).each do |path|
23
+ unless File.directory? path or Build::SKIP.include?( File.basename(path) )
24
+ file_path = (path.split('/') - @root_path).join '/'
25
+ node= Content.new(file_path)
26
+ path= node.to_s
27
+
28
+ # Sort out Layouts, Generators, and Partials
29
+ if File.extname(path) == ".template"
30
+ Gumdrop.layouts[File.basename(path)]= node
31
+
32
+ elsif File.extname(path) == ".generator"
33
+ Gumdrop.generators[File.basename(path)]= Generator.new( node )
34
+
35
+ elsif File.basename(path).starts_with?("_")
36
+ partial_name= File.basename(path)[1..-1].gsub(File.extname(File.basename(path)), '')
37
+ # puts "Creating partial #{partial_name} from #{path}"
38
+ Gumdrop.partials[partial_name]= node
39
+
40
+ else
41
+ Gumdrop.site[path]= node
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ def run_generators
49
+ Gumdrop.generators.each_pair do |path, generator|
50
+ generator.execute()
51
+ end
52
+ end
53
+
54
+ def filter_tree
55
+ Gumdrop.blacklist.each do |skip_path|
56
+ Gumdrop.site.keys.each do |source_path|
57
+ if source_path.starts_with? skip_path
58
+ Gumdrop.report " -ignoring: #{source_path}", :info
59
+ Gumdrop.site.delete source_path
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ def render
66
+ unless opts[:dry_run]
67
+ output_base_path= File.expand_path(Gumdrop.config.output_dir)
68
+ Gumdrop.site.keys.sort.each do |path|
69
+ node= Gumdrop.site[path]
70
+ output_path= File.join(output_base_path, node.to_s)
71
+ FileUtils.mkdir_p File.dirname(output_path)
72
+ node.renderTo output_path, Gumdrop.content_filters
73
+ end
74
+ end
75
+ end
76
+
77
+ def run
78
+ build_tree()
79
+ run_generators()
80
+ filter_tree()
81
+ render()
82
+ self
83
+ end
84
+
85
+ class << self
86
+ def run(root, src, opts={})
87
+ new(root, src, opts).run()
88
+ end
89
+ end
90
+ end
91
+
92
+ end
@@ -37,7 +37,7 @@ module Gumdrop
37
37
  return content if ignore_layout
38
38
  layout= Context.get_template()
39
39
  while !layout.nil?
40
- content = layout.template.render(Context, :content=>content) { content }
40
+ content = layout.template.render(Context, content:content) { content }
41
41
  layout= Context.get_template()
42
42
  end
43
43
  content
@@ -52,6 +52,7 @@ module Gumdrop
52
52
  f.write output
53
53
  end
54
54
  end
55
+
55
56
 
56
57
  def copyTo(output, layout=nil, opts={})
57
58
  do_copy= if File.exists? output
@@ -85,4 +86,4 @@ module Gumdrop
85
86
 
86
87
  end
87
88
 
88
- end
89
+ end
@@ -1,3 +1,18 @@
1
+
2
+ require 'stitch'
3
+ require 'jsmin'
4
+
5
+ class Stitch::Source
6
+ # Patch for gumdrop style filenames
7
+ def name
8
+ name = path.relative_path_from(root)
9
+ name = name.dirname + name.basename(".*")
10
+ name.to_s.gsub(".js", '')
11
+ end
12
+ end
13
+
14
+
15
+
1
16
  module Gumdrop
2
17
 
3
18
  class Generator
@@ -40,16 +55,40 @@ module Gumdrop
40
55
  else
41
56
  "/#{@base_path}/#{name}"
42
57
  end
43
- content= GeneratedContent.new(filepath, opts)
44
- content.template = if Gumdrop.layouts.has_key?( opts[:template] )
45
- Gumdrop.layouts[ opts[:template] ]
46
- else
47
- Gumdrop.layouts[ "#{opts[:template]}.template" ]
48
- end.template
58
+ content= GeneratedContent.new(filepath, block, opts)
59
+ if opts.has_key? :template and !opts[:template].nil?
60
+ content.template = if Gumdrop.layouts.has_key?( opts[:template] )
61
+ Gumdrop.layouts[ opts[:template] ]
62
+ else
63
+ Gumdrop.layouts[ "#{opts[:template]}.template" ]
64
+ end.template
65
+ end
49
66
 
50
67
  Gumdrop.site[content.uri]= content
51
68
  end
52
69
 
70
+ def stitch(name, opts)
71
+ page name do
72
+ content= Stitch::Package.new(opts).compile
73
+ if opts[:compress]
74
+ JSMin.minify content
75
+ else
76
+ content
77
+ end
78
+ end
79
+ if opts[:prune] and opts[:root]
80
+ sp = File.expand_path('./source')
81
+ rp = File.expand_path(opts[:root])
82
+ relative_root = rp.gsub(sp, '')[1..-1]
83
+ rrlen= relative_root.length - 1
84
+ Gumdrop.site.keys.each do |path|
85
+ if path[0..rrlen] == relative_root and name != path
86
+ Gumdrop.site.delete path
87
+ end
88
+ end
89
+ end
90
+ end
91
+
53
92
  def run_dsl_from_source(source)
54
93
  # puts source
55
94
  instance_eval source
@@ -64,6 +103,24 @@ module Gumdrop
64
103
 
65
104
  class GeneratedContent < Content
66
105
  # Nothing special, per se...
106
+
107
+ def initialize(path, block, params={})
108
+ @content_block= block
109
+ super(path, params)
110
+ end
111
+
112
+ def render(ignore_layout=false, reset_context=true, locals={})
113
+ if @content_block.nil?
114
+ super(ignore_layout, reset_context, locals)
115
+ else
116
+ @content_block.call
117
+ end
118
+ end
119
+
120
+ def useLayout?
121
+ !@content_block.nil? or !@template.nil?
122
+ end
123
+
67
124
  end
68
125
 
69
- end
126
+ end
@@ -0,0 +1,35 @@
1
+ # Logging support
2
+
3
+ require 'logger'
4
+
5
+ module Gumdrop
6
+
7
+ module Logging
8
+
9
+ class << self
10
+
11
+ def log
12
+
13
+ end
14
+
15
+ def info
16
+
17
+ end
18
+
19
+ def warn
20
+
21
+ end
22
+
23
+ def error
24
+
25
+ end
26
+
27
+ def debug
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end