[Soks] page templates/categories

[Soks] page templates/categories

Copied from Email on Sat, 05 Mar 2005 05:01:52 -0500 from Bil Kleb (Bil.Kleb@nasa.gov)

Hello,

Earlier, we had discussed adding various page categories, i.e.,
templates

FWIW, here is what I hacked in to get there:

start.rb:

# defined a new type of summary:
class AutomaticCategorySummary
   def initialize( wiki, pagename )
     plural = pagename.sub(/y$/,'ie') + 's'
     AutomaticSummary.new( wiki, {
                           :regexp_for_title => /#{pagename}:/i,
                           :lines_to_include => 10,
                           :reverse_sort => true,
                           :pagename => "All #{plural}" } )
     AutomaticSummary.new( wiki, {
                           :regexp_for_title => /#{pagename}:/i,
                           :max_pages_to_show => 1,
                           :lines_to_include => 10,
                           :reverse_sort => true,
                           :pagename => "Latest #{plural}" } )
   end
end

# added :categories key to the CUSTOMSETTINGS hash:
  :categories => [ 'Trip report', 'Contact', 'Phone Call', 'Idea', 'Story', 'Thought' ]

# added to self.start:
   CUSTOMSETTINGS[:categories].each do |name|
     AutomaticCategorySummary.new( wiki, name )
   end if CUSTOMSETTINGS.has_key? :categories

view/frame.rhtml:

# replaced "Add a new .*" section:
   Add new:
   <a href='<%= url 'Type a title here', 'edit' %>'>+ Page</a>
   <% if $SETTINGS.has_key? :categories %>
     <% $SETTINGS[:categories].each do |name| %>
       <a href='<%= url "#{name}: Type a title here", 'edit' %>'>+ <%= name %></a>
     <% end %>
   <% end %>
   <a href='<%= url 'Picture of Type a title here', 'edit' %>'>+ Image</a>
   <a href='<%= url 'Attached Type a title here', 'edit' %>'>+ File</a>

views/Page_edit.rhtml (per Tom):

  <td><input name='newtitle' size = '60' value='<%= pagename %>'
             onClick="this.value=this.value.replace('Type a title here','')"/></td>

Criticisms, reactions, or more graceful alternatives welcomed.

Regards,
--
Bil Kleb
http://fun3d.larc.nasa.gov
_______________________________________________
Soks-discuss mailing list
Soks-discuss@rubyforge.org
http://rubyforge.org/mailman/listinfo/soks-discuss

Edit this page or watch for changes using RSS.