nesta 0.9.13 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/{spec/spec.opts → .rspec} +0 -0
  3. data/.travis.yml +3 -2
  4. data/CHANGES +130 -1
  5. data/Gemfile +1 -8
  6. data/Gemfile.lock +68 -51
  7. data/LICENSE +1 -1
  8. data/README.md +38 -6
  9. data/Rakefile +2 -5
  10. data/bin/nesta +59 -3
  11. data/config.ru +3 -0
  12. data/lib/nesta.rb +1 -1
  13. data/lib/nesta/app.rb +20 -17
  14. data/lib/nesta/commands.rb +6 -3
  15. data/lib/nesta/config.rb +52 -15
  16. data/lib/nesta/helpers.rb +30 -3
  17. data/lib/nesta/models.rb +48 -30
  18. data/lib/nesta/navigation.rb +32 -12
  19. data/lib/nesta/overrides.rb +5 -5
  20. data/lib/nesta/version.rb +1 -1
  21. data/nesta.gemspec +9 -10
  22. data/smoke-test.sh +102 -0
  23. data/spec/atom_spec.rb +52 -49
  24. data/spec/commands_spec.rb +22 -16
  25. data/spec/config_spec.rb +66 -6
  26. data/spec/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +1 -3
  27. data/spec/model_factory.rb +16 -16
  28. data/spec/models_spec.rb +197 -144
  29. data/spec/overrides_spec.rb +21 -21
  30. data/spec/page_spec.rb +182 -136
  31. data/spec/sitemap_spec.rb +48 -43
  32. data/spec/spec_helper.rb +32 -17
  33. data/templates/Gemfile +5 -2
  34. data/templates/config/config.yml +13 -13
  35. data/templates/config/deploy.rb +2 -2
  36. data/templates/index.haml +2 -0
  37. data/templates/themes/app.rb +1 -1
  38. data/templates/themes/views/layout.haml +7 -0
  39. data/templates/themes/views/master.sass +3 -0
  40. data/templates/themes/views/page.haml +1 -0
  41. data/views/atom.haml +3 -3
  42. data/views/comments.haml +1 -1
  43. data/views/error.haml +1 -1
  44. data/views/feed.haml +1 -1
  45. data/views/layout.haml +6 -3
  46. data/views/master.sass +143 -133
  47. data/views/mixins.sass +53 -28
  48. data/views/normalize.scss +396 -0
  49. data/views/page_meta.haml +2 -2
  50. data/views/sitemap.haml +2 -2
  51. data/views/summaries.haml +2 -2
  52. metadata +155 -202
  53. data/lib/nesta/cache.rb +0 -138
