Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

structure arg and slot options

  • Loading branch information...
commit 6a4a894cbbb92f0d51f783065af905f418d2f4cd 1 parent 9bec493
@ethn ethn authored
View
2  app/assets/stylesheets/card.css
@@ -27,7 +27,7 @@ html>body .open-view {
}
.card-body {
- padding: 5px 12px;
+ padding: 5px 1.5%;
}
View
5 app/assets/stylesheets/page.css
@@ -46,7 +46,7 @@
#logo {
text-align: center;
- padding: 10px 0px;
+ padding: 10px;
background: #fff;
border: 1px solid #777;
-moz-border-radius: 8px;
@@ -59,6 +59,9 @@
text-decoration: none;
text-align: center;
}
+#logo img {
+ width: 100%;
+}
View
2  lib/chunks/include.rb
@@ -4,7 +4,7 @@ module Chunks
class Include < Reference
# attr_reader :options
cattr_reader :options
- @@options = [ :include_name, :view, :item, :type, :size, :title, :hide, :show, :include ].
+ @@options = [ :include_name, :view, :item, :type, :size, :title, :hide, :show, :include, :structure ].
inject({}) do |hash, key| hash[key] = nil; hash end
# attr_reader :options
View
3  lib/wagn/renderer.rb
@@ -239,7 +239,8 @@ def ok_view view, args={}
else
args[:denied_task] = [perms_required].flatten.find do |task|
task = :create if task == :update && card.new_card?
- !card.ok? task
+ @ok ||= {}
+ @ok[task].nil? ? @ok[task] = !card.ok?(task) : @ok[task]
end
end
args[:denied_task] ? (@@denial_views[view] || :denial) : view
View
9 lib/wagn/renderer/html.rb
@@ -158,6 +158,9 @@ def layout_from_card
lo_card.content
end
+ def slot_options
+ @@slot_options ||= Chunks::Include.options.keys.reject { |k| k == :view }.unshift :home_view
+ end
def wrap view, args = {}
classes = ['card-slot', "#{view}-view"]
@@ -169,7 +172,7 @@ def wrap view, args = {}
:style=>args[:style]
}
- ( [:home_view ] + Chunks::Include.options.keys ).each do |key|
+ slot_options.each do |key|
attributes["slot-#{key}"] = args[key] if args[key].present?
end
@@ -360,9 +363,7 @@ def help_text *opts
end
def fancy_title title=nil
- name = showname(title)
- title = name.to_name.parts.join %{<span class="joint">+</span>}
- raw title
+ raw %{<span class="card-title">#{showname(title).to_name.parts.join %{<span class="joint">+</span>} }</span>}
end
def load_revisions
View
29 lib/wagn/set/all/base.rb
@@ -11,22 +11,25 @@ module Set::All::Base
render( args[:view] || :core )
end
- define_view :raw do |args| card ? card.raw_content : _render_blank end
- define_view :core do |args| process_content _render_raw end
- define_view :content do |args| _render_core end
+ define_view :raw do |args|
+ scard = args[:structure] ? Card[ args[:structure] ] : card
+ scard ? scard.raw_content : _render_blank
+ end
+
+ define_view :core do |args| process_content _render_raw(args) end
+ define_view :content do |args| _render_core args end
# this should be done as an alias, but you can't make an alias with an unknown view,
# and base renderer doesn't know "content" at this point
- define_view :titled do |args| card.name + "\n\n" + _render_core end
-
- define_view :name, :perms=>:none do |args| card.name end
- define_view :key, :perms=>:none do |args| card.key end
- define_view :id, :perms=>:none do |args| card.id end
- define_view :linkname, :perms=>:none do |args| card.cardname.url_key end
- define_view :url, :perms=>:none do |args| wagn_url _render_linkname end
+ define_view :titled do |args| card.name + "\n\n" + _render_core(args) end
+
+ define_view :name, :perms=>:none do |args| card.name end
+ define_view :key, :perms=>:none do |args| card.key end
+ define_view :id, :perms=>:none do |args| card.id end
+ define_view :linkname, :perms=>:none do |args| card.cardname.url_key end
+ define_view :url, :perms=>:none do |args| wagn_url _render_linkname end
define_view :link, :perms=>:none do |args|
- name = card.name
- card_link name, showname( args[:title] ), card.known?
+ card_link card.name, showname( args[:title] ), card.known?
end
define_view :open_content do |args|
@@ -42,7 +45,7 @@ module Set::All::Base
define_view :array do |args|
if card.collection?
card.item_cards(:limit=>0).map do |item_card|
- subrenderer(item_card)._render_core
+ subrenderer(item_card)._render_core(args)
end
else
[ _render_core(args) ]#{ yield } ]
View
2  lib/wagn/set/all/kml.rb
@@ -34,7 +34,7 @@ module Set::All::Kml
xml.Placemark do
xml.name cardname
if desc_card = Card.fetch("#{cardname}+*geodescription") and desc_card.ok? :read
- xml.description Wagn::Renderer.new(desc_card).render_core
+ xml.description Wagn::Renderer.new(desc_card).render_core(args)
end
xml.Point do
# apparently the google API likes them in the opposite order for static maps.
View
24 lib/wagn/set/all/rich_html.rb
@@ -77,8 +77,11 @@ module Set::All::RichHtml
define_view :open do |args|
- args[:toggler] = link_to '', path(:view=>:closed), :title => "close #{card.name}", :remote => true,
- :class => "close-icon ui-icon ui-icon-circle-triangle-s toggler slotter nodblclick"
+ args[:toggler] = link_to '', path( :view=>:closed ),
+ :remote => true,
+ :title => "close #{card.name}",
+ :class => "close-icon ui-icon ui-icon-circle-triangle-s toggler slotter nodblclick"
+
wrap :open, args.merge(:frame=>true) do
%{
#{ _render_header args }
@@ -142,12 +145,14 @@ module Set::All::RichHtml
end
define_view :closed do |args|
- args[:toggler] = link_to '', path(:view=>:open), :title => "open #{card.name}", :remote => true,
+ args[:toggler] = link_to '', path( :view=>:open ),
+ :remote => true,
+ :title => "open #{card.name}",
:class => "open-icon ui-icon ui-icon-circle-triangle-e toggler slotter nodblclick"
wrap :closed, args do
%{
#{ render_header args }
- #{ wrap_content( :closed ) { _render_closed_content } }
+ #{ wrap_content( :closed ) { _render_closed_content args } }
}
end
end
@@ -172,8 +177,8 @@ module Set::All::RichHtml
define_view :new, :perms=>:create, :tags=>:unknown_ok do |args|
name_ready = !card.cardname.blank? && !Card.exists?( card.cardname )
- cancel = if ajax_call?
- { :class=>'slotter', :href=>path(:view=>:missing) }
+ cancel = if ajax_call? # shouldn't this be main? ??
+ { :class=>'slotter', :href=>path( :view=>:missing ) }
else
{ :class=>'redirecter', :href=>Card.path_setting('/*previous') }
end
@@ -230,8 +235,8 @@ module Set::All::RichHtml
new_args['card[type]'] = args[:type] if args[:type]
wrap :missing, args do
- link_to raw("Add <strong>#{ showname args[:title] }</strong>"), path(new_args),
- :class=>"slotter missing-#{args[:denied_view]}", :remote=>true
+ link_to raw("Add #{ fancy_title args[:title] }"), path(new_args),
+ :class=>"slotter missing-#{ args[:denied_view] || args[:home_view]}", :remote=>true
end
end
@@ -471,8 +476,7 @@ module Set::All::RichHtml
)}}
end
- define_view :new_account,
- :perms=> lambda { |r| r.card.accountable? } do |args|
+ define_view :new_account, :perms=> lambda { |r| r.card.accountable? } do |args|
wrap :new_account, args.merge(:frame=>true) do
%{
#{ _render_header }
View
3  lib/wagn/set/type/pointer.rb
@@ -116,8 +116,7 @@ def item_cards( args={} )
def item_names( args={} )
context = args[:context] || self.cardname
- cc=self.raw_content
- self.content.split(/\n+/).map{ |line|
+ self.raw_content.split(/\n+/).map{ |line|
line.gsub(/\[\[|\]\]/,'')
}.map{ |link| context==:raw ? link : link.to_name.to_absolute(context) }
end
View
4 spec/lib/wagn/renderer_spec.rb
@@ -103,7 +103,7 @@
it "missing relative inclusion is relative" do
c = Card.new :name => 'bad_include', :content => "{{+bad name missing}}"
rr=(r=Wagn::Renderer.new(c))._render(:titled)
- rr.match(Regexp.escape(%{Add <strong>+bad name missing</strong>})).should_not be_nil
+ rr.match(/Add.*\+.*bad name missing/).should_not be_nil
end
it "renders deny for unpermitted cards" do
@@ -571,7 +571,7 @@
context "missing" do
it "should prompt to add" do
- render_content('{{+cardipoo|open}}').match(/Add \<strong\>/ ).should_not be_nil
+ render_content('{{+cardipoo|open}}').match(/Add \<span/ ).should_not be_nil
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.