nesta 0.9.11 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -11
- data/.gitmodules +6 -0
- data/.hound.yml +2 -0
- data/{spec/spec.opts → .rspec} +0 -0
- data/.travis.yml +11 -0
- data/CHANGES +250 -2
- data/Gemfile +2 -2
- data/Gemfile.lock +89 -33
- data/Guardfile +7 -0
- data/LICENSE +1 -1
- data/README.md +38 -6
- data/RELEASING.md +21 -0
- data/Rakefile +20 -4
- data/bin/nesta +131 -14
- data/config.ru +3 -0
- data/lib/nesta.rb +9 -1
- data/lib/nesta/app.rb +21 -107
- data/lib/nesta/commands.rb +5 -256
- data/lib/nesta/commands/command.rb +57 -0
- data/lib/nesta/commands/demo.rb +1 -0
- data/lib/nesta/commands/demo/content.rb +56 -0
- data/lib/nesta/commands/edit.rb +21 -0
- data/lib/nesta/commands/new.rb +57 -0
- data/lib/nesta/commands/plugin.rb +1 -0
- data/lib/nesta/commands/plugin/create.rb +82 -0
- data/lib/nesta/commands/theme.rb +3 -0
- data/lib/nesta/commands/theme/create.rb +36 -0
- data/lib/nesta/commands/theme/enable.rb +22 -0
- data/lib/nesta/commands/theme/install.rb +31 -0
- data/lib/nesta/config.rb +51 -22
- data/lib/nesta/helpers.rb +115 -0
- data/lib/nesta/models.rb +111 -70
- data/lib/nesta/navigation.rb +36 -12
- data/lib/nesta/overrides.rb +10 -5
- data/lib/nesta/plugin.rb +10 -8
- data/lib/nesta/version.rb +1 -1
- data/nesta.gemspec +14 -13
- data/templates/Gemfile +6 -3
- data/templates/config.ru +3 -0
- data/templates/config/config.yml +14 -14
- data/templates/config/deploy.rb +2 -2
- data/templates/index.haml +2 -0
- data/templates/plugins/Gemfile +4 -0
- data/templates/plugins/README.md +13 -0
- data/templates/plugins/Rakefile +58 -0
- data/templates/plugins/gitignore +3 -0
- data/templates/plugins/lib/init.rb +13 -0
- data/templates/plugins/lib/required.rb +3 -0
- data/templates/plugins/lib/version.rb +5 -0
- data/templates/plugins/plugin.gemspec +28 -0
- data/templates/themes/README.md +1 -1
- 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/{spec → test}/fixtures/nesta-plugin-test/Gemfile +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/Rakefile +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +1 -3
- data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
- data/{spec → test}/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +0 -0
- data/test/integration/atom_feed_test.rb +178 -0
- data/test/integration/commands/demo/content_test.rb +31 -0
- data/test/integration/commands/edit_test.rb +21 -0
- data/test/integration/commands/new_test.rb +120 -0
- data/test/integration/commands/plugin/create_test.rb +128 -0
- data/test/integration/commands/theme/create_test.rb +35 -0
- data/test/integration/commands/theme/enable_test.rb +22 -0
- data/test/integration/commands/theme/install_test.rb +62 -0
- data/test/integration/default_theme_test.rb +220 -0
- data/test/integration/overrides_test.rb +118 -0
- data/test/integration/route_handlers_test.rb +96 -0
- data/test/integration/sitemap_test.rb +85 -0
- data/test/integration_test_helper.rb +61 -0
- data/test/support/model_factory.rb +169 -0
- data/test/support/silence_commands_during_tests.rb +5 -0
- data/test/support/temporary_files.rb +33 -0
- data/test/support/test_configuration.rb +19 -0
- data/test/test_helper.rb +26 -0
- data/test/unit/commands_test.rb +23 -0
- data/test/unit/config_test.rb +138 -0
- data/test/unit/file_model_test.rb +71 -0
- data/test/unit/menu_test.rb +82 -0
- data/test/unit/page_test.rb +571 -0
- data/test/unit/path_test.rb +41 -0
- data/test/unit/plugin_test.rb +47 -0
- data/views/analytics.haml +9 -10
- data/views/atom.haml +4 -4
- 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 +144 -134
- 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 +258 -232
- data/lib/nesta/cache.rb +0 -139
- data/lib/nesta/nesta.rb +0 -7
- data/spec/atom_spec.rb +0 -138
- data/spec/commands_spec.rb +0 -364
- data/spec/config_spec.rb +0 -67
- data/spec/model_factory.rb +0 -92
- data/spec/models_spec.rb +0 -588
- data/spec/overrides_spec.rb +0 -132
- data/spec/page_spec.rb +0 -498
- data/spec/path_spec.rb +0 -28
- data/spec/plugin_spec.rb +0 -51
- data/spec/sitemap_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -76
data/Guardfile
ADDED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -31,12 +31,44 @@ You'll find basic configuration options for your site in
|
|
31
31
|
before you go very far.
|
32
32
|
|
33
33
|
That's it - you can launch a local web server in development mode using
|
34
|
-
|
34
|
+
mr-sparkle...
|
35
35
|
|
36
|
-
$ bundle exec
|
36
|
+
$ bundle exec mr-sparkle config.ru
|
37
37
|
|
38
|
-
...then point your web browser at http://localhost:
|
39
|
-
the files in `content/pages` (see the [
|
40
|
-
|
38
|
+
...then point your web browser at http://localhost:8080. Start editing
|
39
|
+
the files in `content/pages` (see the [docs on writing content][] for
|
40
|
+
full instructions).
|
41
41
|
|
42
|
-
[content]: http://nestacms.com/docs/creating-content
|
42
|
+
[docs on writing content]: http://nestacms.com/docs/creating-content
|
43
|
+
|
44
|
+
## Support
|
45
|
+
|
46
|
+
There's plenty of information on <http://nestacms.com>. If you need some
|
47
|
+
help with anything just jump on the [mailing list][] and ask.
|
48
|
+
|
49
|
+
[mailing list]: http://nestacms.com/support
|
50
|
+
|
51
|
+
If you like Nesta you can keep up with developments by following [@nestacms][]
|
52
|
+
on Twitter, and on [the blog][].
|
53
|
+
|
54
|
+
[@nestacms]: http://twitter.com/nestacms
|
55
|
+
[the blog]: http://nestacms.com/blog
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
If you want to add a new feature, I recommend that you post a quick
|
60
|
+
message to the [mailing list][] before you start coding. I'm likely to
|
61
|
+
suggest that we implement it as a [plugin][] (to keep Nesta itself lean
|
62
|
+
and simple), so you might save yourself some time if we chat about a
|
63
|
+
good approach before you start.
|
64
|
+
|
65
|
+
[plugin]: http://nestacms.com/docs/plugins
|
66
|
+
|
67
|
+
If you think you've found a bug, please bring that up on the [mailing
|
68
|
+
list][] too, rather than creating an issue on GitHub straight away.
|
69
|
+
You'll probably get a faster response on the mailing list, as I'm the
|
70
|
+
only person who'll see your new issue.
|
71
|
+
|
72
|
+
-- Graham ([@grahamashton][] on Twitter).
|
73
|
+
|
74
|
+
[@grahamashton]: http://twitter.com/grahamashton
|
data/RELEASING.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Releasing Nesta
|
2
|
+
|
3
|
+
When it comes time to release a new version of the Nesta gem, these are
|
4
|
+
the steps:
|
5
|
+
|
6
|
+
1. Bump the version number in `lib/nesta/version.rb`. This will cause
|
7
|
+
the version number in `Gemfile.lock` to be updated too, so regenerate
|
8
|
+
it now and check them in together.
|
9
|
+
|
10
|
+
2. Update the `CHANGES` file with a summary of significant changes since
|
11
|
+
the previous release.
|
12
|
+
|
13
|
+
3. Check the versions of Ruby used in `.travis.yml` are up to date. If new
|
14
|
+
Ruby versions need testing, update the config and re-run the Travis build.
|
15
|
+
|
16
|
+
4. Generate a new site with the `nesta` command, install the demo content,
|
17
|
+
check that it runs okay locally.
|
18
|
+
|
19
|
+
5. If everything seems fine, run `rake release`.
|
20
|
+
|
21
|
+
6. Publish an announcement blog post and email the list.
|
data/Rakefile
CHANGED
@@ -3,10 +3,26 @@ require "bundler/setup"
|
|
3
3
|
|
4
4
|
Bundler.require(:default, :test)
|
5
5
|
|
6
|
-
require "spec/rake/spectask"
|
7
6
|
Bundler::GemHelper.install_tasks
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
namespace :test do
|
9
|
+
task :set_load_path do
|
10
|
+
$LOAD_PATH.unshift File.expand_path('test')
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_tests(directory)
|
14
|
+
Rake::FileList["test/#{directory}/*_test.rb"].each { |f| require_relative f }
|
15
|
+
end
|
16
|
+
|
17
|
+
task units: :set_load_path do
|
18
|
+
load_tests('unit')
|
19
|
+
end
|
20
|
+
|
21
|
+
task integrations: :set_load_path do
|
22
|
+
load_tests('integration')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task test: 'test:set_load_path' do
|
27
|
+
load_tests('**')
|
12
28
|
end
|
data/bin/nesta
CHANGED
@@ -13,9 +13,12 @@ USAGE: #{File.basename($0)} [GLOBAL OPTIONS]
|
|
13
13
|
GLOBAL OPTIONS
|
14
14
|
--help, -h Display this message.
|
15
15
|
--version, -v Display version number.
|
16
|
+
--bash-completion Output command completion setup for Bash.
|
17
|
+
--zsh-completion Output command completion setup for Zsh.
|
16
18
|
|
17
19
|
COMMANDS
|
18
20
|
new <path> Create a new Nesta project.
|
21
|
+
edit <path> Edit a document (path relative to content/pages).
|
19
22
|
demo:content Install example pages in ./content-demo.
|
20
23
|
plugin:create <name> Create a gem called nesta-plugin-name.
|
21
24
|
theme:install <url> Install a theme from a git repository.
|
@@ -37,18 +40,24 @@ EOF
|
|
37
40
|
|
38
41
|
def self.parse_command_line
|
39
42
|
opts = GetoptLong.new(
|
43
|
+
['--bash-completion', GetoptLong::NO_ARGUMENT],
|
40
44
|
['--git', GetoptLong::NO_ARGUMENT],
|
41
45
|
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
42
46
|
['--version', '-v', GetoptLong::NO_ARGUMENT],
|
43
|
-
['--vlad', GetoptLong::NO_ARGUMENT]
|
47
|
+
['--vlad', GetoptLong::NO_ARGUMENT],
|
48
|
+
['--zsh-completion', GetoptLong::NO_ARGUMENT]
|
44
49
|
)
|
45
50
|
options = {}
|
46
51
|
opts.each do |opt, arg|
|
47
|
-
case opt
|
52
|
+
case opt
|
53
|
+
when '--bash-completion'
|
54
|
+
bash_completion
|
48
55
|
when '--help'
|
49
56
|
usage(exitcode=0)
|
50
57
|
when '--version'
|
51
58
|
version
|
59
|
+
when '--zsh-completion'
|
60
|
+
zsh_completion
|
52
61
|
else
|
53
62
|
options[opt.sub(/^--/, '')] = arg
|
54
63
|
end
|
@@ -59,21 +68,30 @@ EOF
|
|
59
68
|
usage
|
60
69
|
end
|
61
70
|
|
71
|
+
def self.require_bundled_gems
|
72
|
+
if File.exist?('Gemfile')
|
73
|
+
require 'bundler'
|
74
|
+
Bundler.setup(:default)
|
75
|
+
Bundler.require(:default)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.class_for_command(command)
|
80
|
+
const_names = command.split(':').map { |word| word.capitalize }
|
81
|
+
const_names.inject(Nesta::Commands) do |namespace, const|
|
82
|
+
namespace.const_get(const)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
62
86
|
def self.main(options)
|
63
87
|
command = ARGV.shift
|
64
88
|
command.nil? && usage
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
Nesta::Commands::Plugin::Create.new(ARGV[0]).execute
|
72
|
-
when /^theme:(create|enable|install)$/
|
73
|
-
command_cls = Nesta::Commands::Theme.const_get($1.capitalize.to_sym)
|
74
|
-
command_cls.new(ARGV[0], options).execute
|
75
|
-
else
|
76
|
-
usage(exitcode=0)
|
89
|
+
begin
|
90
|
+
command_cls = class_for_command(command)
|
91
|
+
rescue NameError
|
92
|
+
usage
|
93
|
+
else
|
94
|
+
command_cls.new(ARGV[0], options).execute
|
77
95
|
end
|
78
96
|
rescue RuntimeError => e
|
79
97
|
$stderr.puts "ERROR: #{e}"
|
@@ -82,7 +100,106 @@ EOF
|
|
82
100
|
$stderr.puts "ERROR: #{e}"
|
83
101
|
usage
|
84
102
|
end
|
103
|
+
|
104
|
+
def self.bash_completion
|
105
|
+
puts <<-EOF
|
106
|
+
# Bash completion configuration for the nesta command.
|
107
|
+
#
|
108
|
+
# Install it with these commands:
|
109
|
+
#
|
110
|
+
# $ nesta --bash-completion > ~/.nesta-completion.sh
|
111
|
+
# $ echo '[ -f ~/.nesta-completion.sh ] && source ~/.nesta-completion.sh' \
|
112
|
+
# >> ~/.bash_profile
|
113
|
+
# $ source ~/.nesta-completion.sh
|
114
|
+
|
115
|
+
_nesta() {
|
116
|
+
local cur prev opts pages
|
117
|
+
COMPREPLY=()
|
118
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
119
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
120
|
+
|
121
|
+
opts="new 'demo:content' edit 'plugin:create' 'theme:install' 'theme:enable' 'theme:create'"
|
122
|
+
|
123
|
+
case "${cur}" in
|
124
|
+
theme:*)
|
125
|
+
COMPREPLY=( $(compgen -W "enable install" -- ${cur##*:}) )
|
126
|
+
return 0
|
127
|
+
;;
|
128
|
+
esac
|
129
|
+
|
130
|
+
case "${prev}" in
|
131
|
+
edit)
|
132
|
+
local pages_path="content/pages"
|
133
|
+
local pages="$(find $pages_path -type f | sed s,$pages_path/,,)"
|
134
|
+
COMPREPLY=( $(compgen -W "$pages" -- $cur) )
|
135
|
+
return 0
|
136
|
+
;;
|
137
|
+
*)
|
138
|
+
;;
|
139
|
+
esac
|
140
|
+
|
141
|
+
COMPREPLY=( $(compgen -W "$opts" -- $cur) )
|
142
|
+
return 0
|
143
|
+
}
|
144
|
+
complete -F _nesta nesta
|
145
|
+
EOF
|
146
|
+
exit 0
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.zsh_completion
|
150
|
+
puts <<-EOF
|
151
|
+
# Zsh completion configuration for the nesta command.
|
152
|
+
#
|
153
|
+
# Install it with these commands:
|
154
|
+
#
|
155
|
+
# $ nesta --zsh-completion > <somewhere/in/your/$fpath>/nesta-completion.sh
|
156
|
+
#
|
157
|
+
# Source form somewhere in your $fpath
|
158
|
+
|
159
|
+
#compdef nesta
|
160
|
+
|
161
|
+
|
162
|
+
_nesta_content() {
|
163
|
+
content=(`ls content/pages/**/*`)
|
164
|
+
}
|
165
|
+
|
166
|
+
|
167
|
+
local -a _1st_arguments
|
168
|
+
_1st_arguments=(
|
169
|
+
'new:Create a new Nesta project'
|
170
|
+
'edit:Edit a document'
|
171
|
+
'demo\:content:Install example pages in ./content-demo'
|
172
|
+
'theme\:install:Install a theme from a git repository'
|
173
|
+
'theme\:enable:Make the theme active, updating config.yml'
|
174
|
+
'theme\:create:Makes a template for a new theme in ./themes'
|
175
|
+
)
|
176
|
+
|
177
|
+
local expl
|
178
|
+
local -a content
|
179
|
+
|
180
|
+
_arguments \
|
181
|
+
'(-h)'{-h,--help}'[Display usage]' \
|
182
|
+
'(-v)'{-v,--version}'[Display Nesta version]' \
|
183
|
+
'(--bash-completion)--bash-completion[Output command for Bash completion]' \
|
184
|
+
'(--zsh-completion)--zsh-completion[Output command for Zsh completion]' \
|
185
|
+
'*:: :->subcmds' && return 0
|
186
|
+
|
187
|
+
if (( CURRENT == 1 )); then
|
188
|
+
_describe -t commands "nesta subcommand" _1st_arguments
|
189
|
+
return
|
190
|
+
fi
|
191
|
+
|
192
|
+
case "$words[1]" in
|
193
|
+
edit)
|
194
|
+
_nesta_content
|
195
|
+
_wanted content expl 'all content' compadd -a content ;;
|
196
|
+
esac
|
197
|
+
EOF
|
198
|
+
exit 0
|
199
|
+
end
|
85
200
|
end
|
86
201
|
end
|
87
202
|
|
203
|
+
Nesta::Cli.require_bundled_gems
|
204
|
+
Nesta::Plugin.initialize_plugins
|
88
205
|
Nesta::Cli.main(Nesta::Cli.parse_command_line)
|
data/config.ru
CHANGED
@@ -4,7 +4,10 @@ require 'bundler/setup'
|
|
4
4
|
Bundler.require(:default)
|
5
5
|
|
6
6
|
$LOAD_PATH.unshift(::File.expand_path('lib', ::File.dirname(__FILE__)))
|
7
|
+
|
7
8
|
require 'nesta/env'
|
9
|
+
Nesta::Env.root = ::File.expand_path('.', ::File.dirname(__FILE__))
|
10
|
+
|
8
11
|
require 'nesta/app'
|
9
12
|
|
10
13
|
run Nesta::App
|
data/lib/nesta.rb
CHANGED
data/lib/nesta/app.rb
CHANGED
@@ -1,114 +1,31 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'haml'
|
3
|
-
require '
|
3
|
+
require 'sassc'
|
4
4
|
|
5
|
+
require File.expand_path('../nesta', File.dirname(__FILE__))
|
5
6
|
require File.expand_path('env', File.dirname(__FILE__))
|
6
|
-
require File.expand_path('nesta', File.dirname(__FILE__))
|
7
|
-
require File.expand_path('cache', File.dirname(__FILE__))
|
8
7
|
require File.expand_path('config', File.dirname(__FILE__))
|
9
8
|
require File.expand_path('models', File.dirname(__FILE__))
|
9
|
+
require File.expand_path('helpers', File.dirname(__FILE__))
|
10
10
|
require File.expand_path('navigation', File.dirname(__FILE__))
|
11
11
|
require File.expand_path('overrides', File.dirname(__FILE__))
|
12
12
|
require File.expand_path('path', File.dirname(__FILE__))
|
13
|
-
require File.expand_path('plugin', File.dirname(__FILE__))
|
14
13
|
|
15
14
|
Encoding.default_external = 'utf-8' if RUBY_VERSION =~ /^1.9/
|
16
15
|
|
17
16
|
module Nesta
|
18
17
|
class App < Sinatra::Base
|
19
|
-
register Sinatra::Cache
|
20
|
-
|
21
18
|
set :root, Nesta::Env.root
|
22
19
|
set :views, File.expand_path('../../views', File.dirname(__FILE__))
|
23
|
-
set :
|
24
|
-
set :haml, { :format => :html5 }
|
20
|
+
set :haml, { format: :html5 }
|
25
21
|
|
26
22
|
helpers Overrides::Renderers
|
27
23
|
helpers Navigation::Renderers
|
28
|
-
|
29
|
-
helpers do
|
30
|
-
def set_from_config(*variables)
|
31
|
-
variables.each do |var|
|
32
|
-
instance_variable_set("@#{var}", Nesta::Config.send(var))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_from_page(*variables)
|
37
|
-
variables.each do |var|
|
38
|
-
instance_variable_set("@#{var}", @page.send(var))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def no_widow(text)
|
43
|
-
text.split[0...-1].join(" ") + " #{text.split[-1]}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def set_common_variables
|
47
|
-
@menu_items = Nesta::Menu.for_path('/')
|
48
|
-
@site_title = Nesta::Config.title
|
49
|
-
set_from_config(:title, :subtitle, :google_analytics_code)
|
50
|
-
@heading = @title
|
51
|
-
end
|
52
|
-
|
53
|
-
def url_for(page)
|
54
|
-
File.join(base_url, page.path)
|
55
|
-
end
|
56
|
-
|
57
|
-
def base_url
|
58
|
-
url = "http://#{request.host}"
|
59
|
-
request.port == 80 ? url : url + ":#{request.port}"
|
60
|
-
end
|
61
|
-
|
62
|
-
def absolute_urls(text)
|
63
|
-
text.gsub!(/(<a href=['"])\//, '\1' + base_url + '/')
|
64
|
-
text
|
65
|
-
end
|
66
|
-
|
67
|
-
def nesta_atom_id_for_page(page)
|
68
|
-
published = page.date.strftime('%Y-%m-%d')
|
69
|
-
"tag:#{request.host},#{published}:#{page.abspath}"
|
70
|
-
end
|
71
|
-
|
72
|
-
def atom_id(page = nil)
|
73
|
-
if page
|
74
|
-
page.atom_id || nesta_atom_id_for_page(page)
|
75
|
-
else
|
76
|
-
"tag:#{request.host},2009:/"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def format_date(date)
|
81
|
-
date.strftime("%d %B %Y")
|
82
|
-
end
|
83
|
-
|
84
|
-
def local_stylesheet?
|
85
|
-
Nesta.deprecated('local_stylesheet?', 'use local_stylesheet_link_tag')
|
86
|
-
File.exist?(File.expand_path('views/local.sass', Nesta::App.root))
|
87
|
-
end
|
88
|
-
|
89
|
-
def local_stylesheet_link_tag(name)
|
90
|
-
pattern = File.expand_path("views/#{name}.s{a,c}ss", Nesta::App.root)
|
91
|
-
if Dir.glob(pattern).size > 0
|
92
|
-
haml_tag :link, :href => "/css/#{name}.css", :rel => "stylesheet"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def latest_articles(count = 8)
|
97
|
-
Nesta::Page.find_articles[0..count - 1]
|
98
|
-
end
|
99
|
-
|
100
|
-
def article_summaries(articles)
|
101
|
-
haml(:summaries, :layout => false, :locals => { :pages => articles })
|
102
|
-
end
|
103
|
-
|
104
|
-
def articles_heading
|
105
|
-
@page.metadata('articles heading') || "Articles on #{@page.heading}"
|
106
|
-
end
|
107
|
-
end
|
24
|
+
helpers View::Helpers
|
108
25
|
|
109
26
|
before do
|
110
|
-
if request.
|
111
|
-
redirect to(request.
|
27
|
+
if request.path_info =~ Regexp.new('./$')
|
28
|
+
redirect to(request.path_info.sub(Regexp.new('/$'), ''))
|
112
29
|
end
|
113
30
|
end
|
114
31
|
|
@@ -126,7 +43,7 @@ module Nesta
|
|
126
43
|
Overrides.load_theme_app
|
127
44
|
|
128
45
|
get '/robots.txt' do
|
129
|
-
content_type 'text/plain', :
|
46
|
+
content_type 'text/plain', charset: 'utf-8'
|
130
47
|
<<-EOF
|
131
48
|
# robots.txt
|
132
49
|
# See http://en.wikipedia.org/wiki/Robots_exclusion_standard
|
@@ -134,44 +51,41 @@ module Nesta
|
|
134
51
|
end
|
135
52
|
|
136
53
|
get '/css/:sheet.css' do
|
137
|
-
content_type 'text/css', :
|
138
|
-
|
54
|
+
content_type 'text/css', charset: 'utf-8'
|
55
|
+
stylesheet(params[:sheet].to_sym)
|
139
56
|
end
|
140
57
|
|
141
|
-
get
|
142
|
-
|
143
|
-
|
144
|
-
not_found
|
145
|
-
else
|
146
|
-
send_file(file, :disposition => nil)
|
147
|
-
end
|
58
|
+
get '/attachments/*' do |path|
|
59
|
+
filename = File.join(Nesta::Config.attachment_path, path)
|
60
|
+
send_file(filename, disposition: nil)
|
148
61
|
end
|
149
62
|
|
150
63
|
get '/articles.xml' do
|
151
|
-
content_type :xml, :
|
64
|
+
content_type :xml, charset: 'utf-8'
|
152
65
|
set_from_config(:title, :subtitle, :author)
|
153
66
|
@articles = Page.find_articles.select { |a| a.date }[0..9]
|
154
|
-
|
67
|
+
haml(:atom, format: :xhtml, layout: false)
|
155
68
|
end
|
156
69
|
|
157
70
|
get '/sitemap.xml' do
|
158
|
-
content_type :xml, :
|
159
|
-
@pages = Page.find_all
|
71
|
+
content_type :xml, charset: 'utf-8'
|
72
|
+
@pages = Page.find_all.reject do |page|
|
73
|
+
page.draft? or page.flagged_as?('skip-sitemap')
|
74
|
+
end
|
160
75
|
@last = @pages.map { |page| page.last_modified }.inject do |latest, page|
|
161
76
|
(page > latest) ? page : latest
|
162
77
|
end
|
163
|
-
|
78
|
+
haml(:sitemap, format: :xhtml, layout: false)
|
164
79
|
end
|
165
80
|
|
166
81
|
get '*' do
|
167
82
|
set_common_variables
|
168
|
-
@heading = @title
|
169
83
|
parts = params[:splat].map { |p| p.sub(/\/$/, '') }
|
170
84
|
@page = Nesta::Page.find_by_path(File.join(parts))
|
171
85
|
raise Sinatra::NotFound if @page.nil?
|
172
86
|
@title = @page.title
|
173
87
|
set_from_page(:description, :keywords)
|
174
|
-
|
88
|
+
haml(@page.template, layout: @page.layout)
|
175
89
|
end
|
176
90
|
end
|
177
91
|
end
|