radiant-sheets-extension 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Sheets
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/radiant/radiant-sheets-extension.png)](http://travis-ci.org/radiant/radiant-sheets-extension)
4
+
3
5
  Sheets is a way to manage stylesheets and scripts from your existing page tree. With Sheets, you'll create new types of pages: JavascriptPage and StylesheetPage.
4
6
 
5
7
  Pages of these types are Sheets.
@@ -0,0 +1,2 @@
1
+ module Admin::SheetResourceHelper
2
+ end
@@ -11,8 +11,7 @@
11
11
  - models.each do |javascript|
12
12
  %tr
13
13
  %td.name
14
- = image('javascript')
15
- = link_to javascript.title, edit_admin_script_path(javascript)
14
+ = link_to image('javascript') + ' ' + javascript.title, edit_admin_script_path(javascript)
16
15
  %td.filter= javascript.part('body').filter.filter_name
17
16
  %td.actions= link_to(image('minus') + ' ' + t('remove'), admin_script_url(javascript), :class => "action", :method => :delete, :confirm => "Is it OK to delete #{javascript.slug}?")
18
17
  - else
@@ -30,4 +29,4 @@
30
29
  %span
31
30
  = f.label :upload, image('upload') + ' ' + t('upload')
32
31
  = f.file_field :upload
33
- = f.submit t('create_javascript')
32
+ = f.submit t('create_javascript')
@@ -11,8 +11,7 @@
11
11
  - models.each do |stylesheet|
12
12
  %tr
13
13
  %td.name
14
- = image('stylesheet')
15
- = link_to stylesheet.title, edit_admin_style_path(stylesheet)
14
+ = link_to image('stylesheet') + ' ' + stylesheet.title, edit_admin_style_path(stylesheet)
16
15
  %td.filter= stylesheet.part('body').filter.filter_name
17
16
  %td.actions= link_to(image('minus') + ' ' + t('remove'), admin_style_url(stylesheet), :class => "action", :method => :delete, :confirm => "Is it OK to delete #{stylesheet.slug}?")
18
17
  - else
@@ -30,4 +29,4 @@
30
29
  %span
31
30
  = f.label :upload, image('upload') + ' ' + t('upload')
32
31
  = f.file_field :upload
33
- = f.submit t('create_stylesheet')
32
+ = f.submit t('create_stylesheet')
@@ -0,0 +1,17 @@
1
+ ---
2
+ de:
3
+ create_javascript: Javascript anlegen
4
+ create_stylesheet: CSS anlegen
5
+ edit_javascript: Javascript bearbeiten
6
+ edit_stylesheet: CSS bearbeiten
7
+ new_javascript: Neues Javascript
8
+ new_stylesheet: Neues CSS
9
+ path: Pfad
10
+ sheets: Sheets
11
+ upload: Hochladen
12
+ stylesheet_page: CSS
13
+ javascript_page: Javascript
14
+ sheets:
15
+ root_required: "Sie müssen zuerst eine Homepage anlegen, bevor sie ein %{model} erzeugen können."
16
+ no_styles: 'Keine CSS'
17
+ no_scripts: 'Keine Javascripts'
@@ -1,3 +1,3 @@
1
1
  module RadiantSheetsExtension
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -0,0 +1,70 @@
1
+ class SnsImporter
2
+ class OldTextAsset < ActiveRecord::Base
3
+ set_table_name 'text_assets'
4
+ belongs_to :created_by, :class_name => 'User'
5
+ belongs_to :updated_by, :class_name => 'User'
6
+ end
7
+
8
+ def sns_assets
9
+ OldTextAsset.all
10
+ end
11
+
12
+ def stylesheet_root
13
+ @stylesheet_root ||= StylesheetPage.root || StylesheetPage.create_root
14
+ end
15
+
16
+ def javascript_root
17
+ @javascript_root ||= JavascriptPage.root || JavascriptPage.create_root
18
+ end
19
+
20
+ def root(which)
21
+ case which
22
+ when 'stylesheet'
23
+ stylesheet_root
24
+ when 'javascript'
25
+ javascript_root
26
+ end
27
+ end
28
+
29
+ def call
30
+ sns_assets.each do |ta|
31
+ p "Importing #{ta.class_name} #{ta.name}"
32
+ create_text_asset(ta.attributes)
33
+ end
34
+ end
35
+
36
+ def create_text_asset(attrs)
37
+ class_name = attrs.fetch 'class_name', 'Stylesheet'
38
+ klass = (class_name + 'Page').constantize
39
+ sheet = klass.new_with_defaults
40
+
41
+ sheet.slug = attrs['name']
42
+
43
+ unless Page.exists?({:slug => sheet.slug, :parent_id => sheet.parent_id, :class_name => sheet.class_name})
44
+ add_sheet_content(sheet, attrs)
45
+ set_sheet_parent(sheet, class_name)
46
+
47
+ clean_attrs = clean_sns_attributes(sheet, attrs)
48
+ sheet.update_attributes(clean_attrs)
49
+ end
50
+
51
+ sheet
52
+ end
53
+
54
+ def clean_sns_attributes(sheet, attrs)
55
+ clean_attrs = attrs.dup
56
+ clean_attrs.delete_if { |att|
57
+ att[0].to_s.match(/^(lock_version|id|content|filter_id|name|class_name)$/) || !sheet.respond_to?("#{att[0]}=")
58
+ }
59
+ clean_attrs
60
+ end
61
+
62
+ def add_sheet_content(sheet, attrs)
63
+ sheet.part('body').content = attrs.fetch('content','')
64
+ sheet.part('body').filter_id = attrs.fetch('filter_id','')
65
+ end
66
+
67
+ def set_sheet_parent(sheet, class_name)
68
+ sheet.parent_id = root(class_name.downcase).id
69
+ end
70
+ end
@@ -54,24 +54,7 @@ namespace :radiant do
54
54
  namespace :import do
55
55
  desc "Creates new sheets pages from old SNS text_assets"
56
56
  task :sns => :environment do
57
- class TextAsset < ActiveRecord::Base
58
- belongs_to :created_by, :class_name => 'User'
59
- belongs_to :updated_by, :class_name => 'User'
60
- end
61
- TextAsset.all.each do |ta|
62
- klass = (ta.class_name + 'Page').constantize
63
- p "Importing #{klass} #{ta.name}"
64
- sheet = klass.new_with_defaults
65
- sheet.part('body').content = ta.content
66
- sheet.part('body').filter_id = ta.filter_id
67
- sheet.slug = ta.name
68
- ta.attributes.each do |attribute, value|
69
- if !attribute.match(/^(lock_version|id|content|filter_id|name|class_name)$/) && sheet.respond_to?("#{attribute}=")
70
- sheet.send("#{attribute}=", value)
71
- end
72
- end
73
- sheet.save!
74
- end
57
+ SnsImporter.new.call
75
58
  end
76
59
  end
77
60
  end
@@ -0,0 +1,23 @@
1
+ cd ~
2
+ git clone git://github.com/radiant/radiant.git
3
+ cd ~/radiant
4
+ if [[ $RADIANT_VERSION != "master" ]]
5
+ then
6
+ git checkout -b $RADIANT_VERSION $RADIANT_VERSION
7
+ fi
8
+ cp -r ~/builds/*/radiant-sheets-extension vendor/extensions/sheets
9
+ gem install bundler --pre
10
+ echo 'gem "radiant-sheets-extension", :path => "vendor/extensions/sheets"' >> Gemfile
11
+ bundle install
12
+
13
+ case $DB in
14
+ "mysql" )
15
+ mysql -e 'create database radiant_test;'
16
+ cp spec/ci/database.mysql.yml config/database.yml;;
17
+ "postgres" )
18
+ psql -c 'create database radiant_test;' -U postgres
19
+ cp spec/ci/database.postgresql.yml config/database.yml;;
20
+ esac
21
+
22
+ bundle exec rake db:migrate
23
+ bundle exec rake db:migrate:extensions
data/spec/ci/script ADDED
@@ -0,0 +1,2 @@
1
+ cd ~/radiant
2
+ bundle exec rake spec:extensions EXT=sheets
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-sheets-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 6
10
+ version: 1.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Radiant CMS Dev Team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-29 00:00:00 Z
18
+ date: 2012-01-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: sass
@@ -63,6 +63,7 @@ files:
63
63
  - app/controllers/admin/sheet_resource_controller.rb
64
64
  - app/controllers/admin/styles_controller.rb
65
65
  - app/helpers/admin/scripts_helper.rb
66
+ - app/helpers/admin/sheet_resource_helper.rb
66
67
  - app/helpers/admin/styles_helper.rb
67
68
  - app/models/javascript_page.rb
68
69
  - app/models/sheet.rb
@@ -75,6 +76,7 @@ files:
75
76
  - app/views/admin/styles/edit.html.haml
76
77
  - app/views/admin/styles/index.html.haml
77
78
  - app/views/admin/styles/new.html.haml
79
+ - config/locales/de.yml
78
80
  - config/locales/en.yml
79
81
  - config/locales/nl.yml
80
82
  - config/routes.rb
@@ -89,6 +91,7 @@ files:
89
91
  - lib/radiant-sheets-extension.rb
90
92
  - lib/sass_filter.rb
91
93
  - lib/scss_filter.rb
94
+ - lib/sns_importer.rb
92
95
  - lib/stylesheet_tags.rb
93
96
  - lib/tasks/sheets_extension_tasks.rake
94
97
  - LICENSE
@@ -99,6 +102,8 @@ files:
99
102
  - README.md
100
103
  - sass.html
101
104
  - sheets_extension.rb
105
+ - spec/ci/before_script
106
+ - spec/ci/script
102
107
  - spec/controllers/admin/scripts_controller_spec.rb
103
108
  - spec/controllers/admin/styles_controller_spec.rb
104
109
  - spec/datasets/javascripts_dataset.rb
@@ -146,6 +151,8 @@ signing_key:
146
151
  specification_version: 3
147
152
  summary: Sheets for Radiant CMS
148
153
  test_files:
154
+ - spec/ci/before_script
155
+ - spec/ci/script
149
156
  - spec/controllers/admin/scripts_controller_spec.rb
150
157
  - spec/controllers/admin/styles_controller_spec.rb
151
158
  - spec/datasets/javascripts_dataset.rb