[
https://issues.apache.org/jira/browse/WHIMSY-81?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15957062#comment-15957062
]
Sam Ruby commented on WHIMSY-81:
--------------------------------
Ruby (like JavaScript, but unlike Java and Python) has a concept of open
classes. So if you have an existing class and you want to modify it (for
example, by adding a method), you just do it. For example:
```
require 'wunderbar'
class Wunderbar::HtmlMarkup
def _asf_head style, title
case style
when :fullsize
_h1 title
else
_h3 title
end
end
end
_html do
_asf_head :minisize, 'Hello World!'
end
```
Note that that code doesn't have to be in the wunderbar source repository, it
can be in your code, or in the whimsy/asf library.
A good place to add that would be adding a new file here:
https://github.com/apache/whimsy/tree/master/lib/whimsy/asf, perhaps with a
name like htmltags or somesuch. That new file would need to be required to be
used. If you want this to be opt-in, any code that would want to use it would
need to add:
```
require 'whimsy/asf/htmltags'
```
If you want it to be available by default, add a require_relative line to
https://github.com/apache/whimsy/blob/master/lib/whimsy/asf.rb
Note: if you want to run from the lastest copy of the library that you have on
your machine, you will need one of those rather ugly lines that look like:
$LOAD_PATH.unshift File.realpath(File.expand_path('../../../lib', __FILE__))
> Configurable overrides for _head(fullsize|mini, title) and similar look &
> feel outputs
> --------------------------------------------------------------------------------------
>
> Key: WHIMSY-81
> URL: https://issues.apache.org/jira/browse/WHIMSY-81
> Project: Whimsy
> Issue Type: Wish
> Components: Core
> Reporter: Shane Curcuru
> Assignee: Sam Ruby
>
> Whimsy is turning into a larger collection of useful tools, both for
> organizational processes as well as informational sites used by a wide
> variety of people.
> It would be very helpful for users to provide a small bit of consistency in
> look and feel, headers, footers, and the like without unduly changing the
> general concept of "each tool is independent".
> My first thought would be to either:
> - Override a couple of the Wunderbar methods, perhaps with a very simple set
> of options, that would output one of a small set of default header blocks &
> CSS (think the logo, plus a small hamburger menu pointing at a.o, w.a.o, and
> a Help page)
> - Create new helper functions in ASF that can be easily used in any existing
> scripts with a similar _syntax.
> _h1First.maxheader 'title'
> would output a header div that could be styled with the logo, default
> hamburger menu, and the title in a consistent way. .minheader would instead
> output just the logo and title, nothing else.
> Similar for:
> - Footer (we should have a license, pointer to /about, or /help or "how to
> submit questions" links)
> - Standardize on a couple of table styles
> We don't need a full website framework, but a few bits of commonality would
> improve the user experience as well as simplify the learning path for new
> Whimsy contributors.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)