Skip to content

Commit

Permalink
more movement from helpers, use of #typename, css cleanup, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
ethn committed Mar 13, 2012
1 parent 22d830f commit d7f8815
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 142 deletions.
75 changes: 33 additions & 42 deletions app/assets/stylesheets/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ html>body .card-menu-left,
html>body .page-icon {
display: none;
}
.closed-view .card-header {
padding-right: 22px;
}
.closed-view div:hover.card-header {
padding-right: 0px;
}


div:hover.setting .page-icon,
div:hover.card-header .page-icon,
Expand Down Expand Up @@ -210,7 +205,7 @@ a.wanted-card {
color: #900
}
a.external-link,
.closed-view .content a.external-link {
.closed-content a.external-link {
color: #979;
background: url(external_link.png) center right no-repeat;
padding-right: 13px !important;
Expand Down Expand Up @@ -565,13 +560,15 @@ body#wagn .card-slot.recent-changes h2 {
/* necessary for IE6 */
height: 25px;
}

.closed-view .content,
.closed-view .card-header {
padding-right: 22px;
display: inline;
float: left;
vertical-align: center;
}
.closed-view div:hover.card-header {
padding-right: 0px;
}
.closed-view .card-header {
line-height: 15px;
-moz-border-radius: 0px 6px 6px 0px;
Expand All @@ -581,53 +578,47 @@ body#wagn .card-slot.recent-changes h2 {
margin-right: 4px;
}

.closed-view tr,
.closed-view td,
.closed-view p,
.closed-view h1,
.closed-view h2,
.closed-view h3,
.closed-view h4,
.closed-view h5,
.closed-view h6,
.closed-view ul,
.closed-view li,
.closed-view pre,
.closed-view ol,
.closed-view hr,
.closed-view .content div,
.closed-view .content span,
.closed-view .content,
.closed-view .workspace,
.closed-view .content a,
.closed-view blockquote {
display: inline;
.closed-content,
.closed-content tr,
.closed-content td,
.closed-content p,
.closed-content h1,
.closed-content h2,
.closed-content h3,
.closed-content h4,
.closed-content h5,
.closed-content h6,
.closed-content ul,
.closed-content li,
.closed-content pre,
.closed-content ol,
.closed-content hr,
.closed-content div,
.closed-content span,
.closed-content a,
.closed-content blockquote {
display: inline !important;
margin: 0px 4px;
padding: 0px !important;
border: 0px !important;
font-size: 11px !important;
white-space: nowrap;
float: none !important;
}
.closed-view .content a {
.closed-content a {
margin: 0px;
}
.closed-view .content img {
.closed-content img {
height: 16px;
width: auto;
float: none;
padding: 0px;
}
.closed-view br,
.closed-view hr,
.closed-view input,
.closed-view textarea,
.closed-view object,
.closed-view .comment-box,
.closed-view .table-of-contents,
.closed-view .card-menu,
.closed-view .card-footer,
.closed-view .close-link {
.closed-content br,
.closed-content hr,
.closed-content input,
.closed-content textarea,
.closed-content object {
display: none !important;
}
/*----------- Change View ---------*/
Expand Down
8 changes: 4 additions & 4 deletions app/assets/stylesheets/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ td.rule-setting {
.closed-rule .rule-content div {
padding: 0;
}
.rule-content-container.closed-view {
.rule-content-container {
width: 350px;
overflow: hidden;
text-overflow: ellipsis;
line-height: inherit;
background: inherit;
}
.rule-content-container.closed-view .pointer-list,
.rule-content-container.closed-view .search-list,
.rule-content-container.closed-view .content {
.rule-content-container .closed-content,
.rule-content-container .closed-content .pointer-list,
.rule-content-container .closed-content .search-list {
margin: 0;
}
td.missing-rule {
Expand Down
9 changes: 1 addition & 8 deletions app/helpers/location_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module LocationHelper
#
def location_history
# warn "sess #{session.class}, #{session.object_id}"
session[:history] ||= ['/']
session[:history] ||= [wagn_path('')]
if session[:history]
session[:history].shift if session[:history].size > 5
session[:history]
Expand Down Expand Up @@ -78,11 +78,4 @@ def link_to_page( text, title=nil, options={})
link_to text, url, options
end

def card_title_span( title )
%{<span class="namepart-#{title.to_cardname.css_name}">#{title}</span>}
end

def page_icon(cardname)
link_to_page '&nbsp;'.html_safe, cardname, {:class=>'page-icon', :title=>"Go to: #{cardname.to_s}"}
end
end
42 changes: 0 additions & 42 deletions app/helpers/wagn_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ module WagnHelper
require_dependency 'wiki_content'
include HTMLDiff

# FIXME: slot -> renderer (model)
# Put the initialization in the controller and we no longer care here
# whether it is a Slot or Renderer, and it will be from the parent class
# Now: Always a Renderer, and the subclass is selected by:
# :format => :html (default and only -> Wagn::Renderer::Html (was Slot))

#=begin
def slot() Wagn::Renderer.current_slot end
def card() @card ||= slot.card end

Expand Down Expand Up @@ -67,41 +60,6 @@ def truncatewords_with_closing_tags(input, words = 25, truncate_string = "...")
end


def formal_title(card)
card.cardname.parts.join " <span class=\"wiki-joint\">+</span> "
end

def fancy_title(card)
cardname = (Card===card ? card.cardname : card.to_cardname)
return cardname if cardname.simple?
card_title_span(cardname.left_name) + %{<span class="joint">+</span>} +
card_title_span(cardname.tag_name)
end

# Other snippets -------------------------------------------------------------


def format_date(date, include_time = true)
# Must use DateTime because Time doesn't support %e on at least some platforms
if include_time
DateTime.new(date.year, date.mon, date.day, date.hour, date.min, date.sec).strftime("%B %e, %Y %H:%M:%S")
else
DateTime.new(date.year, date.mon, date.day).strftime("%B %e, %Y")
end
end

## ----- for Linkers ------------------
def typecode_options
Cardtype.createable_types.map do |type|
[type[:name], type[:name]]
end.compact
end

def typecode_options_for_select(selected=Card.default_typecode_key)
#warn "SELECTED = #{selected}"
options_from_collection_for_select(typecode_options, :first, :last, selected)
end


def error_messages_for(object)
if object && object.errors.any?
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def change_notice( user, card, action, watched, subedits=[], updated_card=nil )
def flexmail config
@message = config.delete(:message)

if attachment_list = config.delete(:attach)
if attachment_list = config.delete(:attach) and !attachment_list.empty?
attachment_list.each_with_index do |cardname, i|
if c = Card[ cardname ] and c.respond_to?(:attach)
attachments["attachment-#{i + 1}.#{c.attach_extension}"] = File.read( c.attach.path )
Expand Down
14 changes: 3 additions & 11 deletions lib/old_modules/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ def trunk_watcher_watched_pairs

def watcher_watched_pairs
author = User.current_user.card.cardname
(card_watchers.except(author).map {|watcher| [Card[watcher].extension,self.cardname] } +
type_watchers.except(author).map {|watcher|
#Rails.logger.info "watcher #{watcher.inspect}, #{::Cardtype.name_for(self.typecode)}"
[cd=Card[watcher].extension,::Cardtype.name_for(self.typecode)]})
card_watchers.except(author).map { |watcher| [ Card[watcher].extension, self.cardname ] } +
type_watchers.except(author).map { |watcher| [ Card[watcher].extension, self.typename ] }
end

def card_watchers
Expand All @@ -65,19 +63,13 @@ def card_watchers
end

def type_watchers
#Rails.logger.debug "type_watchers #{Cardtype.name_for(self.typecode).to_s+"+*watchers"}"
items_from("#{Cardtype.name_for(self.typecode).to_s}+*watchers" )
items_from("#{self.typename}+*watchers" )
end

def items_from( name )
#Rails.logger.info "items_from (#{name.inspect})"
User.as :wagbot do
(c = Card[name.to_cardname]) ? c.item_names.reject{|x|x==''}.map(&:to_cardname) : []
#(c = Card[name.to_cardname]) ?
# begin
# r1=c.item_names; r2=r1.reject{|x|x==''}; r3=r2.map(&:to_cardname)
# Rails.logger.info "items from 2 #{c.new_record?}, #{r1.inspect}, #{r2.inspect}, #{r3.inspect}"; r3
# end : []
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/packs/default/rich_html_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class Wagn::Renderer::Html
:class => "line-link title down-arrow slotter", :remote => true }
#{ unless card.typecode=='Basic'
%{<span class="cardtype">#{ link_to_page( Cardtype.name_for(card.typecode) ) }</span>}
%{<span class="cardtype">#{ link_to_page card.typename }</span>}
end }
#{ page_icon(card.name) } &nbsp;
Expand Down Expand Up @@ -647,7 +647,7 @@ def form_opts url, classes='', other_html={}
private

def watching_type_cards
"watching #{link_to_page(Cardtype.name_for(card.typecode))} cards" # can I parse this and get the link to happen? that wud r@wk.
"watching #{ link_to_page card.typename } cards" # can I parse this and get the link to happen? that wud r@wk.
end

def watch_unwatch
Expand Down
4 changes: 2 additions & 2 deletions lib/packs/right/rstar_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Wagn::Renderer::Html
:class => 'edit-rule-link slotter', :remote => true )
],
["rule-content",
%{<div class="rule-content-container closed-view">
<span class="content">#{rule_card ? subrenderer(rule_card).render_closed_content : ''}</span>
%{<div class="rule-content-container">
<span class="closed-content content">#{rule_card ? subrenderer(rule_card).render_closed_content : ''}</span>
</div> } ],
["rule-type", (rule_card ? rule_card.typename : '') ],
]
Expand Down
2 changes: 1 addition & 1 deletion lib/packs/type/file_and_image_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Wagn::Renderer
end

define_view(:source, :type=>'image') do |args|
attach_url( args[:size] || :medium )
attach_url( @mode==:closed ? :icon : ( args[:size] || :medium ) )
end

define_view(:source, :type=>'file') do |args|
Expand Down
10 changes: 8 additions & 2 deletions lib/packs/type/plaintext_phrase_html_and_number_pack.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
class Wagn::Renderer
define_view(:core, :type=>'plain_text') do |args|
process_content(_render_raw).gsub(/\n/, '<br/>')
class Html
define_view(:core, :type=>'plain_text') do |args|
process_content(_render_raw).gsub(/\n/, '<br/>')
end
end

define_view(:core, :type=>'plain_text') do |args|
process_content(_render_raw)
end

define_view(:editor, :type=>'plain_text') do |args|
form.text_area :content, :rows=>3, :class=>'card-content'
end
Expand Down
41 changes: 19 additions & 22 deletions lib/packs/type/search_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,35 @@ class Wagn::Renderer
define_view(:card_list, :type=>'search') do |args|
cards = args[:results]
@item_view ||= (card.spec[:view]) || :closed

instruction, title = nil,nil
if card.name=='*search' && search_params[:vars] && keyword=search_params[:vars][:keyword]
instruction = %{Cards matching keyword: <strong class="keyword">#{keyword}</strong>} #ENGLISH
title = 'Search Results' #ENGLISH
end

paging = render(:paging, :results=>cards)

# now the result string ...
if title
%{<h1 class="page-header">#{ title }</h1>}
else '' end +
if instruction; %{
<div class="instruction">
<p>#{ instruction }</p>
</div>}
else '' end +
_render_search_header +
if cards.empty?
%{<div class="search-no-results"></div>}
else %{#{paging}
<div class="search-result-list"> #{
else
%{
#{paging}
<div class="search-result-list"> #{
cards.map do |c|
%{<div class="search-result-item item-#{ @item_view }">#{
process_inclusion(c, :view=>@item_view) }</div>}
%{<div class="search-result-item item-#{ @item_view }">
#{ process_inclusion c, :view=>@item_view }
</div>}
end.join }
</div>#{ paging }}
</div>
#{ paging }
}
end
end

define_view :search_header do |args|
''
end



define_view :search_header, :name=>'*search' do |args|
return '' unless vars = search_params[:vars] and keyword = vars[:keyword]
%{<h1 class="page-header search-result-header">Search results for: <em>#{keyword}</em></h1>}
end

define_view(:card_list, :name=>'*recent') do |args|
cards = args[:results]
Expand Down
Loading

0 comments on commit d7f8815

Please sign in to comment.