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/lib/nesta/navigation.rb
CHANGED
@@ -2,10 +2,10 @@ module Nesta
|
|
2
2
|
module Navigation
|
3
3
|
module Renderers
|
4
4
|
def display_menu(menu, options = {})
|
5
|
-
defaults = { :
|
5
|
+
defaults = { class: nil, levels: 2 }
|
6
6
|
options = defaults.merge(options)
|
7
7
|
if options[:levels] > 0
|
8
|
-
haml_tag :ul, :
|
8
|
+
haml_tag :ul, class: options[:class] do
|
9
9
|
menu.each do |item|
|
10
10
|
display_menu_item(item, options)
|
11
11
|
end
|
@@ -17,14 +17,14 @@ module Nesta
|
|
17
17
|
if item.respond_to?(:each)
|
18
18
|
if (options[:levels] - 1) > 0
|
19
19
|
haml_tag :li do
|
20
|
-
display_menu(item, :
|
20
|
+
display_menu(item, levels: (options[:levels] - 1))
|
21
21
|
end
|
22
22
|
end
|
23
23
|
else
|
24
|
-
html_class = (
|
25
|
-
haml_tag :li, :
|
26
|
-
haml_tag :a, :<, :
|
27
|
-
haml_concat item
|
24
|
+
html_class = current_item?(item) ? current_menu_item_class : nil
|
25
|
+
haml_tag :li, class: html_class do
|
26
|
+
haml_tag :a, :<, href: path_to(item.abspath) do
|
27
|
+
haml_concat link_text(item)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -41,20 +41,44 @@ module Nesta
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def display_breadcrumbs(options = {})
|
44
|
-
haml_tag :ul, :
|
44
|
+
haml_tag :ul, class: options[:class] do
|
45
45
|
breadcrumb_ancestors[0...-1].each do |page|
|
46
46
|
haml_tag :li do
|
47
|
-
haml_tag :a, :<, :
|
48
|
-
|
47
|
+
haml_tag :a, :<, href: path_to(page.abspath), itemprop: 'url' do
|
48
|
+
haml_tag :span, :<, itemprop: 'title' do
|
49
|
+
haml_concat link_text(page)
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
52
|
-
haml_tag(:li
|
54
|
+
haml_tag(:li, class: current_breadcrumb_class) do
|
55
|
+
haml_concat link_text(@page)
|
56
|
+
end
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
60
|
+
def link_text(page)
|
61
|
+
page.link_text
|
62
|
+
rescue LinkTextNotSet
|
63
|
+
return 'Home' if page.abspath == '/'
|
64
|
+
raise
|
65
|
+
end
|
66
|
+
|
56
67
|
def breadcrumb_label(page)
|
57
|
-
(
|
68
|
+
Nesta.deprecated('breadcrumb_label', 'use link_text')
|
69
|
+
link_text(page)
|
70
|
+
end
|
71
|
+
|
72
|
+
def current_item?(item)
|
73
|
+
request.path_info == item.abspath
|
74
|
+
end
|
75
|
+
|
76
|
+
def current_menu_item_class
|
77
|
+
'current'
|
78
|
+
end
|
79
|
+
|
80
|
+
def current_breadcrumb_class
|
81
|
+
nil
|
58
82
|
end
|
59
83
|
end
|
60
84
|
end
|
data/lib/nesta/overrides.rb
CHANGED
@@ -6,6 +6,11 @@ module Nesta
|
|
6
6
|
super(template, defaults.merge(options), locals)
|
7
7
|
end
|
8
8
|
|
9
|
+
def erb(template, options = {}, locals = {})
|
10
|
+
defaults, engine = Overrides.render_options(template, :erb)
|
11
|
+
super(template, defaults.merge(options), locals)
|
12
|
+
end
|
13
|
+
|
9
14
|
def scss(template, options = {}, locals = {})
|
10
15
|
defaults, engine = Overrides.render_options(template, :scss)
|
11
16
|
super(template, defaults.merge(options), locals)
|
@@ -24,15 +29,15 @@ module Nesta
|
|
24
29
|
end
|
25
30
|
|
26
31
|
def self.load_local_app
|
27
|
-
|
28
|
-
|
32
|
+
app_file = Nesta::Path.local('app.rb')
|
33
|
+
require app_file if File.exist?(app_file)
|
29
34
|
end
|
30
35
|
|
31
36
|
def self.load_theme_app
|
32
37
|
if Nesta::Config.theme
|
33
|
-
|
38
|
+
app_file = Nesta::Path.themes(Nesta::Config.theme, 'app.rb')
|
39
|
+
require app_file if File.exist?(app_file)
|
34
40
|
end
|
35
|
-
rescue LoadError
|
36
41
|
end
|
37
42
|
|
38
43
|
private
|
@@ -44,7 +49,7 @@ module Nesta
|
|
44
49
|
[local_view_path, theme_view_path].each do |path|
|
45
50
|
engines.each do |engine|
|
46
51
|
if template_exists?(engine, path, template)
|
47
|
-
return { :
|
52
|
+
return { views: path }, engine
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
data/lib/nesta/plugin.rb
CHANGED
@@ -17,17 +17,19 @@ module Nesta
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.load_local_plugins
|
20
|
+
# This approach is deprecated; plugins should now be distributed
|
21
|
+
# as gems. See http://nestacms.com/docs/plugins/writing-plugins
|
20
22
|
plugins = Dir.glob(File.expand_path('../plugins/*', File.dirname(__FILE__)))
|
21
23
|
plugins.each { |path| require_local_plugin(path) }
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def self.require_local_plugin(path)
|
27
|
+
Nesta.deprecated(
|
28
|
+
'loading plugins from ./plugins', "convert #{path} to a gem")
|
29
|
+
require File.join(path, 'lib', File.basename(path))
|
30
|
+
rescue LoadError => e
|
31
|
+
$stderr.write("Couldn't load plugins/#{File.basename(path)}: #{e}\n")
|
32
|
+
end
|
33
|
+
private_class_method :require_local_plugin
|
32
34
|
end
|
33
35
|
end
|
data/lib/nesta/version.rb
CHANGED
data/nesta.gemspec
CHANGED
@@ -24,26 +24,27 @@ Implementing your site's design is easy, but Nesta also has a small
|
|
24
24
|
selection of themes to choose from.
|
25
25
|
EOF
|
26
26
|
|
27
|
-
s.rubyforge_project = "nesta"
|
28
|
-
|
29
27
|
s.files = `git ls-files`.split("\n")
|
30
28
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
31
29
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
32
30
|
s.require_paths = ["lib"]
|
33
31
|
|
34
|
-
s.add_dependency('haml', '
|
35
|
-
s.add_dependency('
|
36
|
-
s.add_dependency('
|
32
|
+
s.add_dependency('haml', '>= 3.1')
|
33
|
+
s.add_dependency('haml-contrib', '>= 1.0')
|
34
|
+
s.add_dependency('rack', '~> 2.0')
|
35
|
+
s.add_dependency('rdiscount', '~> 2.1')
|
37
36
|
s.add_dependency('RedCloth', '~> 4.2')
|
38
|
-
s.add_dependency('
|
39
|
-
|
37
|
+
s.add_dependency('sassc', '>= 2.2')
|
38
|
+
s.add_dependency('sinatra', '~> 2.0')
|
39
|
+
s.add_dependency('tilt', '~> 2.0')
|
40
|
+
|
40
41
|
# Useful in development
|
41
|
-
s.
|
42
|
+
s.add_development_dependency('mr-sparkle')
|
42
43
|
|
43
44
|
# Test libraries
|
44
|
-
s.add_development_dependency('
|
45
|
-
s.add_development_dependency('
|
46
|
-
s.add_development_dependency('
|
47
|
-
s.add_development_dependency('
|
48
|
-
s.add_development_dependency('
|
45
|
+
s.add_development_dependency('byebug')
|
46
|
+
s.add_development_dependency('capybara', '~> 2.0')
|
47
|
+
s.add_development_dependency('minitest', '~> 5.0')
|
48
|
+
s.add_development_dependency('minitest-reporters')
|
49
|
+
s.add_development_dependency('rake')
|
49
50
|
end
|
data/templates/Gemfile
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'nesta'
|
4
|
-
<% if @options['heroku'] %>gem 'heroku'<% end %>
|
3
|
+
gem 'nesta'
|
5
4
|
<% if @options['vlad'] %>gem 'vlad', '2.1.0'
|
6
5
|
gem 'vlad-git', '2.2.0'<% end %>
|
7
6
|
|
8
|
-
|
7
|
+
group :development do
|
8
|
+
gem 'mr-sparkle'
|
9
|
+
end
|
10
|
+
|
11
|
+
# gem 'debugger'
|
data/templates/config.ru
CHANGED
data/templates/config/config.yml
CHANGED
@@ -8,7 +8,7 @@ subtitle: "(change this text in config/config.yml)"
|
|
8
8
|
# Atom feed. Specify at least one of name, uri or email, and Nesta will
|
9
9
|
# include it in your feed. See the Atom spec for more info:
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# https://tools.ietf.org/html/rfc4287#section-4.1.1
|
12
12
|
#
|
13
13
|
# author:
|
14
14
|
# name: Your Name
|
@@ -28,14 +28,6 @@ subtitle: "(change this text in config/config.yml)"
|
|
28
28
|
#
|
29
29
|
# disqus_short_name: mysite
|
30
30
|
|
31
|
-
# cache
|
32
|
-
# Set it to true if you'd like Nesta to cache your pages in ./public.
|
33
|
-
# Useful if you're deploying Nesta with a proxy server such as Nginx,
|
34
|
-
# but not in the least bit helpful if your pages are dynamic, or you're
|
35
|
-
# deploying Nesta to Heroku.
|
36
|
-
#
|
37
|
-
cache: false
|
38
|
-
|
39
31
|
# content
|
40
32
|
# The root directory where nesta will look for your article files.
|
41
33
|
# Should contain "pages" and "attachments" subdirectories that contain
|
@@ -54,14 +46,22 @@ content: content
|
|
54
46
|
#
|
55
47
|
# google_analytics_code: "UA-???????-?"
|
56
48
|
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
49
|
+
# read_more
|
50
|
+
# When the summary of an article is displayed on the home page, or
|
51
|
+
# on a category page, there is a link underneath the summary that
|
52
|
+
# points to the rest of the post. Use this value to customize the
|
53
|
+
# default link text. You can still override this value on a per-page
|
54
|
+
# basis with the 'Read more' metadata key.
|
55
|
+
#
|
56
|
+
# read_more: "Continue reading"
|
57
|
+
|
58
|
+
# Overriding "content" in production is recommended if you're deploying
|
59
|
+
# Nesta to your own server (but see the deployment documentation on the
|
60
|
+
# Nesta site). Setting google_analytics_code in production is recommended
|
61
|
+
# regardless of how you're deploying (if you have a GA # account!).
|
61
62
|
#
|
62
63
|
# Don't forget to uncomment the "production:" line too...
|
63
64
|
|
64
65
|
# production:
|
65
|
-
# cache: true
|
66
66
|
# content: /var/apps/nesta/shared/content
|
67
67
|
# google_analytics_code: "UA-???????-?"
|
data/templates/config/deploy.rb
CHANGED
@@ -38,10 +38,10 @@ namespace :vlad do
|
|
38
38
|
# using a different app server in the call to Vlad.load in Rakefile.
|
39
39
|
#
|
40
40
|
desc "Deploy the code and restart the server"
|
41
|
-
task :
|
41
|
+
task deploy: [:update, :start_app]
|
42
42
|
|
43
43
|
# If you use bundler to manage the installation of gems on your server
|
44
44
|
# you can use this definition of the deploy task instead:
|
45
45
|
#
|
46
|
-
# task :
|
46
|
+
# task deploy: [:update, :bundle, :start_app]
|
47
47
|
end
|
data/templates/index.haml
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
README
|
2
|
+
======
|
3
|
+
|
4
|
+
TODO: Explain what your plugin is for
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
To use this plugin just add it to your Nesta project's `Gemfile` and
|
10
|
+
then install it with Bundler:
|
11
|
+
|
12
|
+
$ echo 'gem "<%= @gem_name %>"' >> Gemfile
|
13
|
+
$ bundle
|
@@ -0,0 +1,58 @@
|
|
1
|
+
def version
|
2
|
+
version_file = File.join(File.dirname(__FILE__), "lib", name, "version.rb")
|
3
|
+
contents = File.read(version_file)
|
4
|
+
contents.match(/VERSION = ['"]([0-9a-z.-]+)['"].*$/)
|
5
|
+
$1
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
"<%= @gem_name %>"
|
10
|
+
end
|
11
|
+
|
12
|
+
def built_gem_path
|
13
|
+
gem_packages = File.join(File.dirname(__FILE__), "pkg", "#{name}-*.gem")
|
14
|
+
Dir[gem_packages].sort_by { |file| File.mtime(file) }.last
|
15
|
+
end
|
16
|
+
|
17
|
+
def already_tagged?
|
18
|
+
`git tag`.split(/\n/).include?("v#{version}")
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Build #{name}-#{version}.gem into the pkg directory."
|
22
|
+
task 'build' do
|
23
|
+
`gem build -V #{File.join(File.dirname(__FILE__), "#{name}.gemspec")}`
|
24
|
+
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "pkg"))
|
25
|
+
gem = Dir[File.join(File.dirname(__FILE__), "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
|
26
|
+
FileUtils.mv(gem, 'pkg')
|
27
|
+
puts "#{name} #{version} built to #{built_gem_path}."
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Build and install #{name}-#{version}.gem into system gems."
|
31
|
+
task 'install' => 'build' do
|
32
|
+
`gem install '#{built_gem_path}' --local`
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Create tag v#{version} and build and push #{name}-#{version}.gem to Rubygems\n" \
|
36
|
+
"To prevent publishing in Rubygems use `gem_push=no rake release`"
|
37
|
+
task 'release' => ['build', 'release:guard_clean',
|
38
|
+
'release:source_control_push', 'release:rubygem_push'] do
|
39
|
+
end
|
40
|
+
|
41
|
+
task 'release:guard_clean' do
|
42
|
+
if !system("git diff --exit-code") || !system("git diff-index --quiet --cached HEAD")
|
43
|
+
puts "There are files that need to be committed first."
|
44
|
+
exit(1)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
task 'release:source_control_push' do
|
49
|
+
unless already_tagged?
|
50
|
+
system "git tag -a -m 'Version #{version}' v#{version}"
|
51
|
+
system 'git push'
|
52
|
+
system 'git push --tags'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
task 'release:rubygem_push' do
|
57
|
+
system "gem push #{built_gem_path}"
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "<%= @gem_name %>/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "<%= @gem_name %>"
|
8
|
+
spec.version = Nesta::Plugin::<%= module_name %>::VERSION
|
9
|
+
spec.authors = ["TODO: Your name"]
|
10
|
+
spec.email = ["TODO: Your email address"]
|
11
|
+
spec.homepage = ""
|
12
|
+
spec.summary = %q{TODO: Write a gem summary}
|
13
|
+
spec.description = %q{TODO: Write a gem description}
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.rubyforge_project = "<%= @gem_name %>"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# spec.add_development_dependency "rspec"
|
25
|
+
# spec.add_runtime_dependency "rest-client"
|
26
|
+
spec.add_dependency("nesta", ">= 0.9.11")
|
27
|
+
spec.add_development_dependency("rake")
|
28
|
+
end
|
data/templates/themes/README.md
CHANGED
data/templates/themes/app.rb
CHANGED
@@ -8,7 +8,7 @@ module Nesta
|
|
8
8
|
#
|
9
9
|
# Put your assets in themes/<%= @name %>/public/<%= @name %>.
|
10
10
|
#
|
11
|
-
# use Rack::Static, :
|
11
|
+
# use Rack::Static, urls: ["/<%= @name %>"], root: "themes/<%= @name %>/public"
|
12
12
|
|
13
13
|
helpers do
|
14
14
|
# Add new helpers here.
|