nesta 0.9.2 → 0.9.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.
- data/CHANGES +42 -0
- data/Gemfile.lock +1 -4
- data/bin/nesta +0 -2
- data/lib/nesta/app.rb +16 -38
- data/lib/nesta/commands.rb +2 -1
- data/lib/nesta/config.rb +1 -2
- data/lib/nesta/models.rb +75 -23
- data/lib/nesta/navigation.rb +35 -4
- data/lib/nesta/version.rb +1 -1
- data/nesta.gemspec +0 -1
- data/spec/commands_spec.rb +4 -16
- data/spec/models_spec.rb +145 -42
- data/spec/page_spec.rb +63 -35
- data/spec/spec_helper.rb +12 -14
- data/templates/Rakefile +0 -24
- data/templates/config/config.yml +0 -6
- data/templates/index.haml +1 -0
- data/views/atom.haml +28 -0
- data/views/master.sass +25 -8
- data/views/page.haml +1 -6
- data/views/sitemap.haml +11 -0
- metadata +27 -42
- data/config/config.yml.sample +0 -73
- data/views/atom.builder +0 -28
- data/views/index.haml +0 -7
- data/views/sitemap.builder +0 -15
data/CHANGES
CHANGED
@@ -1,3 +1,45 @@
|
|
1
|
+
= 0.9.3 / 18 January 2011
|
2
|
+
|
3
|
+
* The route and view for serving the home page (/) has been removed,
|
4
|
+
and the home page must now be created as an index page in
|
5
|
+
content/pages.
|
6
|
+
|
7
|
+
You will have to create `content/pages/index.haml` manually when
|
8
|
+
upgrading. Running `nesta new mysite.com` will create a
|
9
|
+
`content/pages/index.haml` file that is suitable for a blog.
|
10
|
+
|
11
|
+
* The URL /my-page can be served from `pages/my-page/index.mdown` as
|
12
|
+
well as pages/my-page.mdown (index pages can also be created with
|
13
|
+
Textile or Haml, just like any other page).
|
14
|
+
|
15
|
+
* The description and keywords settings have been removed from
|
16
|
+
config.yml as they can now be set on `content/pages/index.haml`.
|
17
|
+
|
18
|
+
* Added the Title metadata key to override a page's default title tag.
|
19
|
+
|
20
|
+
* Specify the sort order of pages that are listed on a category page.
|
21
|
+
Optionally append a colon and a number to a path in the 'Categories'
|
22
|
+
metadata to control the sort order of pages listed on the category
|
23
|
+
page.
|
24
|
+
|
25
|
+
See these files for the syntax:
|
26
|
+
https://github.com/gma/nesta-demo-content/tree/master/pages/examples
|
27
|
+
|
28
|
+
* Support arbitrarily deep hierarchies when generating the breadcrumb
|
29
|
+
(see the new helper method added to Nesta::Navigation).
|
30
|
+
|
31
|
+
* Dropped the --heroku switch (Heroku runs fine without it and there is
|
32
|
+
less chance that committing config.yml to your repository will be an
|
33
|
+
issue now that Nesta sites live in their own repositories).
|
34
|
+
|
35
|
+
* Re-implemented /articles.xml and /sitemap.xml in Haml, dropping the
|
36
|
+
dependency on builder. This side steps a bug in Ruby 1.9.1, so Nesta
|
37
|
+
can now run on 1.9.1 again. Also fixed a validity error in the Atom
|
38
|
+
feed.
|
39
|
+
|
40
|
+
* Bug fix: Don't output empty <li> tags for nested submenus that are
|
41
|
+
beneath the requested number of levels.
|
42
|
+
|
1
43
|
= 0.9.2 / 10 January 2011
|
2
44
|
|
3
45
|
* Made the FileModel.metadata method public, to allow for custom
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nesta (0.9.
|
4
|
+
nesta (0.9.3)
|
5
5
|
RedCloth (~> 4.2)
|
6
|
-
builder (~> 3.0)
|
7
6
|
haml (~> 3.0)
|
8
7
|
maruku (>= 0.6.0)
|
9
8
|
shotgun (>= 0.8)
|
@@ -13,7 +12,6 @@ GEM
|
|
13
12
|
remote: http://rubygems.org/
|
14
13
|
specs:
|
15
14
|
RedCloth (4.2.3)
|
16
|
-
builder (3.0.0)
|
17
15
|
haml (3.0.25)
|
18
16
|
hoe (2.6.2)
|
19
17
|
rake (>= 0.8.7)
|
@@ -45,7 +43,6 @@ PLATFORMS
|
|
45
43
|
|
46
44
|
DEPENDENCIES
|
47
45
|
RedCloth (~> 4.2)
|
48
|
-
builder (~> 3.0)
|
49
46
|
haml (~> 3.0)
|
50
47
|
hpricot (= 0.8.3)
|
51
48
|
maruku (>= 0.6.0)
|
data/bin/nesta
CHANGED
@@ -22,7 +22,6 @@ COMMANDS
|
|
22
22
|
|
23
23
|
OPTIONS FOR new
|
24
24
|
--git Create a new git repository for the project.
|
25
|
-
--heroku Include the heroku:config rake task.
|
26
25
|
--vlad Include config/deploy.rb.
|
27
26
|
|
28
27
|
EOF
|
@@ -33,7 +32,6 @@ exit 0
|
|
33
32
|
opts = GetoptLong.new(
|
34
33
|
['--git', GetoptLong::NO_ARGUMENT],
|
35
34
|
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
36
|
-
['--heroku', GetoptLong::NO_ARGUMENT],
|
37
35
|
['--vlad', GetoptLong::NO_ARGUMENT]
|
38
36
|
)
|
39
37
|
options = {}
|
data/lib/nesta/app.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require 'builder'
|
3
2
|
require 'haml'
|
4
3
|
require 'sass'
|
5
4
|
|
@@ -38,14 +37,6 @@ module Nesta
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
def set_title(page)
|
42
|
-
if page.respond_to?(:parent) && page.parent
|
43
|
-
@title = "#{page.heading} - #{page.parent.heading}"
|
44
|
-
else
|
45
|
-
@title = "#{page.heading} - #{Nesta::Config.title}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
40
|
def no_widow(text)
|
50
41
|
text.split[0...-1].join(" ") + " #{text.split[-1]}"
|
51
42
|
end
|
@@ -99,6 +90,18 @@ module Nesta
|
|
99
90
|
haml_tag :link, :href => "/css/#{name}.css", :rel => "stylesheet"
|
100
91
|
end
|
101
92
|
end
|
93
|
+
|
94
|
+
def latest_articles(count = 8)
|
95
|
+
Nesta::Page.find_articles[0..count - 1]
|
96
|
+
end
|
97
|
+
|
98
|
+
def article_summaries(articles)
|
99
|
+
haml(
|
100
|
+
:summaries,
|
101
|
+
:layout => false,
|
102
|
+
:locals => { :pages => latest_articles }
|
103
|
+
)
|
104
|
+
end
|
102
105
|
end
|
103
106
|
|
104
107
|
not_found do
|
@@ -111,23 +114,6 @@ module Nesta
|
|
111
114
|
haml(:error)
|
112
115
|
end unless Nesta::App.environment == :development
|
113
116
|
|
114
|
-
# If you want to change Nesta's behaviour, you have two options:
|
115
|
-
#
|
116
|
-
# 1. Create an app.rb file in your project's root directory.
|
117
|
-
# 2. Make a theme or a plugin, and put the relevant code in there.
|
118
|
-
#
|
119
|
-
# You can add new routes, or modify the behaviour of any of the
|
120
|
-
# default objects in app.rb, or replace any of the default view
|
121
|
-
# templates by creating replacements of the same name in a ./views
|
122
|
-
# folder situated in the root directory of the project for your
|
123
|
-
# site.
|
124
|
-
#
|
125
|
-
# Your ./views folder gets searched first when rendering a template
|
126
|
-
# or Sass file, then the currently configured theme is searched, and
|
127
|
-
# finally Nesta will check if the template exists in the views
|
128
|
-
# folder in the Nesta gem (which is where the default look and feel
|
129
|
-
# is defined).
|
130
|
-
#
|
131
117
|
Overrides.load_local_app
|
132
118
|
Overrides.load_theme_app
|
133
119
|
|
@@ -144,15 +130,6 @@ module Nesta
|
|
144
130
|
cache sass(params[:sheet].to_sym)
|
145
131
|
end
|
146
132
|
|
147
|
-
get '/' do
|
148
|
-
set_common_variables
|
149
|
-
set_from_config(:title, :subtitle, :description, :keywords)
|
150
|
-
@heading = @title
|
151
|
-
@title = "#{@title} - #{@subtitle}"
|
152
|
-
@articles = Page.find_articles[0..7]
|
153
|
-
cache haml(:index)
|
154
|
-
end
|
155
|
-
|
156
133
|
get %r{/attachments/([\w/.-]+)} do
|
157
134
|
file = File.join(Nesta::Config.attachment_path, params[:captures].first)
|
158
135
|
send_file(file, :disposition => nil)
|
@@ -162,7 +139,7 @@ module Nesta
|
|
162
139
|
content_type :xml, :charset => 'utf-8'
|
163
140
|
set_from_config(:title, :subtitle, :author)
|
164
141
|
@articles = Page.find_articles.select { |a| a.date }[0..9]
|
165
|
-
cache
|
142
|
+
cache haml(:atom, :format => :xhtml, :layout => false)
|
166
143
|
end
|
167
144
|
|
168
145
|
get '/sitemap.xml' do
|
@@ -171,15 +148,16 @@ module Nesta
|
|
171
148
|
@last = @pages.map { |page| page.last_modified }.inject do |latest, page|
|
172
149
|
(page > latest) ? page : latest
|
173
150
|
end
|
174
|
-
cache
|
151
|
+
cache haml(:sitemap, :format => :xhtml, :layout => false)
|
175
152
|
end
|
176
153
|
|
177
154
|
get '*' do
|
178
155
|
set_common_variables
|
156
|
+
@heading = @title
|
179
157
|
parts = params[:splat].map { |p| p.sub(/\/$/, '') }
|
180
158
|
@page = Nesta::Page.find_by_path(File.join(parts))
|
181
159
|
raise Sinatra::NotFound if @page.nil?
|
182
|
-
|
160
|
+
@title = @page.title
|
183
161
|
set_from_page(:description, :keywords)
|
184
162
|
cache haml(@page.template, :layout => @page.layout)
|
185
163
|
end
|
data/lib/nesta/commands.rb
CHANGED
@@ -66,7 +66,7 @@ module Nesta
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def have_rake_tasks?
|
69
|
-
@options['
|
69
|
+
@options['vlad']
|
70
70
|
end
|
71
71
|
|
72
72
|
def create_repository
|
@@ -85,6 +85,7 @@ module Nesta
|
|
85
85
|
templates = {
|
86
86
|
'config.ru' => "#{@path}/config.ru",
|
87
87
|
'config/config.yml' => "#{@path}/config/config.yml",
|
88
|
+
'index.haml' => "#{@path}/content/pages/index.haml",
|
88
89
|
'Gemfile' => "#{@path}/Gemfile"
|
89
90
|
}
|
90
91
|
templates['Rakefile'] = "#{@path}/Rakefile" if have_rake_tasks?
|
data/lib/nesta/config.rb
CHANGED
@@ -6,8 +6,7 @@ require "sinatra"
|
|
6
6
|
module Nesta
|
7
7
|
class Config
|
8
8
|
@settings = %w[
|
9
|
-
title subtitle
|
10
|
-
cache content google_analytics_code
|
9
|
+
title subtitle theme disqus_short_name cache content google_analytics_code
|
11
10
|
]
|
12
11
|
@author_settings = %w[name uri email]
|
13
12
|
@yaml = nil
|
data/lib/nesta/models.rb
CHANGED
@@ -29,10 +29,12 @@ module Nesta
|
|
29
29
|
|
30
30
|
def self.load(path)
|
31
31
|
FORMATS.each do |format|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
[path, File.join(path, 'index')].each do |basename|
|
33
|
+
filename = model_path("#{basename}.#{format}")
|
34
|
+
if File.exist?(filename) && needs_loading?(path, filename)
|
35
|
+
@@cache[path] = self.new(filename)
|
36
|
+
break
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
@@cache[path]
|
@@ -54,17 +56,25 @@ module Nesta
|
|
54
56
|
@mtime = File.mtime(filename)
|
55
57
|
end
|
56
58
|
|
57
|
-
def
|
58
|
-
|
59
|
+
def index_page?
|
60
|
+
@filename =~ /\/?index\.\w+$/
|
61
|
+
end
|
62
|
+
|
63
|
+
def abspath
|
64
|
+
page_path = @filename.sub(Nesta::Config.page_path, '')
|
65
|
+
if index_page?
|
66
|
+
File.dirname(page_path)
|
67
|
+
else
|
68
|
+
File.join(File.dirname(page_path), File.basename(page_path, '.*'))
|
69
|
+
end
|
59
70
|
end
|
60
71
|
|
61
72
|
def path
|
62
|
-
abspath.sub(/^\//,
|
73
|
+
abspath.sub(/^\//, '')
|
63
74
|
end
|
64
75
|
|
65
|
-
def
|
66
|
-
|
67
|
-
File.join(prefix, permalink)
|
76
|
+
def permalink
|
77
|
+
File.basename(path)
|
68
78
|
end
|
69
79
|
|
70
80
|
def layout
|
@@ -149,16 +159,28 @@ module Nesta
|
|
149
159
|
|
150
160
|
def heading
|
151
161
|
regex = case @format
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
162
|
+
when :mdown
|
163
|
+
/^#\s*(.*)/
|
164
|
+
when :haml
|
165
|
+
/^\s*%h1\s+(.*)/
|
166
|
+
when :textile
|
167
|
+
/^\s*h1\.\s+(.*)/
|
168
|
+
end
|
159
169
|
markup =~ regex
|
160
170
|
Regexp.last_match(1)
|
161
171
|
end
|
172
|
+
|
173
|
+
def title
|
174
|
+
if metadata('title')
|
175
|
+
metadata('title')
|
176
|
+
elsif parent
|
177
|
+
"#{heading} - #{parent.heading}"
|
178
|
+
elsif heading
|
179
|
+
"#{heading} - #{Nesta::Config.title}"
|
180
|
+
elsif abspath == '/'
|
181
|
+
Nesta::Config.title
|
182
|
+
end
|
183
|
+
end
|
162
184
|
|
163
185
|
def date(format = nil)
|
164
186
|
@date ||= if metadata("date")
|
@@ -205,22 +227,44 @@ module Nesta
|
|
205
227
|
end
|
206
228
|
|
207
229
|
def categories
|
208
|
-
|
209
|
-
|
210
|
-
|
230
|
+
paths = category_strings.map { |specifier| specifier.sub(/:-?\d+$/, '') }
|
231
|
+
pages = valid_paths(paths).map { |p| Page.find_by_path(p) }
|
232
|
+
pages.sort do |x, y|
|
211
233
|
x.heading.downcase <=> y.heading.downcase
|
212
234
|
end
|
213
235
|
end
|
214
236
|
|
237
|
+
def priority(category)
|
238
|
+
category_string = category_strings.detect do |string|
|
239
|
+
string =~ /^#{category}([,:\s]|$)/
|
240
|
+
end
|
241
|
+
category_string && category_string.split(':', 2)[-1].to_i
|
242
|
+
end
|
243
|
+
|
215
244
|
def parent
|
216
|
-
|
245
|
+
if abspath == '/'
|
246
|
+
nil
|
247
|
+
else
|
248
|
+
parent_path = File.dirname(path)
|
249
|
+
while parent_path != '.' do
|
250
|
+
parent = Page.load(parent_path)
|
251
|
+
return parent unless parent.nil?
|
252
|
+
parent_path = File.dirname(parent_path)
|
253
|
+
end
|
254
|
+
Page.load('index')
|
255
|
+
end
|
217
256
|
end
|
218
257
|
|
219
258
|
def pages
|
220
259
|
Page.find_all.select do |page|
|
221
260
|
page.date.nil? && page.categories.include?(self)
|
222
261
|
end.sort do |x, y|
|
223
|
-
|
262
|
+
by_priority = y.priority(path) <=> x.priority(path)
|
263
|
+
if by_priority == 0
|
264
|
+
x.heading.downcase <=> y.heading.downcase
|
265
|
+
else
|
266
|
+
by_priority
|
267
|
+
end
|
224
268
|
end
|
225
269
|
end
|
226
270
|
|
@@ -229,10 +273,18 @@ module Nesta
|
|
229
273
|
end
|
230
274
|
|
231
275
|
private
|
276
|
+
def category_strings
|
277
|
+
strings = metadata('categories')
|
278
|
+
strings.nil? ? [] : strings.split(',').map { |string| string.strip }
|
279
|
+
end
|
280
|
+
|
232
281
|
def valid_paths(paths)
|
282
|
+
page_dir = Nesta::Config.page_path
|
233
283
|
paths.select do |path|
|
234
284
|
FORMATS.detect do |format|
|
235
|
-
File.
|
285
|
+
[path, File.join(path, 'index')].detect do |candidate|
|
286
|
+
File.exist?(File.join(page_dir, "#{candidate}.#{format}"))
|
287
|
+
end
|
236
288
|
end
|
237
289
|
end
|
238
290
|
end
|
data/lib/nesta/navigation.rb
CHANGED
@@ -14,16 +14,47 @@ module Nesta
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def display_menu_item(item, options = {})
|
17
|
-
|
18
|
-
if
|
19
|
-
|
20
|
-
|
17
|
+
if item.respond_to?(:each)
|
18
|
+
if (options[:levels] - 1) > 0
|
19
|
+
haml_tag :li do
|
20
|
+
display_menu(item, :levels => (options[:levels] - 1))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
haml_tag :li do
|
21
25
|
haml_tag :a, :href => item.abspath do
|
22
26
|
haml_concat item.heading
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
31
|
+
|
32
|
+
def breadcrumb_ancestors
|
33
|
+
ancestors = []
|
34
|
+
page = @page
|
35
|
+
while page
|
36
|
+
ancestors << page
|
37
|
+
page = page.parent
|
38
|
+
end
|
39
|
+
ancestors.reverse
|
40
|
+
end
|
41
|
+
|
42
|
+
def display_breadcrumbs(options = {})
|
43
|
+
haml_tag :ul, :class => options[:class] do
|
44
|
+
breadcrumb_ancestors[0...-1].each do |page|
|
45
|
+
haml_tag :li do
|
46
|
+
haml_tag :a, :href => page.abspath do
|
47
|
+
haml_concat breadcrumb_label(page)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
haml_tag(:li) { haml_concat breadcrumb_label(@page) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def breadcrumb_label(page)
|
56
|
+
(page.abspath == '/') ? 'Home' : page.heading
|
57
|
+
end
|
27
58
|
end
|
28
59
|
end
|
29
60
|
end
|
data/lib/nesta/version.rb
CHANGED
data/nesta.gemspec
CHANGED
@@ -31,7 +31,6 @@ EOF
|
|
31
31
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
32
32
|
s.require_paths = ["lib"]
|
33
33
|
|
34
|
-
s.add_dependency('builder', '~> 3.0')
|
35
34
|
s.add_dependency('haml', '~> 3.0')
|
36
35
|
s.add_dependency('maruku', '>= 0.6.0')
|
37
36
|
s.add_dependency('RedCloth', '~> 4.2')
|
data/spec/commands_spec.rb
CHANGED
@@ -44,6 +44,10 @@ describe "nesta" do
|
|
44
44
|
should_exist('content/pages')
|
45
45
|
end
|
46
46
|
|
47
|
+
it "should create the home page" do
|
48
|
+
should_exist('content/pages/index.haml')
|
49
|
+
end
|
50
|
+
|
47
51
|
it "should create the rackup file" do
|
48
52
|
should_exist('config.ru')
|
49
53
|
end
|
@@ -82,22 +86,6 @@ describe "nesta" do
|
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
|
-
describe "--heroku" do
|
86
|
-
before(:each) do
|
87
|
-
Nesta::Commands::New.new(@project_path, 'heroku' => '').execute
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should add heroku to Gemfile" do
|
91
|
-
gemfile_source.should match(/gem 'heroku'/)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should add the heroku:config Rake task" do
|
95
|
-
should_exist('Rakefile')
|
96
|
-
rakefile_source.should match(/namespace :heroku/)
|
97
|
-
rakefile_source.should match(/task :config/)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
89
|
describe "--vlad" do
|
102
90
|
before(:each) do
|
103
91
|
Nesta::Commands::New.new(@project_path, 'vlad' => '').execute
|