radiant-sheets-extension 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -0
- data/app/models/javascript_page.rb +0 -1
- data/app/models/sheet.rb +5 -3
- data/app/models/stylesheet_page.rb +0 -1
- data/app/views/admin/scripts/edit.html.haml +2 -2
- data/app/views/admin/scripts/index.html.haml +3 -3
- data/app/views/admin/styles/edit.html.haml +2 -2
- data/app/views/admin/styles/index.html.haml +3 -3
- data/app/views/admin/styles/new.html.haml +2 -2
- data/config/locales/nl.yml +17 -0
- data/lib/radiant-sheets-extension/version.rb +1 -1
- data/radiant-sheets-extension.gemspec +1 -1
- data/sheets_extension.rb +1 -14
- data/spec/lib/javascript_tags_spec.rb +3 -0
- data/spec/lib/stylesheet_tags_spec.rb +3 -0
- data/spec/models/javascript_page_spec.rb +5 -0
- data/spec/models/stylesheet_page_spec.rb +3 -0
- metadata +64 -36
data/README.md
CHANGED
@@ -4,6 +4,24 @@ Sheets is a way to manage stylesheets and scripts from your existing page tree.
|
|
4
4
|
|
5
5
|
Pages of these types are Sheets.
|
6
6
|
|
7
|
+
## Configuration
|
8
|
+
|
9
|
+
Sheets have an option to output paths with a cache parameter which will create a digest of the rendered content.
|
10
|
+
|
11
|
+
By setting `Radiant::Config['sheets.use_cache_param?]` to `true` the paths output from the `<r:stylesheet>` and `<r:javascript>` tags will appear like
|
12
|
+
|
13
|
+
/css/styles.css?bc4150d023d3255136db671d61ac93f2
|
14
|
+
/js/scripts.js?d6c5855a62cf32a4dadbc2831f0f295f
|
15
|
+
|
16
|
+
where the parameter is created from the rendered content of the sheet.
|
17
|
+
|
18
|
+
Without this set, the paths will be:
|
19
|
+
|
20
|
+
/css/styles.css
|
21
|
+
/js/scripts.js
|
22
|
+
|
23
|
+
and the pages will not be rendered to generate the path.
|
24
|
+
|
7
25
|
## Features
|
8
26
|
|
9
27
|
The basic features:
|
data/app/models/sheet.rb
CHANGED
@@ -76,8 +76,6 @@ module Sheet
|
|
76
76
|
self.errors.add(:upload, 'not given. Please upload a file.')
|
77
77
|
when !file.kind_of?(ActionController::UploadedFile)
|
78
78
|
self.errors.add(:upload, 'is an unusable format.')
|
79
|
-
when file.size > 262144 # 256k (that's a HUGE script or stylesheet)
|
80
|
-
self.errors.add(:upload, 'file size is larger than 256kB. Please upload a smaller file.')
|
81
79
|
else
|
82
80
|
self.slug = file.original_filename.to_slug().gsub(/-css$/,'.css').gsub(/-js/,'.js')
|
83
81
|
self.part('body').content = file.read
|
@@ -93,7 +91,11 @@ module Sheet
|
|
93
91
|
end
|
94
92
|
|
95
93
|
def child_path(child)
|
96
|
-
clean_path(path + '/' + child.slug +
|
94
|
+
clean_path(path + '/' + child.slug + child.cache_marker)
|
95
|
+
end
|
96
|
+
|
97
|
+
def cache_marker
|
98
|
+
Radiant::Config['sheets.use_cache_param?'] ? "?#{digest}" : ''
|
97
99
|
end
|
98
100
|
|
99
101
|
private
|
@@ -1,12 +1,12 @@
|
|
1
1
|
%h1= model.new_record? ? t('new_javascript') : t('edit_javascript')
|
2
2
|
- form_for [:admin, model], :url => (model.new_record? ? admin_scripts_url : admin_script_url(model)) do |f|
|
3
3
|
%p.title
|
4
|
-
= label :sheet_page, :slug, '
|
4
|
+
= label :sheet_page, :slug, t('slug')
|
5
5
|
= f.text_field :slug, :class => 'textbox', :maxlength => 255, :id => 'sheet_page_slug'
|
6
6
|
%span.hint= %{#{t('path')}: #{@root.url}<span id="this_slug">#{model.slug}</span>}
|
7
7
|
- f.fields_for :parts do |p|
|
8
8
|
%p.content
|
9
|
-
= p.label :content, '
|
9
|
+
= p.label :content, t('content')
|
10
10
|
= p.hidden_field :name, :value => 'body' if model.new_record?
|
11
11
|
= p.text_area :content, :class => 'textarea large', :style => 'width: 100%'
|
12
12
|
%p
|
@@ -1,12 +1,12 @@
|
|
1
1
|
%h1= model.new_record? ? t('new_stylesheet') : t('edit_stylesheet')
|
2
2
|
- form_for [:admin, model], :url => (model.new_record? ? admin_styles_url() : admin_style_url(model)) do |f|
|
3
3
|
%p.title
|
4
|
-
= label :sheet_page, :slug, '
|
4
|
+
= label :sheet_page, :slug, t('slug')
|
5
5
|
= f.text_field :slug, :class => 'textbox', :maxlength => 255, :id => "sheet_page_slug"
|
6
6
|
%span.hint= %{Path: #{@root.url}<span id="this_slug">#{model.slug}</span>}
|
7
7
|
- f.fields_for :parts do |p|
|
8
8
|
%p.content
|
9
|
-
= p.label :content, '
|
9
|
+
= p.label :content, t('content')
|
10
10
|
= p.hidden_field :name, :value => 'body' if model.new_record?
|
11
11
|
= p.text_area :content, :class => 'textarea large', :style => 'width: 100%'
|
12
12
|
%p
|
@@ -1,12 +1,12 @@
|
|
1
1
|
%h1= model.new_record? ? t('new_stylesheet') : t('edit_stylesheet')
|
2
2
|
- form_for [:admin, model], :url => (model.new_record? ? admin_styles_url() : admin_style_url(model)) do |f|
|
3
3
|
%p.title
|
4
|
-
= label :sheet_page, :slug, '
|
4
|
+
= label :sheet_page, :slug, t('slug')
|
5
5
|
= f.text_field :slug, :class => 'textbox', :maxlength => 255, :id => "sheet_page_slug"
|
6
6
|
%span.hint= %{Path: #{@root.url}<span id="this_slug">#{model.slug}</span>}
|
7
7
|
- f.fields_for :parts do |p|
|
8
8
|
%p.content
|
9
|
-
= p.label :content, '
|
9
|
+
= p.label :content, t('content')
|
10
10
|
= p.hidden_field :name, :value => 'body' if model.new_record?
|
11
11
|
= p.text_area :content, :class => 'textarea large', :style => 'width: 100%'
|
12
12
|
%p
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
nl:
|
3
|
+
create_javascript: Creëer Javascript
|
4
|
+
create_stylesheet: Creëer Stylesheet
|
5
|
+
edit_javascript: Javascript aanpassen
|
6
|
+
edit_stylesheet: Stylesheet aanpassen
|
7
|
+
new_javascript: Nieuwe Javascript
|
8
|
+
new_stylesheet: Nieuwe Stylesheet
|
9
|
+
path: Pad
|
10
|
+
sheets: Sheets
|
11
|
+
upload: Uploaden
|
12
|
+
stylesheet_page: Stylesheet
|
13
|
+
javascript_page: Javascript
|
14
|
+
sheets:
|
15
|
+
root_required: "Je moet een homepage publiceren voor je een %{model} kunt maken."
|
16
|
+
no_styles: 'Geen Stylesheets'
|
17
|
+
no_scripts: 'Geen Javascripts'
|
data/sheets_extension.rb
CHANGED
@@ -36,22 +36,9 @@ class SheetsExtension < Radiant::Extension
|
|
36
36
|
alias_method_chain :filter_options_for_select, :sheet_restrictions
|
37
37
|
end
|
38
38
|
|
39
|
-
# Will only be called in 0.9.1 and below, avoid redeclaring
|
40
|
-
unless Page.respond_to?('in_menu')
|
41
|
-
Page.class_eval do
|
42
|
-
class_inheritable_accessor :in_menu
|
43
|
-
self.in_menu = true
|
44
|
-
|
45
|
-
class << self
|
46
|
-
alias_method :in_menu?, :in_menu
|
47
|
-
alias_method :in_menu, :in_menu=
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
39
|
Page.class_eval do
|
53
40
|
def sheet?
|
54
|
-
self.
|
41
|
+
self.is_a?(Sheet::Instance)
|
55
42
|
end
|
56
43
|
|
57
44
|
include JavascriptTags
|
@@ -8,6 +8,9 @@ describe "Javascript Tags" do
|
|
8
8
|
let(:javascript_page){ pages(:site_js)}
|
9
9
|
|
10
10
|
describe "<r:javascript>" do
|
11
|
+
before do
|
12
|
+
Radiant::Config['sheets.use_cache_param?'] = true
|
13
|
+
end
|
11
14
|
subject { page }
|
12
15
|
it { should render(%{<r:javascript />}).with_error("`javascript' tag must contain a `slug' attribute.") }
|
13
16
|
it { should render(%{<r:javascript slug="bogus" />}).with_error("javascript bogus not found") }
|
@@ -7,6 +7,9 @@ describe "Stylesheet Tags" do
|
|
7
7
|
let(:page){ pages(:home) }
|
8
8
|
|
9
9
|
describe "<r:stylesheet>" do
|
10
|
+
before do
|
11
|
+
Radiant::Config['sheets.use_cache_param?'] = true
|
12
|
+
end
|
10
13
|
let(:site_css){pages(:site_css)}
|
11
14
|
subject { page }
|
12
15
|
it { should render(%{<r:stylesheet />}).with_error("`stylesheet' tag must contain a `slug' attribute.") }
|
@@ -48,6 +48,11 @@ describe JavascriptPage do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#path' do
|
51
|
+
|
52
|
+
before do
|
53
|
+
Radiant::Config['sheets.use_cache_param?'] = true
|
54
|
+
end
|
55
|
+
|
51
56
|
it 'should include an md5 hash of the rendered contents' do
|
52
57
|
site_js.path.should == "/js/site.js?#{site_js.digest}"
|
53
58
|
end
|
@@ -48,6 +48,9 @@ describe StylesheetPage do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#path' do
|
51
|
+
before do
|
52
|
+
Radiant::Config['sheets.use_cache_param?'] = true
|
53
|
+
end
|
51
54
|
it 'should include an md5 hash of the rendered contents' do
|
52
55
|
site_css.path.should == "/css/site.css?#{site_css.digest}"
|
53
56
|
end
|
metadata
CHANGED
@@ -1,46 +1,64 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-sheets-extension
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Radiant CMS Dev Team
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-12-29 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: sass
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
25
|
+
requirements:
|
19
26
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 27
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 1
|
32
|
+
- 12
|
33
|
+
version: 3.1.12
|
22
34
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
26
37
|
name: coffee-script
|
27
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
41
|
+
requirements:
|
30
42
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 2
|
48
|
+
- 0
|
32
49
|
version: 2.2.0
|
33
50
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
of Pages.
|
38
|
-
email:
|
51
|
+
version_requirements: *id002
|
52
|
+
description: Manage CSS and Javascript content in Radiant CMS as Sheets, a subset of Pages.
|
53
|
+
email:
|
39
54
|
- radiant@radiantcms.org
|
40
55
|
executables: []
|
56
|
+
|
41
57
|
extensions: []
|
58
|
+
|
42
59
|
extra_rdoc_files: []
|
43
|
-
|
60
|
+
|
61
|
+
files:
|
44
62
|
- app/controllers/admin/scripts_controller.rb
|
45
63
|
- app/controllers/admin/sheet_resource_controller.rb
|
46
64
|
- app/controllers/admin/styles_controller.rb
|
@@ -58,6 +76,7 @@ files:
|
|
58
76
|
- app/views/admin/styles/index.html.haml
|
59
77
|
- app/views/admin/styles/new.html.haml
|
60
78
|
- config/locales/en.yml
|
79
|
+
- config/locales/nl.yml
|
61
80
|
- config/routes.rb
|
62
81
|
- cucumber.yml
|
63
82
|
- features/admin/managing_javascripts.feature
|
@@ -95,29 +114,38 @@ files:
|
|
95
114
|
- spec/spec_helper.rb
|
96
115
|
homepage: http://radiantcms.org/
|
97
116
|
licenses: []
|
117
|
+
|
98
118
|
post_install_message:
|
99
119
|
rdoc_options: []
|
100
|
-
|
120
|
+
|
121
|
+
require_paths:
|
101
122
|
- lib
|
102
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
124
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
133
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 3
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
114
141
|
requirements: []
|
142
|
+
|
115
143
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.8.
|
144
|
+
rubygems_version: 1.8.10
|
117
145
|
signing_key:
|
118
146
|
specification_version: 3
|
119
147
|
summary: Sheets for Radiant CMS
|
120
|
-
test_files:
|
148
|
+
test_files:
|
121
149
|
- spec/controllers/admin/scripts_controller_spec.rb
|
122
150
|
- spec/controllers/admin/styles_controller_spec.rb
|
123
151
|
- spec/datasets/javascripts_dataset.rb
|