nesta 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +1 -1
- data/.gitignore +1 -0
- data/CHANGES +73 -0
- data/Gemfile.lock +24 -22
- data/README.md +4 -2
- data/bin/nesta +4 -1
- data/lib/nesta/app.rb +1 -2
- data/lib/nesta/commands/build.rb +38 -0
- data/lib/nesta/commands/new.rb +2 -1
- data/lib/nesta/commands.rb +1 -0
- data/lib/nesta/config.rb +49 -75
- data/lib/nesta/config_file.rb +5 -1
- data/lib/nesta/helpers.rb +0 -5
- data/lib/nesta/models.rb +33 -34
- data/lib/nesta/navigation.rb +0 -5
- data/lib/nesta/overrides.rb +32 -43
- data/lib/nesta/plugin.rb +0 -16
- data/lib/nesta/static/assets.rb +50 -0
- data/lib/nesta/static/html_file.rb +26 -0
- data/lib/nesta/static/site.rb +104 -0
- data/lib/nesta/version.rb +1 -1
- data/lib/nesta.rb +1 -3
- data/nesta.gemspec +4 -4
- data/templates/config/config.yml +28 -2
- data/templates/themes/README.md +1 -1
- data/templates/themes/views/master.sass +1 -1
- data/test/integration/atom_feed_test.rb +1 -1
- data/test/integration/commands/build_test.rb +53 -0
- data/test/integration/overrides_test.rb +1 -1
- data/test/integration/sitemap_test.rb +1 -1
- data/test/support/temporary_files.rb +1 -1
- data/test/support/test_configuration.rb +2 -4
- data/test/unit/config_test.rb +25 -94
- data/test/unit/static/assets_test.rb +56 -0
- data/test/unit/static/html_file_test.rb +41 -0
- data/test/unit/static/site_test.rb +104 -0
- data/views/atom.haml +2 -2
- data/views/comments.haml +2 -2
- data/views/footer.haml +1 -1
- data/views/header.haml +2 -3
- data/views/layout.haml +2 -2
- data/views/master.sass +1 -1
- data/views/mixins.sass +2 -2
- data/views/normalize.scss +0 -1
- data/views/sitemap.haml +1 -1
- metadata +33 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e14e3ed99700277225c068df787864f52f19385f08469d91bf1a8f4073e24568
|
4
|
+
data.tar.gz: 84e9c0fb31ba8b380b0ce86f9edc6f660fd8a8f9474ad28400e7c921fd745c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e39c4ada00a1ac3b4be18b6887240a670d4f1c050023771dc71fa6703bbb315bac54f959053788dc7018761a5bfc3e1fe387486e856629a785ae3098c8203704
|
7
|
+
data.tar.gz: 4da9e195b6679df8c9f2c9ec3a07b780409b2a68f6cffe66feab9276a0ee90b987b7221a13d5f363c0b700c3d5b8d956e9b6a5753a0aa81058e1e10458ced75f
|
data/.github/workflows/tests.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGES
CHANGED
@@ -1,3 +1,76 @@
|
|
1
|
+
= 0.14.0 / (23 March 2023)
|
2
|
+
|
3
|
+
* Nesta can now be used as a Static Site Generator (SSG) with its new
|
4
|
+
`nesta build` command! Server Side Rendering (SSR) is still supported,
|
5
|
+
as is development with a local web server.
|
6
|
+
|
7
|
+
Back in the days when Heroku allowed us to deploy Nesta on their
|
8
|
+
platform for free, there really didn't seem to be any point in
|
9
|
+
converting a site to a bunch of static HTML and CSS files. If you
|
10
|
+
enabled the appropriate HTTP cache-control headers, Heroku would
|
11
|
+
automatically cache an entire site in memory, so there was no real
|
12
|
+
performance benefit. That's why Nesta never had SSG support, even
|
13
|
+
though everybody seemed to think it was cool.
|
14
|
+
|
15
|
+
But Heroku is not free any more. And there's a wide choice of hosting
|
16
|
+
platforms for static site generators. So why not?
|
17
|
+
|
18
|
+
See the docs for full details, but in short:
|
19
|
+
|
20
|
+
- If you run `bundle exec nesta build`, Nesta will generate a static
|
21
|
+
copy of your site in a ./dist directory.
|
22
|
+
|
23
|
+
- You might want to add ./dist to your .gitignore file.
|
24
|
+
|
25
|
+
- There are a couple of new config settings in config.yml.
|
26
|
+
|
27
|
+
- You can configure hosting platforms like Netlify, AWS Amplify,
|
28
|
+
Vercel (and others) to redeploy your site by running the build
|
29
|
+
command when you push changes to your git repository.
|
30
|
+
|
31
|
+
This was fun to implement. (Graham Ashton)
|
32
|
+
|
33
|
+
* Sass and SCSS files are now rendered with Dart Sass (the main implementation
|
34
|
+
of Sass). We had been using the (now deprecated) libsass library.
|
35
|
+
|
36
|
+
Sass has changed a bit since libsass was current, so you may need to make
|
37
|
+
some small changes to your stylesheets. Documentation that should help with
|
38
|
+
those changes can be found here:
|
39
|
+
|
40
|
+
https://sass-lang.com/documentation/breaking-changes
|
41
|
+
|
42
|
+
* Replace Nesta's custom template-locating code with Sinatra's #find_template
|
43
|
+
method. (Graham Ashton, suggested by Lilith River)
|
44
|
+
|
45
|
+
* Update multiple dependencies to fix security vulnerabilities; see commit
|
46
|
+
history for details. (Graham Ashton)
|
47
|
+
|
48
|
+
* Built-in support for configuring Nesta via environment variables has been
|
49
|
+
dropped. (Graham Ashton)
|
50
|
+
|
51
|
+
Should you still want to configure Nesta via the environment you can
|
52
|
+
use Erb in `config.yml`, like this:
|
53
|
+
|
54
|
+
some_value: <%= ENV.fetch('NESTA_VARIABLE') %>
|
55
|
+
|
56
|
+
* During a tidy up of the config file code, the `yaml_conf` attribute on
|
57
|
+
the Nesta::Config class has been renamed to `config`. This is unlikely
|
58
|
+
to affect you, but if it does just change the name. (Graham Ashton)
|
59
|
+
|
60
|
+
* The `yaml_path` attribute on the Nesta::Config class has been moved
|
61
|
+
to `Nesta::ConfigFile.path`. Again, I can't imagine why anybody would
|
62
|
+
have written code that used it, but it's a breaking change so I'm
|
63
|
+
mentioning it. (Graham Ashton)
|
64
|
+
|
65
|
+
* Support for loading plugins from a local directory (which was deprecated
|
66
|
+
in version 0.9.10) has been removed. (Graham Ashton)
|
67
|
+
|
68
|
+
* The local_stylesheet? helper method (deprecated in 0.9.1) has been
|
69
|
+
removed. (Graham Ashton)
|
70
|
+
|
71
|
+
* The breadcrumb_label helper method (deprecated in 0.9.3) has been removed.
|
72
|
+
(Graham Ashton)
|
73
|
+
|
1
74
|
= 0.13.0 / (28 September 2022)
|
2
75
|
|
3
76
|
* Update dependencies in order to support Ruby 3.0 and above.
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nesta (0.
|
4
|
+
nesta (0.14.0)
|
5
5
|
RedCloth (~> 4.2)
|
6
6
|
haml (>= 3.1, < 6.0)
|
7
7
|
haml-contrib (>= 1.0)
|
8
|
-
rack (~> 2
|
8
|
+
rack (~> 2)
|
9
|
+
rake
|
9
10
|
rdiscount (~> 2.1)
|
10
|
-
|
11
|
+
sass-embedded (~> 1.58)
|
11
12
|
sinatra (~> 2.0)
|
12
13
|
tilt (~> 2.0)
|
13
14
|
|
@@ -28,6 +29,7 @@ GEM
|
|
28
29
|
rack-test (>= 0.5.4)
|
29
30
|
xpath (>= 2.0, < 4.0)
|
30
31
|
ffi (1.15.5)
|
32
|
+
google-protobuf (3.22.2)
|
31
33
|
haml (5.2.2)
|
32
34
|
temple (>= 0.8.0)
|
33
35
|
tilt
|
@@ -39,9 +41,9 @@ GEM
|
|
39
41
|
rb-inotify (>= 0.9)
|
40
42
|
rb-kqueue (>= 0.2)
|
41
43
|
mini_mime (1.1.2)
|
42
|
-
mini_portile2 (2.8.
|
43
|
-
minitest (5.
|
44
|
-
minitest-reporters (1.
|
44
|
+
mini_portile2 (2.8.1)
|
45
|
+
minitest (5.18.0)
|
46
|
+
minitest-reporters (1.6.0)
|
45
47
|
ansi
|
46
48
|
builder
|
47
49
|
minitest (>= 5.0)
|
@@ -53,35 +55,36 @@ GEM
|
|
53
55
|
unicorn (>= 4.5)
|
54
56
|
mustermann (2.0.2)
|
55
57
|
ruby2_keywords (~> 0.0.1)
|
56
|
-
nokogiri (1.
|
58
|
+
nokogiri (1.14.2)
|
57
59
|
mini_portile2 (~> 2.8.0)
|
58
60
|
racc (~> 1.4)
|
59
|
-
public_suffix (5.0.
|
60
|
-
racc (1.6.
|
61
|
-
rack (2.2.4)
|
62
|
-
rack-protection (2.2.
|
61
|
+
public_suffix (5.0.1)
|
62
|
+
racc (1.6.2)
|
63
|
+
rack (2.2.6.4)
|
64
|
+
rack-protection (2.2.4)
|
63
65
|
rack
|
64
66
|
rack-test (2.0.2)
|
65
67
|
rack (>= 1.3)
|
66
|
-
raindrops (0.20.
|
68
|
+
raindrops (0.20.1)
|
67
69
|
rake (13.0.6)
|
68
70
|
rb-fsevent (0.11.2)
|
69
71
|
rb-inotify (0.10.1)
|
70
72
|
ffi (~> 1.0)
|
71
73
|
rb-kqueue (0.2.8)
|
72
74
|
ffi (>= 0.5.0)
|
73
|
-
rdiscount (2.2.
|
74
|
-
ruby-progressbar (1.
|
75
|
+
rdiscount (2.2.7)
|
76
|
+
ruby-progressbar (1.13.0)
|
75
77
|
ruby2_keywords (0.0.5)
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
sass-embedded (1.58.3)
|
79
|
+
google-protobuf (~> 3.21)
|
80
|
+
rake (>= 10.0.0)
|
81
|
+
sinatra (2.2.4)
|
79
82
|
mustermann (~> 2.0)
|
80
83
|
rack (~> 2.2)
|
81
|
-
rack-protection (= 2.2.
|
84
|
+
rack-protection (= 2.2.4)
|
82
85
|
tilt (~> 2.0)
|
83
|
-
temple (0.
|
84
|
-
tilt (2.0
|
86
|
+
temple (0.10.0)
|
87
|
+
tilt (2.1.0)
|
85
88
|
unicorn (6.1.0)
|
86
89
|
kgio (~> 2.6)
|
87
90
|
raindrops (~> 0.7)
|
@@ -98,7 +101,6 @@ DEPENDENCIES
|
|
98
101
|
minitest-reporters
|
99
102
|
mr-sparkle
|
100
103
|
nesta!
|
101
|
-
rake
|
102
104
|
|
103
105
|
BUNDLED WITH
|
104
|
-
2.
|
106
|
+
2.4.6
|
data/README.md
CHANGED
@@ -44,8 +44,8 @@ full instructions).
|
|
44
44
|
## Support
|
45
45
|
|
46
46
|
There's plenty of information on <http://nestacms.com>. If you need some
|
47
|
-
help with anything feel free to file an issue, or contact me
|
48
|
-
|
47
|
+
help with anything feel free to file an issue, or contact me on Mastodon
|
48
|
+
(@gma@hachyderm.io) or Twitter (@grahamashton).
|
49
49
|
|
50
50
|
If you like Nesta you can keep up with developments by following [@nestacms][]
|
51
51
|
on Twitter, and on [the blog][].
|
@@ -53,6 +53,8 @@ on Twitter, and on [the blog][].
|
|
53
53
|
[@nestacms]: http://twitter.com/nestacms
|
54
54
|
[the blog]: http://nestacms.com/blog
|
55
55
|
|
56
|
+
![Tests](https://github.com/gma/nesta/actions/workflows/tests.yml/badge.svg)
|
57
|
+
|
56
58
|
## Contributing
|
57
59
|
|
58
60
|
If you want to add a new feature, I recommend that you file an issue to discuss
|
data/bin/nesta
CHANGED
@@ -24,6 +24,7 @@ COMMANDS
|
|
24
24
|
theme:install <url> Install a theme from a git repository.
|
25
25
|
theme:enable <name> Make the theme active, updating config.yml.
|
26
26
|
theme:create <name> Makes a template for a new theme in ./themes.
|
27
|
+
build [path] Build static copy of site (path defaults to ./dist)
|
27
28
|
|
28
29
|
OPTIONS FOR new
|
29
30
|
--git Create a new git repository for the project.
|
@@ -41,6 +42,7 @@ EOF
|
|
41
42
|
def self.parse_command_line
|
42
43
|
opts = GetoptLong.new(
|
43
44
|
['--bash-completion', GetoptLong::NO_ARGUMENT],
|
45
|
+
['--domain', GetoptLong::REQUIRED_ARGUMENT],
|
44
46
|
['--git', GetoptLong::NO_ARGUMENT],
|
45
47
|
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
46
48
|
['--version', '-v', GetoptLong::NO_ARGUMENT],
|
@@ -118,7 +120,7 @@ _nesta() {
|
|
118
120
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
119
121
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
120
122
|
|
121
|
-
opts="new 'demo:content' edit 'plugin:create' 'theme:install' 'theme:enable' 'theme:create'"
|
123
|
+
opts="new 'demo:content' edit 'plugin:create' 'theme:install' 'theme:enable' 'theme:create' build"
|
122
124
|
|
123
125
|
case "${cur}" in
|
124
126
|
theme:*)
|
@@ -172,6 +174,7 @@ _1st_arguments=(
|
|
172
174
|
'theme\:install:Install a theme from a git repository'
|
173
175
|
'theme\:enable:Make the theme active, updating config.yml'
|
174
176
|
'theme\:create:Makes a template for a new theme in ./themes'
|
177
|
+
'build\:Build static copy of site'
|
175
178
|
)
|
176
179
|
|
177
180
|
local expl
|
data/lib/nesta/app.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'haml'
|
3
|
-
require 'sassc'
|
4
3
|
|
5
4
|
require File.expand_path('../nesta', File.dirname(__FILE__))
|
6
5
|
require File.expand_path('env', File.dirname(__FILE__))
|
@@ -18,6 +17,7 @@ module Nesta
|
|
18
17
|
set :root, Nesta::Env.root
|
19
18
|
set :views, File.expand_path('../../views', File.dirname(__FILE__))
|
20
19
|
set :haml, { format: :html5 }
|
20
|
+
set :public_folder, 'public'
|
21
21
|
|
22
22
|
helpers Overrides::Renderers
|
23
23
|
helpers Navigation::Renderers
|
@@ -90,5 +90,4 @@ module Nesta
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
Nesta::Plugin.load_local_plugins
|
94
93
|
Nesta::Plugin.initialize_plugins
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
require_relative '../static/assets'
|
4
|
+
require_relative '../static/site'
|
5
|
+
|
6
|
+
module Nesta
|
7
|
+
module Commands
|
8
|
+
class Build
|
9
|
+
DEFAULT_DESTINATION = "dist"
|
10
|
+
|
11
|
+
attr_accessor :domain
|
12
|
+
|
13
|
+
def initialize(build_dir = nil, options = {})
|
14
|
+
@build_dir = build_dir || DEFAULT_DESTINATION
|
15
|
+
if @build_dir == Nesta::App.settings.public_folder
|
16
|
+
raise RuntimeError.new("#{@build_dir} is already used, for assets")
|
17
|
+
end
|
18
|
+
@domain = options['domain'] || configured_domain_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def configured_domain_name
|
22
|
+
Nesta::Config.build.fetch('domain', 'localhost')
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute(process)
|
26
|
+
logger = Proc.new { |message| puts message }
|
27
|
+
site = Nesta::Static::Site.new(@build_dir, @domain, logger)
|
28
|
+
site.render_pages
|
29
|
+
site.render_not_found
|
30
|
+
site.render_atom_feed
|
31
|
+
site.render_sitemap
|
32
|
+
site.render_templated_assets
|
33
|
+
Nesta::Static::Assets.new(@build_dir, logger).copy_attachments
|
34
|
+
Nesta::Static::Assets.new(@build_dir, logger).copy_public_folder
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/nesta/commands/new.rb
CHANGED
@@ -25,7 +25,8 @@ module Nesta
|
|
25
25
|
def create_repository(process)
|
26
26
|
FileUtils.cd(@path) do
|
27
27
|
File.open('.gitignore', 'w') do |file|
|
28
|
-
|
28
|
+
lines = %w[._* .*.swp .bundle .DS_Store .sass-cache dist]
|
29
|
+
file.puts lines.join("\n")
|
29
30
|
end
|
30
31
|
process.run('git', 'init')
|
31
32
|
process.run('git', 'add', '.')
|
data/lib/nesta/commands.rb
CHANGED
@@ -7,6 +7,7 @@ require File.expand_path('path', File.dirname(__FILE__))
|
|
7
7
|
require File.expand_path('system_command', File.dirname(__FILE__))
|
8
8
|
require File.expand_path('version', File.dirname(__FILE__))
|
9
9
|
|
10
|
+
require File.expand_path('commands/build', File.dirname(__FILE__))
|
10
11
|
require File.expand_path('commands/demo', File.dirname(__FILE__))
|
11
12
|
require File.expand_path('commands/edit', File.dirname(__FILE__))
|
12
13
|
require File.expand_path('commands/new', File.dirname(__FILE__))
|
data/lib/nesta/config.rb
CHANGED
@@ -1,115 +1,89 @@
|
|
1
|
+
require 'singleton'
|
1
2
|
require 'yaml'
|
2
3
|
|
4
|
+
require_relative './config_file'
|
5
|
+
|
3
6
|
module Nesta
|
4
7
|
class Config
|
8
|
+
include Singleton
|
9
|
+
|
5
10
|
class NotDefined < KeyError; end
|
6
11
|
|
7
|
-
|
8
|
-
|
12
|
+
SETTINGS = %w[
|
13
|
+
author
|
14
|
+
build
|
9
15
|
content
|
10
16
|
disqus_short_name
|
17
|
+
domain
|
11
18
|
google_analytics_code
|
12
19
|
read_more
|
13
20
|
subtitle
|
14
21
|
theme
|
15
22
|
title
|
16
23
|
]
|
17
|
-
|
18
|
-
@yaml = nil
|
19
|
-
|
24
|
+
|
20
25
|
class << self
|
21
|
-
|
26
|
+
extend Forwardable
|
27
|
+
def_delegators *[:instance, :fetch].concat(SETTINGS.map(&:to_sym))
|
22
28
|
end
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
attr_accessor :config
|
31
|
+
|
32
|
+
def fetch(setting, *default)
|
33
|
+
setting = setting.to_s
|
34
|
+
self.config ||= read_config_file(setting)
|
35
|
+
env_config = config.fetch(Nesta::App.environment.to_s, {})
|
36
|
+
env_config.fetch(
|
37
|
+
setting,
|
38
|
+
config.fetch(setting) { raise NotDefined.new(setting) }
|
39
|
+
)
|
26
40
|
rescue NotDefined
|
27
|
-
|
28
|
-
from_yaml(key.to_s)
|
29
|
-
rescue NotDefined
|
30
|
-
default.empty? && raise || (return default.first)
|
31
|
-
end
|
41
|
+
default.empty? && raise || (return default.first)
|
32
42
|
end
|
33
43
|
|
34
|
-
def
|
35
|
-
if
|
36
|
-
fetch(method, nil)
|
44
|
+
def method_missing(method, *args)
|
45
|
+
if SETTINGS.include?(method.to_s)
|
46
|
+
fetch(method.to_s, nil)
|
37
47
|
else
|
38
48
|
super
|
39
49
|
end
|
40
50
|
end
|
41
|
-
|
42
|
-
def self.author
|
43
|
-
environment_config = {}
|
44
|
-
%w[name uri email].each do |setting|
|
45
|
-
variable = "NESTA_AUTHOR__#{setting.upcase}"
|
46
|
-
ENV[variable] && environment_config[setting] = ENV[variable]
|
47
|
-
end
|
48
|
-
environment_config.empty? ? from_yaml('author') : environment_config
|
49
|
-
rescue NotDefined
|
50
|
-
nil
|
51
|
-
end
|
52
51
|
|
53
|
-
def
|
54
|
-
|
55
|
-
'see http://nestacms.com/docs/deployment/page-caching')
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.content_path(basename = nil)
|
59
|
-
get_path(content, basename)
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.page_path(basename = nil)
|
63
|
-
get_path(File.join(content_path, "pages"), basename)
|
52
|
+
def respond_to_missing?(method, include_private = false)
|
53
|
+
SETTINGS.include?(method.to_s) || super
|
64
54
|
end
|
65
|
-
|
66
|
-
def
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.yaml_path
|
71
|
-
File.expand_path('config/config.yml', Nesta::App.root)
|
55
|
+
|
56
|
+
def build
|
57
|
+
fetch('build', {})
|
72
58
|
end
|
73
59
|
|
74
|
-
def
|
60
|
+
def read_more
|
75
61
|
fetch('read_more', 'Continue reading')
|
76
62
|
end
|
77
63
|
|
78
|
-
|
79
|
-
|
80
|
-
|
64
|
+
private
|
65
|
+
|
66
|
+
def read_config_file(setting)
|
67
|
+
YAML::load(ERB.new(IO.read(Nesta::ConfigFile.path)).result)
|
68
|
+
rescue Errno::ENOENT
|
81
69
|
raise NotDefined.new(setting)
|
82
|
-
else
|
83
|
-
overrides = { "true" => true, "false" => false }
|
84
|
-
overrides.has_key?(value) ? overrides[value] : value
|
85
|
-
end
|
86
|
-
private_class_method :from_environment
|
87
|
-
|
88
|
-
def self.yaml_exists?
|
89
|
-
File.exist?(yaml_path)
|
90
70
|
end
|
91
|
-
private_class_method :yaml_exists?
|
92
71
|
|
93
|
-
def self.from_hash(hash, setting)
|
94
|
-
hash.fetch(setting) { raise NotDefined.new(setting) }
|
95
|
-
end
|
96
|
-
private_class_method :from_hash
|
97
|
-
|
98
|
-
def self.from_yaml(setting)
|
99
|
-
raise NotDefined.new(setting) unless yaml_exists?
|
100
|
-
self.yaml_conf ||= YAML::load(ERB.new(IO.read(yaml_path)).result)
|
101
|
-
env_config = self.yaml_conf.fetch(Nesta::App.environment.to_s, {})
|
102
|
-
begin
|
103
|
-
from_hash(env_config, setting)
|
104
|
-
rescue NotDefined
|
105
|
-
from_hash(self.yaml_conf, setting)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
private_class_method :from_yaml
|
109
|
-
|
110
72
|
def self.get_path(dirname, basename)
|
111
73
|
basename.nil? ? dirname : File.join(dirname, basename)
|
112
74
|
end
|
113
75
|
private_class_method :get_path
|
76
|
+
|
77
|
+
def self.content_path(basename = nil)
|
78
|
+
get_path(content, basename)
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.page_path(basename = nil)
|
82
|
+
get_path(File.join(content_path, "pages"), basename)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.attachment_path(basename = nil)
|
86
|
+
get_path(File.join(content_path, "attachments"), basename)
|
87
|
+
end
|
114
88
|
end
|
115
89
|
end
|
data/lib/nesta/config_file.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module Nesta
|
2
2
|
class ConfigFile
|
3
|
+
def self.path
|
4
|
+
File.expand_path('config/config.yml', Nesta::App.root)
|
5
|
+
end
|
6
|
+
|
3
7
|
def set_value(key, value)
|
4
8
|
pattern = /^\s*#?\s*#{key}:.*/
|
5
9
|
replacement = "#{key}: #{value}"
|
6
10
|
|
7
11
|
configured = false
|
8
|
-
File.open(
|
12
|
+
File.open(self.class.path, 'r+') do |file|
|
9
13
|
output = ''
|
10
14
|
file.each_line do |line|
|
11
15
|
if configured
|
data/lib/nesta/helpers.rb
CHANGED
@@ -60,11 +60,6 @@ module Nesta
|
|
60
60
|
date.strftime("%d %B %Y")
|
61
61
|
end
|
62
62
|
|
63
|
-
def local_stylesheet?
|
64
|
-
Nesta.deprecated('local_stylesheet?', 'use local_stylesheet_link_tag')
|
65
|
-
File.exist?(File.expand_path('views/local.sass', Nesta::App.root))
|
66
|
-
end
|
67
|
-
|
68
63
|
def local_stylesheet_link_tag(name)
|
69
64
|
pattern = File.expand_path("views/#{name}.s{a,c}ss", Nesta::App.root)
|
70
65
|
if Dir.glob(pattern).size > 0
|
data/lib/nesta/models.rb
CHANGED
@@ -380,45 +380,44 @@ module Nesta
|
|
380
380
|
end
|
381
381
|
end
|
382
382
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
if
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
sub_menu_for_depth(menu, current_depth) << page
|
395
|
-
end
|
383
|
+
private_class_method def self.append_menu_item(menu, file, depth)
|
384
|
+
path = file.readline
|
385
|
+
rescue EOFError
|
386
|
+
else
|
387
|
+
page = Page.load(path.strip)
|
388
|
+
current_depth = path.scan(INDENT).size
|
389
|
+
if page
|
390
|
+
if current_depth > depth
|
391
|
+
sub_menu_for_depth(menu, depth) << [page]
|
392
|
+
else
|
393
|
+
sub_menu_for_depth(menu, current_depth) << page
|
396
394
|
end
|
397
|
-
append_menu_item(menu, file, current_depth)
|
398
395
|
end
|
396
|
+
append_menu_item(menu, file, current_depth)
|
397
|
+
end
|
399
398
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
399
|
+
private_class_method def self.sub_menu_for_depth(menu, depth)
|
400
|
+
sub_menu = menu
|
401
|
+
depth.times { sub_menu = sub_menu[-1] }
|
402
|
+
sub_menu
|
403
|
+
end
|
405
404
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
end
|
405
|
+
private_class_method def self.find_menu_item_by_path(menu, path)
|
406
|
+
item = menu.detect do |item|
|
407
|
+
item.respond_to?(:path) && (item.path == path)
|
408
|
+
end
|
409
|
+
if item
|
410
|
+
subsequent = menu[menu.index(item) + 1]
|
411
|
+
item = [item]
|
412
|
+
item << subsequent if subsequent.respond_to?(:each)
|
413
|
+
else
|
414
|
+
sub_menus = menu.select { |menu_item| menu_item.respond_to?(:each) }
|
415
|
+
sub_menus.each do |sub_menu|
|
416
|
+
item = find_menu_item_by_path(sub_menu, path)
|
417
|
+
break if item
|
420
418
|
end
|
421
|
-
item
|
422
419
|
end
|
420
|
+
item
|
421
|
+
end
|
423
422
|
end
|
424
423
|
end
|
data/lib/nesta/navigation.rb
CHANGED