Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new labeled view and title args

  • Loading branch information...
commit de200590fbbbed3e58413df8a4a17dd94fc684a3 1 parent d86d3b0
@ethn ethn authored
View
90 app/assets/stylesheets/card.css
@@ -15,6 +15,7 @@
html>body .open-view {
width: auto; /* so non-ie browsers do better with image floats */
}
+.card-frame .card-body,
.card-slot,
.ALL {
overflow: hidden;
@@ -208,9 +209,7 @@ fieldset > legend > .instruction {
/* for IE */
-div.content-view {
- display: inline;
-}
+
.conflict-view {
text-align: left;
background: #ffc;
@@ -292,15 +291,13 @@ del.diffmod,
margin: 0 0 4px 0;
}
-.help.content {
+/*.help.content {
padding: 10px;
margin-top: 5px;
color: #444;
-}
+}*/
.card-body {
- display: block;
- padding: 5px 12px;
- min-height: 25px;
+ padding: 5px 5px;
}
.instruction {
border-left: 0;
@@ -320,28 +317,55 @@ del.diffmod,
body#wagn .card-slot.recent-changes h2 {
margin-top: 15px;
}
-.last-update {
- color: #666;
-/* margin-right: 5px; */
-}
-/*-------------- STATES -----------*/
-/*----------- open cards -------*/
+/*-------------- VIEWS -----------*/
- /* means content view */
-.content-content {
+/*-------------- content view ------ */
+.content-view {
display: inline;
- padding: 0;
}
+/*----------- titled view -------*/
+
+
.titled-view > .card-header {
background: inherit;
- padding: 0;
}
-/*------------- closed cards -------*/
+.titled-view > .card-header,
+.titled-view > .card-body {
+ padding-left: 0;
+ padding-right: 0;
+}
+
+
+/*----------- related view -------*/
+
+
+
+.related-view > .card-body {
+ background: #ddd;
+ padding: 5px;
+}
+.related-view > .card-body > .ALL {
+ background: #ddd;
+ background: #fff;
+ border-radius: 6px;
+}
+.related-view > .card-body > .ALL > .card-header {
+ background: #eee;
+}
+.related-view > .card-body > .ALL > .card-header h1 {
+ color: #000;
+}
+.related-view > .card-body > .ALL > .card-header,
+.related-view > .card-body > .ALL > .card-body {
+ padding: 5px;
+}
+
+/*------------- closed view -------*/
.closed-view {
width: 100%; /*needed for ie6, or..?*/
@@ -418,6 +442,7 @@ body#wagn .card-slot.recent-changes h2 {
float: left;
}
.change-view .last-update {
+ color: #666;
float:right;
text-align: right;
}
@@ -428,7 +453,27 @@ body#wagn .card-slot.recent-changes h2 {
white-space: nowrap;
}
+/*----------- Labeled View ---------*/
+
+
+.labeled-view .card-menu-link {
+ display: none;
+}
+.labeled-view:hover .card-menu-link {
+ display: inline-block;
+}
+a.missing-labeled,
+.labeled-view label {
+ display: inline-block;
+ min-width: 20%;
+ text-align: right;
+}
+.labeled-view label h1,
+.labeled-view .pointer-list,
+.labeled-view .pointer-item {
+ display: inline;
+}
/* CARDTYPE_SPECIFIC ------------------------------*/
@@ -513,7 +558,6 @@ div.search-result-list .search-result-item {
.pointer-item.item-link,
.search-result-item.item-name,
.pointer-item.item-name {
- display: block;
text-indent: -15px;
padding-left: 15px;
}
@@ -524,11 +568,7 @@ div.search-result-list .search-result-item {
/*-----------( Image ) -----------*/
-/*
-.open-view .TYPE-image .content {
- padding: 5px;
-}
-*/
+
/*-----------( Toggle ) -----------*/
View
3  app/assets/stylesheets/print.css
@@ -12,9 +12,6 @@
.title {
font-size: 15px;
}
-.card-slot.paragraph .content {
- overflow: visible !important;
-}
body#wagn {
color: #444;
font-style: normal;
View
16 lib/chunks/include.rb
@@ -2,7 +2,12 @@
module Chunks
class Include < Reference
- attr_reader :options
+# attr_reader :options
+ cattr_reader :options
+ @@options = [ :include_name, :view, :item, :type, :size, :title, :hide, :show, :include ].
+ inject({}) do |hash, key| hash[key] = nil; hash end
+
+# attr_reader :options
unless defined? INCLUDE_CONFIG
# {{+name|attr:val;attr:val;attr:val}}
# Groups: $1, everything (less {{}}), $2 name, $3 options
@@ -32,12 +37,7 @@ def parse match, params
when /^\#/ ; "<!-- #{CGI.escapeHTML in_brackets} -->"
when '' ; '' # no name
else
- @options = {
- :include_name => name,
- :view => nil, :item => nil, :type => nil, :size => nil,
- :hide => nil, :show => nil, :wild => nil, :include => in_brackets, #yuck, need better name (this is raw stuff)
-
- }
+ @options = @@options.clone.merge :include_name => name, :include => in_brackets #yuck, need better name (this is raw stuff)
@configs = Hash.new_from_semicolon_attr_list opts
@@ -74,7 +74,7 @@ def process_chunk
view = view.to_sym
end
- @processed = yield options # this is not necessarily text, sometimes objects for json
+ @processed = yield @options # this is not necessarily text, sometimes objects for json
end
def replace_reference old_name, new_name
View
15 lib/wagn/renderer.rb
@@ -25,12 +25,7 @@ class Renderer
@@view_tags = {}
def self.get_renderer format
- #warn "get_renderer #{format.inspect}"
- const_get( if RENDERERS.has_key? format
- RENDERERS[ format ]
- else
- format.to_s.camelize.to_sym
- end )
+ const_get( ( RENDERERS[ format ] || format.to_s.camelize.to_sym ) )
end
attr_reader :format, :card, :root, :parent
@@ -88,8 +83,12 @@ def controller() @controller ||= StubCardController.new en
def session() CardController===controller ? controller.session : {} end
def ajax_call?() @@ajax_call end
- def showname
- @showname ||= card.cardname.to_show *@context_names
+ def showname title=nil
+ if title
+ title.to_name.to_absolute_name(card.cardname).to_show *@context_names
+ else
+ @showname ||= card.cardname.to_show *@context_names
+ end
end
def main?
View
10 lib/wagn/renderer/html.rb
@@ -169,7 +169,7 @@ def wrap view, args = {}
:style=>args[:style]
}
- [:home_view, :item, :include, :show, :hide, :size].each do |key|
+ ( [:home_view ] + Chunks::Include.options.keys ).each do |key|
attributes["slot-#{key}"] = args[key] if args[key].present?
end
@@ -186,7 +186,9 @@ def wrap view, args = {}
end
def wrap_content view, args={}
- raw %{<span class="#{view}-content content #{'card-body' if args[:body] } #{args[:class]}">#{ yield }</span>}
+ tag_type = args[:body] ? :div : :span
+ klass = ["#{view}-content content", args[:class], ('card-body' if args[:body])].compact * ' '
+ content_tag( tag_type, :class=>klass ) { yield }
end
def wrap_main(content)
@@ -357,8 +359,8 @@ def help_text *opts
%{<div class="instruction">#{raw text}</div>} if text
end
- def fancy_title name=nil
- name ||= showname
+ def fancy_title title=nil
+ name = showname(title)
title = name.to_name.parts.join %{<span class="joint">+</span>}
raw title
end
View
2  lib/wagn/set/all/base.rb
@@ -26,7 +26,7 @@ module Set::All::Base
define_view :link, :perms=>:none do |args|
name = card.name
- card_link name, name, card.known?
+ card_link name, showname( args[:title] ), card.known?
end
define_view :open_content do |args|
View
48 lib/wagn/set/all/rich_html.rb
@@ -37,22 +37,44 @@ module Set::All::RichHtml
define_view :titled do |args|
wrap :titled, args do
- _render_header( args.merge :menu_default_hidden=>true ) +
- wrap_content( :titled ) do
- %{
- #{ _render_core args }
- #{ optional_render :comment_box, args }
- #{ notice }
+ %{
+ #{ _render_header args.merge( :menu_default_hidden=>true ) }
+ #{ wrap_content( :titled, :body=>true ) { _render_core args } }
+ #{ optional_render :comment_box, args }
+ #{ notice }
+ }
+ end
+ end
+
+ define_view :labeled do |args|
+ wrap :labeled, args do
+ %{
+ #{ _optional_render :menu, args }
+
+ <label>
+ #{ _render_title args }
+ </label>
+ #{
+ wrap_content :titled do
+ _render_closed_content args
+ end
}
- end
+ }
end
end
define_view :title do |args|
- t = content_tag :h1, fancy_title, :class=>'card-title'
+ title = content_tag :h1, fancy_title( args[:title] ), :class=>'card-title'
+ title = _optional_render( :title_link, args.merge( :title_ready=>title ), default_hidden=true ) || title
add_name_context
- t
+ title
end
+
+ define_view :title_link do |args|
+ link_to_page (args[:title_ready] || showname(args[:title]) ), card.name
+ end
+
+
define_view :open do |args|
args[:toggler] = link_to '', path(:view=>:closed), :title => "close #{card.name}", :remote => true,
@@ -71,7 +93,7 @@ module Set::All::RichHtml
%{
<div class="card-header">
#{ args.delete :toggler }
- #{ _render_title }
+ #{ _render_title args }
#{ _optional_render :menu, args, args[:menu_default_hidden] || false }
</div>
}
@@ -176,7 +198,7 @@ module Set::All::RichHtml
#{ hidden_field_tag :success, card.rule(:thanks) || '_self' }
#{
case
- when name_ready ; _render_title + hidden_field_tag( 'card[name]', card.name )
+ when name_ready ; _render_title(args) + hidden_field_tag( 'card[name]', card.name )
when card.rule_card( :autoname ) ; ''
else ; _render_name_editor
end
@@ -208,8 +230,8 @@ module Set::All::RichHtml
new_args['card[type]'] = args[:type] if args[:type]
wrap :missing, args do
- link_to raw("Add <strong>#{ showname }</strong>"), path(new_args),
- :class=>'slotter', :remote=>true
+ link_to raw("Add <strong>#{ showname args[:title] }</strong>"), path(new_args),
+ :class=>"slotter missing-#{args[:denied_view]}", :remote=>true
end
end
View
2  lib/wagn/set/all/rss.rb
@@ -45,7 +45,7 @@ module Set::All::Rss
define_view :titled do |args|
# content includes wrap (<object>, etc.) , which breaks at least safari rss reader.
- content_tag( :h2, showname ) + self._render_open_content(args) { yield }
+ content_tag( :h2, showname(args[:title]) ) + self._render_open_content(args) { yield }
end
alias_view(:titled, {}, :open)
alias_view(:open_content,{}, :content)
View
2  lib/wagn/set/type/file_and_image.rb
@@ -42,7 +42,7 @@ module Set::Type::FileAndImage
define_view :core, :type=>'file' do |args|
handle_source args do |source|
- "<a href=\"#{source}\">Download #{ showname }</a>"
+ "<a href=\"#{source}\">Download #{ showname args[:title] }</a>"
end
end
View
23 spec/lib/wagn/renderer_spec.rb
@@ -155,12 +155,12 @@
end
it "titled" do
- result = render_card(:titled, :name=>'A+B')
+ result = render_card :titled, :name=>'A+B'
assert_view_select result, 'div[class~="titled-view"]' do
assert_select 'h1' do
assert_select 'span'
end
- assert_select 'span[class~="titled-content"]', 'AlphaBeta'
+ assert_select 'div[class~="titled-content"]', 'AlphaBeta'
end
end
@@ -174,7 +174,7 @@
assert_select 'div[class="card-header"]' do
assert_select 'h1[class="card-title"]'
end
- assert_select 'span[class~="card-body"]'
+ assert_select 'div[class~="card-body"]'
end
end
@@ -200,12 +200,15 @@
end
it "should render setting view for a *input rule" do
- r = Wagn::Renderer.new(Card.fetch('*read+*right+*input',:new=>{})).render_open_rule
- r.should_not match(/error/i)
- r.should_not match('No Card!')
- assert_view_select r, 'tr[class="card-slot edit-rule"]' do
- assert_select 'input[id="success"][name="success"][type="hidden"][value="*read+*right+*input"]'
- end
+ Account.as_bot do
+ r = Wagn::Renderer.new(Card.fetch('*read+*right+*input',:new=>{})).render_open_rule
+ r.should_not match(/error/i)
+ r.should_not match('No Card!')
+ # warn "r = #{r}"
+ assert_view_select r, 'tr[class="card-slot edit-rule"]' do
+ assert_select 'input[id="success"][name="success"][type="hidden"][value="*read+*right+*input"]'
+ end
+ end
end
end
@@ -239,7 +242,7 @@
it "renders card content" do
#warn "simple page = #{@simple_page}"
- assert_view_select @simple_page, 'span[class="open-content content card-body "]', 'AlphaBeta'
+ assert_view_select @simple_page, 'div[class="open-content content card-body"]', 'AlphaBeta'
end
it "renders notice info" do
Please sign in to comment.
Something went wrong with that request. Please try again.