This is an automated email from the ASF dual-hosted git repository.
curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 5a45ace Improve default themes and provide test/test.cgi as sample
script
5a45ace is described below
commit 5a45aceaa2ad12e914c768f4a9b42210e8ba8cfe
Author: Shane Curcuru <[email protected]>
AuthorDate: Wed Jun 7 18:03:12 2017 -0400
Improve default themes and provide test/test.cgi as sample script
---
lib/whimsy/asf/themes.rb | 16 +++++++---------
www/test/test.cgi | 46 +++++++++++++++++++++++++++++++++-------------
2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/lib/whimsy/asf/themes.rb b/lib/whimsy/asf/themes.rb
index d1ea29b..0417cbd 100644
--- a/lib/whimsy/asf/themes.rb
+++ b/lib/whimsy/asf/themes.rb
@@ -100,7 +100,7 @@ class Wunderbar::HtmlMarkup
end
# Emit a panel with title and body content
- def _whimsy_panel(title, style: 'panel-default', header: 'h3')
+ def _whimsy_panel(title, style: 'panel-primary', header: 'h3')
_div.panel class: style do
_div.panel_heading do
_.tag! header, class: 'panel-title' do
@@ -114,7 +114,7 @@ class Wunderbar::HtmlMarkup
end
# Emit a panel with helpblock and table
https://getbootstrap.com/components/#panels-tables
- def _whimsy_panel_table(title: 'Table Title', style: 'panel-default',
header: 'h2', helpblock: nil)
+ def _whimsy_panel_table(title: 'Table Title', style: 'panel-primary',
header: 'h2', helpblock: nil)
_div.panel class: style do
_div.panel_heading do
_.tag! header, class: 'panel-title' do
@@ -187,7 +187,7 @@ class Wunderbar::HtmlMarkup
end
# Emit complete bootstrap theme, with related links, and helpblock of intro
text
- def _whimsy_body(title: 'MOAR WHIMSY!', subtitle: 'About This Script',
related: {}, helpblock: nil)
+ def _whimsy_body(title: 'MOAR WHIMSY!', subtitle: 'About This Script',
relatedtitle: 'Related Whimsy Links', related: {}, helpblock: nil)
_whimsy_nav
_div.content.container_fluid do
_div.row do
@@ -197,18 +197,16 @@ class Wunderbar::HtmlMarkup
end
_div.row do
_div.col_md_8 do
- _whimsy_panel subtitle do
+ _whimsy_panel subtitle, style: "panel-info" do
if helpblock
helpblock.call
else
- # TODO: make this point to the specific cgi being run
- _a 'See the code', href: 'https://github.com/apache/whimsy/'
+ _a 'See this code', href:
"https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
end
-
end
end
_div.col_md_4 do
- _whimsy_panel "More Whimsy", style: "panel-info" do
+ _whimsy_panel relatedtitle, style: "panel-default" do
_ul list_style_position: 'inside' do
if related
related.each do |url, desc|
@@ -225,7 +223,7 @@ class Wunderbar::HtmlMarkup
end
else
_li do
- _a 'Whimsy Source Code', href:
'https://github.com/apache/whimsy/'
+ _a 'See this code', href:
"https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
end
end
end
diff --git a/www/test/test.cgi b/www/test/test.cgi
index 3ffa396..dd6b462 100755
--- a/www/test/test.cgi
+++ b/www/test/test.cgi
@@ -7,29 +7,43 @@ require 'whimsy/asf'
require 'wunderbar'
require 'wunderbar/bootstrap'
+def get_data(defaults: {})
+ return {
+ "Sample data processing here" => "row 1",
+ "This could come from a file" => "row B"
+ }
+end
+
_html do
_body? do
_whimsy_body(
- title: PAGETITLE,
+ title: PAGETITLE,
related: {
"https://whimsy.apache.org/committers/tools" => "Whimsy Tool Listing",
-
"https://incubator.apache.org/images/incubator_feather_egg_logo_sm.png" =>
"Incubator Logo",
+
"https://incubator.apache.org/images/incubator_feather_egg_logo_sm.png" =>
"Incubator Logo, to show that graphics can appear",
"https://community.apache.org/" => "Get Community Help",
- "https://github.com/apache/whimsy/" => "Read The Whimsy Code"
+
"https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}" => "See
This Source Code"
},
helpblock: -> {
- _p "This www/test/test.cgi script shows a proposed new way to write
whimsy tools."
- _p "Using lib/whimsy/theme and _whimsy_body2 means users have a
consistent UI for different tools,
- and means that simple descriptions or help documentation are included
at the start of each tool."
- _p "Similarly, having a listing of related tools in the right hand
panel helps end users find other interesting tools here."
+ _p "This www/test/test.cgi script shows a canonical way to write a
simple whimsy tool that processes data and then displays it."
+ _p %{
+ This helpblock appears at top left, and should explain to an end
user what this script does for the user and why they might be interested.
+ Any related whimsy or other (projects.a.o, etc.) links should be in
the related: listing on the top right to help users find other useful things.
+ This provides a consistent user experience.
+ }
}
) do
+ # IF YOUR SCRIPT EMITS A LARGE TABLE
_whimsy_panel_table(
- title: "Your Table Title Here",
+ title: "Data Table H2 Title Goes Here",
helpblock: -> {
- _p "Explain any additional details (if needed) about your table data
here."
+ _p "If your script displays a sizeable table(s) of data, then use
this area to provide a Key: to the data."
}
) do
+ # Gather or process your data **here**, so if an error is raised, the
_body?
+ # scope will trap it - and will then display the above help
information
+ # to the user before emitting a polite error traceback.
+ datums = get_data()
_table.table.table_hover.table_striped do
_thead_ do
_tr do
@@ -37,14 +51,13 @@ _html do
_th 'Column Two'
end
_tbody do
- datums = ["Fred", "Francie", "Flubber"]
- [1, 2, 3].each do | row |
+ datums.each do | key, val |
_tr_ do
_td do
- _ row
+ _ key
end
_td do
- _ datums[row]
+ _ val
end
end
end
@@ -52,6 +65,13 @@ _html do
end
end
end
+ # IF YOUR SCRIPT ONLY EMITS SIMPLE DATA
+ _h2 "Simple Data Can Just Use A List"
+ _ul do
+ [1,2,3].each do |row|
+ _li "This is row number #{row}."
+ end
+ end
end
end
end
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].