nesta 0.9.13 → 0.10.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.
- checksums.yaml +7 -0
- data/{spec/spec.opts → .rspec} +0 -0
- data/.travis.yml +3 -2
- data/CHANGES +130 -1
- data/Gemfile +1 -8
- data/Gemfile.lock +68 -51
- data/LICENSE +1 -1
- data/README.md +38 -6
- data/Rakefile +2 -5
- data/bin/nesta +59 -3
- data/config.ru +3 -0
- data/lib/nesta.rb +1 -1
- data/lib/nesta/app.rb +20 -17
- data/lib/nesta/commands.rb +6 -3
- data/lib/nesta/config.rb +52 -15
- data/lib/nesta/helpers.rb +30 -3
- data/lib/nesta/models.rb +48 -30
- data/lib/nesta/navigation.rb +32 -12
- data/lib/nesta/overrides.rb +5 -5
- data/lib/nesta/version.rb +1 -1
- data/nesta.gemspec +9 -10
- data/smoke-test.sh +102 -0
- data/spec/atom_spec.rb +52 -49
- data/spec/commands_spec.rb +22 -16
- data/spec/config_spec.rb +66 -6
- data/spec/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +1 -3
- data/spec/model_factory.rb +16 -16
- data/spec/models_spec.rb +197 -144
- data/spec/overrides_spec.rb +21 -21
- data/spec/page_spec.rb +182 -136
- data/spec/sitemap_spec.rb +48 -43
- data/spec/spec_helper.rb +32 -17
- data/templates/Gemfile +5 -2
- data/templates/config/config.yml +13 -13
- data/templates/config/deploy.rb +2 -2
- data/templates/index.haml +2 -0
- data/templates/themes/app.rb +1 -1
- data/templates/themes/views/layout.haml +7 -0
- data/templates/themes/views/master.sass +3 -0
- data/templates/themes/views/page.haml +1 -0
- data/views/atom.haml +3 -3
- data/views/comments.haml +1 -1
- data/views/error.haml +1 -1
- data/views/feed.haml +1 -1
- data/views/layout.haml +6 -3
- data/views/master.sass +143 -133
- data/views/mixins.sass +53 -28
- data/views/normalize.scss +396 -0
- data/views/page_meta.haml +2 -2
- data/views/sitemap.haml +2 -2
- data/views/summaries.haml +2 -2
- metadata +155 -202
- data/lib/nesta/cache.rb +0 -138
data/lib/nesta/cache.rb
DELETED
@@ -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
|