orange-sparkles 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/simple/cartons/bar.rb +14 -0
- data/lib/orange-sparkles/plugin.rb +2 -1
- data/lib/orange-sparkles/sparkles_app_resource.rb +72 -0
- data/lib/orange-sparkles/sparkles_resource.rb +48 -16
- data/lib/orange-sparkles/templates/sparkles-admin.haml +3 -1
- data/lib/orange-sparkles/views/blog_posts/create.haml +8 -9
- data/lib/orange-sparkles/views/blog_posts/edit.haml +12 -12
- data/lib/orange-sparkles/views/default_resource/admin.list.haml +31 -0
- data/lib/orange-sparkles/views/default_resource/create.haml +1 -1
- data/lib/orange-sparkles/views/default_resource/edit.haml +4 -1
- data/lib/orange-sparkles/views/default_resource/list.haml +2 -31
- data/lib/orange-sparkles/views/default_resource/orange.list.haml +31 -0
- data/lib/orange-sparkles/views/default_resource/show.haml +4 -1
- data/lib/orange-sparkles/views/default_resource/summary.haml +1 -0
- data/lib/orange-sparkles/views/default_resource/table_row.haml +4 -1
- metadata +9 -5
@@ -1,10 +1,11 @@
|
|
1
|
+
require 'orange-sparkles/sparkles_app_resource'
|
1
2
|
require 'orange-sparkles/sparkles_resource'
|
2
3
|
module Orange::Plugins
|
3
4
|
class Sparkles < Base
|
4
5
|
assets_dir File.join(File.dirname(__FILE__), 'assets')
|
5
6
|
views_dir File.join(File.dirname(__FILE__), 'views')
|
6
7
|
templates_dir File.join(File.dirname(__FILE__), 'templates')
|
7
|
-
resource
|
8
|
+
resource SparklesAppResource.new
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'extlib/mash'
|
2
|
+
|
3
|
+
class Orange::Carton
|
4
|
+
# Define a helper for input type="text" type database stuff
|
5
|
+
# Show in a context if wrapped in one of the helpers
|
6
|
+
def self.markdown(name, opts = {})
|
7
|
+
add_scaffold(name, :markdown, DataMapper::Property::Text, opts.with_defaults(:lazy => true))
|
8
|
+
end
|
9
|
+
|
10
|
+
# Declares a SparklesResource subclass that scaffolds this carton
|
11
|
+
# The Subclass will have the name of the carton followed by "Resource"
|
12
|
+
def self.as_sparkles_resource
|
13
|
+
name = self.to_s
|
14
|
+
eval <<-HEREDOC
|
15
|
+
class ::#{name}Resource < Orange::SparklesResource
|
16
|
+
use #{name}
|
17
|
+
call_me :#{name.downcase}
|
18
|
+
end
|
19
|
+
HEREDOC
|
20
|
+
end
|
21
|
+
def self.as_sparkle_resource
|
22
|
+
as_sparkles_resource
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class SparklesAppResource < Orange::Resource
|
27
|
+
call_me :sparkles
|
28
|
+
|
29
|
+
def init
|
30
|
+
@tabs = []
|
31
|
+
end
|
32
|
+
def stack_init
|
33
|
+
orange[:scaffold].add_scaffold_type(:markdown) do |name, val, opts|
|
34
|
+
packet = opts[:packet]
|
35
|
+
opts = opts.with_defaults({:value => '', :label => false, :show => false, :wrap_tag => 'div'})
|
36
|
+
if opts[:show]
|
37
|
+
packet.markdown(val || '')
|
38
|
+
else
|
39
|
+
val = '' if val.blank?
|
40
|
+
val.gsub!("\n", '
')
|
41
|
+
ret = "<textarea name='#{opts[:model_name]}[#{name}]' class='markdown-editor'>#{val}</textarea>"
|
42
|
+
ret = "<label for=''>#{opts[:display_name]}</label><br />" + ret if opts[:label]
|
43
|
+
ret = "<#{opts[:wrap_tag]}>#{ret}</#{opts[:wrap_tag]}>" if opts[:wrap_tag]
|
44
|
+
ret
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def stylesheets
|
50
|
+
orange.options["sparkles.stylesheets"] || []
|
51
|
+
end
|
52
|
+
def javascripts
|
53
|
+
orange.options["sparkles.javascripts"] || []
|
54
|
+
end
|
55
|
+
def site_name(packet, default = "An Orange Site")
|
56
|
+
packet['site'] ? packet['site'].name : default
|
57
|
+
end
|
58
|
+
def sidebar?
|
59
|
+
orange.options["sidebar_on"] || false
|
60
|
+
end
|
61
|
+
def add_tab(resource, text = nil)
|
62
|
+
@tabs << {:resource => resource, :text => (text || resource.to_s.capitalize)}
|
63
|
+
end
|
64
|
+
def tabs
|
65
|
+
tabs = orange.options["sparkles.tabs"] || []
|
66
|
+
tabs = (tabs + @tabs) unless @tabs.blank?
|
67
|
+
tabs.collect{|hash| Mash.new(hash)} || []
|
68
|
+
end
|
69
|
+
def default_style?
|
70
|
+
orange.options["sparkles.default_style"] || stylesheets.empty?
|
71
|
+
end
|
72
|
+
end
|
@@ -1,23 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class Orange::SparklesResource < Orange::ModelResource
|
2
|
+
extend ClassInheritableAttributes
|
3
|
+
cattr_accessor :tabbed, :auto_sitemap
|
4
|
+
viewable :summary
|
5
|
+
|
6
|
+
def self.tab(text = nil)
|
7
|
+
self.tabbed = text
|
6
8
|
end
|
7
|
-
|
8
|
-
|
9
|
+
|
10
|
+
def self.auto_sitemap!
|
11
|
+
self.auto_sitemap = true
|
9
12
|
end
|
10
|
-
|
11
|
-
|
13
|
+
|
14
|
+
def exposed?(packet)
|
15
|
+
[]
|
12
16
|
end
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
def stack_init
|
19
|
+
orange[:sparkles].add_tab(@my_orange_name, self.class.tabbed) if self.class.tabbed || (self.class.tabbed == nil)
|
20
|
+
orange.register(:sitemap_created) do |opts|
|
21
|
+
packet = opts[:packet]
|
22
|
+
site_id = opts[:site_id]
|
23
|
+
orange[:sitemap, true].add_route_for(packet,
|
24
|
+
:orange_site_id => site_id,
|
25
|
+
:resource => @my_orange_name,
|
26
|
+
:resource_action => :do_route,
|
27
|
+
:slug => @my_orange_name.to_s,
|
28
|
+
:link_text => @my_orange_name.to_s.capitalize,
|
29
|
+
:show_in_nav => true
|
30
|
+
)
|
31
|
+
end if (self.class.auto_sitemap || (self.class.auto_sitemap == nil))
|
15
32
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
33
|
+
|
34
|
+
def route_with_resource(packet, *args)
|
35
|
+
route = orange[:sitemap, true].url_for(packet,
|
36
|
+
:resource => @my_orange_name,
|
37
|
+
:resource_action => :do_route
|
38
|
+
)
|
39
|
+
route + args.compact.join('/')
|
19
40
|
end
|
20
|
-
|
21
|
-
|
41
|
+
|
42
|
+
def do_route(packet, opts = {})
|
43
|
+
resource_path = packet['route.resource_path']
|
44
|
+
parts = resource_path.split('/')
|
45
|
+
route(packet, parts, opts = {})
|
46
|
+
end
|
47
|
+
|
48
|
+
def route(packet, route_parts, opts = {})
|
49
|
+
if route_parts.blank?
|
50
|
+
list(packet, opts)
|
51
|
+
else
|
52
|
+
show(packet, opts.with_defaults({:resource_id => route_parts.first}))
|
53
|
+
end
|
22
54
|
end
|
23
55
|
end
|
@@ -9,6 +9,8 @@
|
|
9
9
|
= part[:js]
|
10
10
|
%link{:rel => "stylesheet", :type => "text/css", :href => "/assets/_sparkles_/js/markitup/skins/simple/style.css"}
|
11
11
|
%link{:rel => "stylesheet", :type => "text/css", :href => "/assets/_sparkles_/js/markitup/sets/markdown/style.css"}
|
12
|
+
:javascript
|
13
|
+
$(function(){$('.markdown-editor').markItUp(mySettings);})
|
12
14
|
%body{:id => packet["route.resource"].to_s}
|
13
15
|
%div#header
|
14
16
|
%div#user-status
|
@@ -25,10 +27,10 @@
|
|
25
27
|
%div.tab-container
|
26
28
|
/ %a.tab#home-tab{:href => "#"} Home
|
27
29
|
%a.tab#sitemap-tab{:href => route_to(:sitemap)} Pages
|
28
|
-
%a.tab#assets-tab{:href => route_to(:assets)} Assets
|
29
30
|
- for link in (orange[:sparkles].tabs || [])
|
30
31
|
%style= "body##{link[:resource]} a##{link[:resource]}-tab{ background: #999999;}"
|
31
32
|
%a.tab{:id => "#{link[:resource]}-tab", :href => route_to(link[:resource])}= link[:text]
|
33
|
+
%a.tab#assets-tab{:href => route_to(:assets)} Assets
|
32
34
|
%div#subheader
|
33
35
|
%h1
|
34
36
|
%img.subhead-icon{:src => "/assets/_sparkles_/images/edit.png", :width => "23", :height => "22", :alt => "Pages icon"}
|
@@ -4,9 +4,8 @@
|
|
4
4
|
%div#edit-box
|
5
5
|
%form#edit{:action => route_to(model_name, "new"), :method => "post", :"accept-charset" => "UTF-8"}
|
6
6
|
%label{:for => "edit-title"} Title
|
7
|
-
%input#publish-social{:type => "hidden", :name => "#{model_name}[publish_to_social]", :value => "0"}
|
8
7
|
%input#edit-title{:type => "text", :name => "#{model_name}[title]", :value => ""}
|
9
|
-
%textarea#edit-content{:cols => "32", :rows => "
|
8
|
+
%textarea#edit-content{:cols => "32", :rows => "20", :name => "#{model_name}[body]"}<= ''
|
10
9
|
%div#save-status
|
11
10
|
New Draft
|
12
11
|
%input#publish-me{:type => "hidden", :name => "#{model_name}[published]", :value => "0"}
|
@@ -43,13 +42,13 @@
|
|
43
42
|
/ %a.grey-button Add to Menu
|
44
43
|
/ %hr.one-px-grey
|
45
44
|
|
46
|
-
%div#publish_to_social.control-label
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
/ %div#publish_to_social.control-label
|
46
|
+
/ Publish to Social Media?
|
47
|
+
/ %div.slider-container
|
48
|
+
/ %div.slider-background.slider-background-yes-no
|
49
|
+
/ %div.slider-off
|
50
|
+
/ No
|
51
|
+
/ %hr.one-px-grey
|
53
52
|
%div#page-summary.control-label
|
54
53
|
Page Summary (optional)
|
55
54
|
%div.settings-collapse
|
@@ -6,7 +6,7 @@
|
|
6
6
|
%label{:for => "edit-title"} Title
|
7
7
|
- # Make it harder to republish to social by forcing publish to social off.
|
8
8
|
%input#edit-title{:type => "text", :name => "#{model_name}[title]", :value => model.title}
|
9
|
-
%textarea#edit-content{:cols => "32", :rows => "
|
9
|
+
%textarea#edit-content{:cols => "32", :rows => "20", :name => "#{model_name}[body]"}<= model.body
|
10
10
|
%div#save-status
|
11
11
|
#{model.published ? "Published" : "Draft saved"} #{fuzzy_time(model.updated_at)}
|
12
12
|
%input#publish-me{:type => "hidden", :name => "#{model_name}[published]", :value => "0"}
|
@@ -48,17 +48,17 @@
|
|
48
48
|
/ %a.grey-button Add to Menu
|
49
49
|
/ %hr.one-px-grey
|
50
50
|
|
51
|
-
%div#publish_to_social.control-label
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
/ %div#publish_to_social.control-label
|
52
|
+
/ Publish To Social Media?
|
53
|
+
/ %div.slider-container
|
54
|
+
/ %div.slider-background.slider-background-yes-no
|
55
|
+
/ - if model.publish_to_social && !model.published
|
56
|
+
/ %div.slider
|
57
|
+
/ Yes
|
58
|
+
/ - else
|
59
|
+
/ %div.slider-off
|
60
|
+
/ No
|
61
|
+
/ %hr.one-px-grey
|
62
62
|
%div#page-summary.control-label
|
63
63
|
Page Summary (optional)
|
64
64
|
%div.settings-collapse
|
@@ -0,0 +1,31 @@
|
|
1
|
+
- packet.add_js("page-list-effects.js", :module => "_sparkles_")
|
2
|
+
- is_short ||= false
|
3
|
+
.list-view
|
4
|
+
%table.tablesorter{:class => (is_short ? "is_short" : "")}
|
5
|
+
%thead
|
6
|
+
%tr.list-header-group
|
7
|
+
%th.list-header.page-listing-expand-collapse
|
8
|
+
- for prop in props
|
9
|
+
%th.list-header= prop[:name].to_s.gsub('_', ' ').capitalize
|
10
|
+
%td.list-header Actions
|
11
|
+
%tfoot
|
12
|
+
%tr
|
13
|
+
%td
|
14
|
+
- for prop in props
|
15
|
+
%td
|
16
|
+
%td
|
17
|
+
%a.button.add-button{:href => route_to(model_name, 'create')} New
|
18
|
+
%tbody
|
19
|
+
- for obj in list
|
20
|
+
%tr.page-listing-item= view_table_row(model_name, :model => obj)
|
21
|
+
.pager
|
22
|
+
%form
|
23
|
+
%img.first{:src=>"/assets/_sparkles_/images/tablesorter/first.png"}
|
24
|
+
%img.prev{:src=>"/assets/_sparkles_/images/tablesorter/prev.png"}
|
25
|
+
%input.pagedisplay{:type => "text"}
|
26
|
+
%img.next{:src=>"/assets/_sparkles_/images/tablesorter/next.png"}
|
27
|
+
%img.last{:src=>"/assets/_sparkles_/images/tablesorter/last.png"}
|
28
|
+
%select.pagesize
|
29
|
+
%option{:value => "5", :selected => is_short ? true : false} 5
|
30
|
+
%option{:value => "10", :selected => is_short ? false : true} 10
|
31
|
+
%option{:value => "25"} 25
|
@@ -2,5 +2,5 @@
|
|
2
2
|
%form{:action => "#{packet.route_to(model_name, 'new')}", :method => 'post', :"accept-charset" => "UTF-8"}
|
3
3
|
- packet["page.title"] = "#{model_name.to_s.capitalize} > Create"
|
4
4
|
- for prop in props
|
5
|
-
|
5
|
+
!~ view_attribute(prop, model_name, :label => true)
|
6
6
|
%input{:type => 'submit', :value => 'Save New Item'}
|
@@ -5,7 +5,10 @@
|
|
5
5
|
= orange[:sitemap, true].sitemap_links(packet, {:slug_me => orange[:sitemap, true].slug_for(model, props)})
|
6
6
|
%form{:action => packet.route_to(model_name, model[:id], 'save'), :method => 'post', :"accept-charset" => "UTF-8"}
|
7
7
|
- for prop in props
|
8
|
-
|
8
|
+
- if(prop[:relationship])
|
9
|
+
!~ view_attribute(prop, model_name, :label => true, :value => model.__send__(prop[:name]), :model => model)
|
10
|
+
- else
|
11
|
+
!~ view_attribute(prop, model_name, :label => true, :value => model.attribute_get(prop[:name]), :model => model)
|
9
12
|
%input{:type => 'submit', :value => 'Save Changes'}
|
10
13
|
- else
|
11
14
|
%p Couldn't find the item you're looking for.
|
@@ -1,31 +1,2 @@
|
|
1
|
-
-
|
2
|
-
|
3
|
-
.list-view
|
4
|
-
%table.tablesorter{:class => (is_short ? "is_short" : "")}
|
5
|
-
%thead
|
6
|
-
%tr.list-header-group
|
7
|
-
%th.list-header.page-listing-expand-collapse
|
8
|
-
- for prop in props
|
9
|
-
%th.list-header= prop[:name].to_s.gsub('_', ' ').capitalize
|
10
|
-
%td.list-header Actions
|
11
|
-
%tfoot
|
12
|
-
%tr
|
13
|
-
%td
|
14
|
-
- for prop in props
|
15
|
-
%td
|
16
|
-
%td
|
17
|
-
%a.button.add-button{:href => route_to(model_name, 'create')} New
|
18
|
-
%tbody
|
19
|
-
- for obj in list
|
20
|
-
%tr.page-listing-item= view_table_row(model_name, :model => obj)
|
21
|
-
.pager
|
22
|
-
%form
|
23
|
-
%img.first{:src=>"/assets/_sparkles_/images/tablesorter/first.png"}
|
24
|
-
%img.prev{:src=>"/assets/_sparkles_/images/tablesorter/prev.png"}
|
25
|
-
%input.pagedisplay{:type => "text"}
|
26
|
-
%img.next{:src=>"/assets/_sparkles_/images/tablesorter/next.png"}
|
27
|
-
%img.last{:src=>"/assets/_sparkles_/images/tablesorter/last.png"}
|
28
|
-
%select.pagesize
|
29
|
-
%option{:value => "5", :selected => is_short ? true : false} 5
|
30
|
-
%option{:value => "10", :selected => is_short ? false : true} 10
|
31
|
-
%option{:value => "25"} 25
|
1
|
+
- for obj in list
|
2
|
+
= view_summary(model_name, :model => obj)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
- packet.add_js("page-list-effects.js", :module => "_sparkles_")
|
2
|
+
- is_short ||= false
|
3
|
+
.list-view
|
4
|
+
%table.tablesorter{:class => (is_short ? "is_short" : "")}
|
5
|
+
%thead
|
6
|
+
%tr.list-header-group
|
7
|
+
%th.list-header.page-listing-expand-collapse
|
8
|
+
- for prop in props
|
9
|
+
%th.list-header= prop[:name].to_s.gsub('_', ' ').capitalize
|
10
|
+
%td.list-header Actions
|
11
|
+
%tfoot
|
12
|
+
%tr
|
13
|
+
%td
|
14
|
+
- for prop in props
|
15
|
+
%td
|
16
|
+
%td
|
17
|
+
%a.button.add-button{:href => route_to(model_name, 'create')} New
|
18
|
+
%tbody
|
19
|
+
- for obj in list
|
20
|
+
%tr.page-listing-item= view_table_row(model_name, :model => obj)
|
21
|
+
.pager
|
22
|
+
%form
|
23
|
+
%img.first{:src=>"/assets/_sparkles_/images/tablesorter/first.png"}
|
24
|
+
%img.prev{:src=>"/assets/_sparkles_/images/tablesorter/prev.png"}
|
25
|
+
%input.pagedisplay{:type => "text"}
|
26
|
+
%img.next{:src=>"/assets/_sparkles_/images/tablesorter/next.png"}
|
27
|
+
%img.last{:src=>"/assets/_sparkles_/images/tablesorter/last.png"}
|
28
|
+
%select.pagesize
|
29
|
+
%option{:value => "5", :selected => is_short ? true : false} 5
|
30
|
+
%option{:value => "10", :selected => is_short ? false : true} 10
|
31
|
+
%option{:value => "25"} 25
|
@@ -1,4 +1,7 @@
|
|
1
1
|
- if model
|
2
2
|
%div{ :class => model_name}
|
3
3
|
- for prop in props
|
4
|
-
|
4
|
+
- if(prop[:relationship])
|
5
|
+
!~ view_attribute(prop, model_name, :show => true, :value => model.__send__(prop[:name]), :model => model)
|
6
|
+
- else
|
7
|
+
!~ view_attribute(prop, model_name, :show => true, :value => model.attribute_get(prop[:name]), :model => model)
|
@@ -0,0 +1 @@
|
|
1
|
+
= view_show(model_name, :model => model)
|
@@ -2,7 +2,10 @@
|
|
2
2
|
%td.move
|
3
3
|
|
4
4
|
- for prop in props
|
5
|
-
|
5
|
+
- if(prop[:relationship])
|
6
|
+
%td= [:belongs, :has_one].include?(prop[:type]) ? (model.__send__(prop[:name]) ? model.__send__(prop[:name]).scaffold_name : "") : ""
|
7
|
+
- else
|
8
|
+
%td= model.attribute_get(prop[:name])
|
6
9
|
%td.actions
|
7
10
|
%div.page-listing-actions
|
8
11
|
%a.button.grey-button.preview-button{:href => route_to(model_name, model.id, "edit")}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Haslem
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-27 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/orange-sparkles/assets/js/popout-effects-page-edit.js
|
266
266
|
- lib/orange-sparkles/plugin.rb
|
267
267
|
- lib/orange-sparkles/sparkles_app.rb
|
268
|
+
- lib/orange-sparkles/sparkles_app_resource.rb
|
268
269
|
- lib/orange-sparkles/sparkles_resource.rb
|
269
270
|
- lib/orange-sparkles/templates/home.haml
|
270
271
|
- lib/orange-sparkles/templates/sparkles-admin.haml
|
@@ -287,11 +288,14 @@ files:
|
|
287
288
|
- lib/orange-sparkles/views/blog_posts/table_row.haml
|
288
289
|
- lib/orange-sparkles/views/contactforms/contactform.haml
|
289
290
|
- lib/orange-sparkles/views/contactforms/list.haml
|
291
|
+
- lib/orange-sparkles/views/default_resource/admin.list.haml
|
290
292
|
- lib/orange-sparkles/views/default_resource/create.haml
|
291
293
|
- lib/orange-sparkles/views/default_resource/edit.haml
|
292
294
|
- lib/orange-sparkles/views/default_resource/list.haml
|
295
|
+
- lib/orange-sparkles/views/default_resource/orange.list.haml
|
293
296
|
- lib/orange-sparkles/views/default_resource/show.haml
|
294
297
|
- lib/orange-sparkles/views/default_resource/sitemap_row.haml
|
298
|
+
- lib/orange-sparkles/views/default_resource/summary.haml
|
295
299
|
- lib/orange-sparkles/views/default_resource/table_row.haml
|
296
300
|
- lib/orange-sparkles/views/disqus/comment_thread.haml
|
297
301
|
- lib/orange-sparkles/views/news/archive.haml
|
@@ -358,5 +362,5 @@ rubygems_version: 1.3.6
|
|
358
362
|
signing_key:
|
359
363
|
specification_version: 3
|
360
364
|
summary: Adding some prettiness to orange-core
|
361
|
-
test_files:
|
362
|
-
|
365
|
+
test_files:
|
366
|
+
- examples/simple/cartons/bar.rb
|