@@ -1,138 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Sinatra
4
-
5
- # Sinatra Caching module
6
- #
7
- # TODO:: Need to write documentation here
8
- #
9
- module Cache
10
-
11
- VERSION = 'Sinatra::Cache v0.2.0'
12
- def self.version; VERSION; end
13
-
14
-
15
- module Helpers
16
-
17
- # Caches the given URI to a html file in /public
18
- #
19
- # <b>Usage:</b>
20
- # >> cache( erb(:contact, :layout => :layout))
21
- # => returns the HTML output written to /public/<CACHE_DIR_PATH>/contact.html
22
- #
23
- # Also accepts an Options Hash, with the following options:
24
- # * :extension => in case you need to change the file extension
25
- #
26
- # TODO:: implement the opts={} hash functionality. What other options are needed?
27
- #
28
- def cache(content, opts={})
29
- return content unless settings.cache_enabled
30
-
31
- unless content.nil?
32
- content = "#{content}\n#{page_cached_timestamp}\n"
33
- path = cache_page_path(request.path_info,opts)
34
- FileUtils.makedirs(File.dirname(path))
35
- open(path, 'wb+') { |f| f << content }
36
- log("Cached Page: [#{path}]",:info)
37
- content
38
- end
39
- end
40
-
41
- # Expires the cached URI (as .html file) in /public
42
- #
43
- # <b>Usage:</b>
44
- # >> cache_expire('/contact')
45
- # => deletes the /public/<CACHE_DIR_PATH>contact.html page
46
- #
47
- # get '/contact' do
48
- # cache_expire # deletes the /public/<CACHE_DIR_PATH>contact.html page as well
49
- # end
50
- #
51
- # TODO:: implement the options={} hash functionality. What options are really needed ?
52
- def cache_expire(path = nil, opts={})
53
- return unless settings.cache_enabled
54
-
55
- path = (path.nil?) ? cache_page_path(request.path_info) : cache_page_path(path)
56
- if File.exist?(path)
57
- File.delete(path)
58
- log("Expired Page deleted at: [#{path}]",:info)
59
- else
60
- log("No Expired Page was found at the path: [#{path}]",:info)
61
- end
62
- end
63
-
64
- # Prints a basic HTML comment with a timestamp in it, so that you can see when a file was cached last.
65
- #
66
- # *NB!* IE6 does NOT like this to be the first line of a HTML document, so output
67
- # inside the <head> tag. Many hours wasted on that lesson ;-)
68
- #
69
- # <b>Usage:</b>
70
- # >> <%= page_cached_timestamp %>
71
- # => <!-- page cached: 2009-02-24 12:00:00 -->
72
- #
73
- def page_cached_timestamp
74
- "<!-- page cached: #{Time.now.strftime("%Y-%d-%m %H:%M:%S")} -->\n" if settings.cache_enabled
75
- end
76
-
77
-
78
- private
79
-
80
- # Establishes the file name of the cached file from the path given
81
- #
82
- # TODO:: implement the opts={} functionality, and support for custom extensions on a per request basis.
83
- #
84
- def cache_file_name(path,opts={})
85
- name = (path.empty? || path == "/") ? "index" : Rack::Utils.unescape(path.sub(/^(\/)/,'').chomp('/'))
86
- name << settings.cache_page_extension unless (name.split('/').last || name).include? '.'
87
- return name
88
- end
89
-
90
- # Sets the full path to the cached page/file
91
- # Dependent upon Sinatra.settings .public and .cache_dir variables being present and set.
92
- #
93
- def cache_page_path(path,opts={})
94
- # test if given a full path rather than relative path, otherwise join the public path to cache_dir
95
- # and ensure it is a full path
96
- cache_dir = (settings.cache_dir == File.expand_path(settings.cache_dir)) ?
97
- settings.cache_dir : File.expand_path("#{settings.public}/#{settings.cache_dir}")
98
- cache_dir = cache_dir[0..-2] if cache_dir[-1,1] == '/'
99
- "#{cache_dir}/#{cache_file_name(path,opts)}"
100
- end
101
-
102
- # TODO:: this implementation really stinks, how do I incorporate Sinatra's logger??
103
- def log(msg,scope=:debug)
104
- if settings.cache_logging
105
- "Log: msg=[#{msg}]" if scope == settings.cache_logging_level
106
- else
107
- # just ignore the stuff...
108
- # puts "just ignoring msg=[#{msg}] since cache_logging => [#{settings.cache_logging.to_s}]"
109
- end
110
- end
111
-
112
- end #/module Helpers
113
-
114
-
115
- # Sets the default settings:
116
- #
117
- # * +:cache_enabled+ => toggle for the cache functionality. Default is: +true+
118
- # * +:cache_page_extension+ => sets the default extension for cached files. Default is: +.html+
119
- # * +:cache_dir+ => sets cache directory where cached files are stored. Default is: ''(empty) == root of /public.<br>
120
- # set to empty, since the ideal 'system/cache/' does not work with Passenger & mod_rewrite :(
121
- # * +cache_logging+ => toggle for logging the cache calls. Default is: +true+
122
- # * +cache_logging_level+ => sets the level of the cache logger. Default is: <tt>:info</tt>.<br>
123
- # Options:(unused atm) [:info, :warn, :debug]
124
- #
125
- def self.registered(app)
126
- app.helpers(Cache::Helpers)
127
- app.set :cache_enabled, true
128
- app.set :cache_page_extension, '.html'
129
- app.set :cache_dir, ''
130
- app.set :cache_logging, true
131
- app.set :cache_logging_level, :info
132
- end
133
-
134
- end #/module Cache
135
-
136
- register(Sinatra::Cache)
137
-
138
- end #/module Sinatra