You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@tcl.apache.org by mx...@apache.org on 2015/12/09 01:23:45 UTC
svn commit: r1718749 - in /tcl/rivet/trunk: ChangeLog doc/rivet.xml
doc/xml/asciiglyphs.xml doc/xml/commands.xml doc/xml/examples.xml
rivet/packages/asciiglyphs/asciiglyphs.tcl
Author: mxmanghi
Date: Wed Dec 9 00:23:45 2015
New Revision: 1718749
URL: http://svn.apache.org/viewvc?rev=1718749&view=rev
Log:
* doc/xml/commands.xml,asciiglyphs.tcl: adding documentation for ::rivet::try
and AsciiGlyphs
Added:
tcl/rivet/trunk/doc/xml/asciiglyphs.xml
Modified:
tcl/rivet/trunk/ChangeLog
tcl/rivet/trunk/doc/rivet.xml
tcl/rivet/trunk/doc/xml/commands.xml
tcl/rivet/trunk/doc/xml/examples.xml
tcl/rivet/trunk/rivet/packages/asciiglyphs/asciiglyphs.tcl
Modified: tcl/rivet/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/ChangeLog?rev=1718749&r1=1718748&r2=1718749&view=diff
==============================================================================
--- tcl/rivet/trunk/ChangeLog (original)
+++ tcl/rivet/trunk/ChangeLog Wed Dec 9 00:23:45 2015
@@ -1,3 +1,7 @@
+2015-12-08 Massimo Manghi <mx...@apache.org>
+ * doc/xml/commands.xml,asciiglyphs.tcl: adding documentation for ::rivet::try
+ and AsciiGlyphs
+
2015-12-06 Massimo Manghi <mx...@apache.org>
* rivet/packages/asciiglyphs.tcl: Package HexGlyphs renamed as AsciiGlyphs
Modified: tcl/rivet/trunk/doc/rivet.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/rivet.xml?rev=1718749&r1=1718748&r2=1718749&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/rivet.xml (original)
+++ tcl/rivet/trunk/doc/rivet.xml Wed Dec 9 00:23:45 2015
@@ -27,6 +27,7 @@
<!ENTITY upgrade.xml SYSTEM "xml/upgrade.xml" >
<!ENTITY request.xml SYSTEM "xml/request.xml" >
<!ENTITY entities.xml SYSTEM "xml/entities.xml" >
+ <!ENTITY asciiglyphs.xml SYSTEM "xml/asciiglyphs.xml" >
]>
<!--
@@ -120,6 +121,9 @@
<!-- Entities -->
&entities.xml;
+
+ <!-- AsciiGlyphs -->
+ &asciiglyphs.xml;
<!-- Help -->
&help.xml;
Added: tcl/rivet/trunk/doc/xml/asciiglyphs.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/asciiglyphs.xml?rev=1718749&view=auto
==============================================================================
--- tcl/rivet/trunk/doc/xml/asciiglyphs.xml (added)
+++ tcl/rivet/trunk/doc/xml/asciiglyphs.xml Wed Dec 9 00:23:45 2015
@@ -0,0 +1,35 @@
+<section id="asciiglyphs">
+ <title>AsciiGlyphs</title>
+ <section>
+ <title>Introduction</title>
+ <para>
+ The <command>AsciiGlyphs</command> package provides a command
+ to print large ASCII glyphs in an HTML fragment based on
+ a <pre>...</pre:> element. The shape of the glyphs was
+ inspired by the challenge response used by Fossil to let anonymous users
+ to log into a repository. The glyph set was extended to
+ support the whole English alphabet and some punctuation characters.
+ The string to be represented has to be made of pure 7-bit ASCII characters.
+ The package also runs standalone outside of mod_rivet
+ </para>
+
+ <programlisting>package require AsciiGlyphs
+::AsciiGlyphs toGlyphs "Date: 07-12-2015"
+ _____ _____ ______ ___ ______ __ ___ ___ ___ __ _____
+| __ \ /\ |_ _| | ____| _ / _ \ |____ | /_ ||__ \ |__ \ / _ \ /_ || ____|
+| | | | / \ | | | |__ |_| | | | | / / ____ | | ) | ____ ) || | | | | || |__
+| | | | / /\ \ | | | __| _ | | | | / / |____| | | / / |____| / / | | | | | ||___ \
+| |__| | / ____ \ | | | |____ |_| | |_| | / / | | / /_ / /_ | |_| | | | ___) |
+|_____/ /_/ \_\ |_| |______| \___/ /_/ |_||____| |____| \___/ |_||____/
+
+::AsciiGlyphs toGlyphs "Time: 18:10:19"
+ _____ ___ _ _ ______ __ ___ __ ___ __ ___
+|_ _| | || \ / | | ____| _ /_ | / _ \ _ /_ | / _ \ _ /_ | / _ \
+ | | | | | \/ | | |__ |_| | || (_) | |_| | || | | | |_| | || (_) |
+ | | | | | | | | | __| _ | | > _ < _ | || | | | _ | | \__, |
+ | | | | | | | | | |____ |_| | || (_) | |_| | || |_| | |_| | | / /
+ |_| |___||_| |_| |______| |_| \___/ |_| \___/ |_| /_/
+
+</programlisting>
+ </section>
+</section>
\ No newline at end of file
Modified: tcl/rivet/trunk/doc/xml/commands.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/commands.xml?rev=1718749&r1=1718748&r2=1718749&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/xml/commands.xml (original)
+++ tcl/rivet/trunk/doc/xml/commands.xml Wed Dec 9 00:23:45 2015
@@ -1522,26 +1522,104 @@ bab</programlisting>
<refentry id="read_file">
<refnamediv>
- <refname>read_file</refname>
- <refpurpose>
- Read the entire contents of a file and return it as a string.
- </refpurpose>
+ <refname>read_file</refname>
+ <refpurpose>
+ Read the entire contents of a file and return it as a string.
+ </refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
- <command>::rivet::read_file</command>
- <arg>file name</arg>
- </cmdsynopsis>
+ <command>::rivet::read_file</command>
+ <arg>file name</arg>
+ </cmdsynopsis>
</refsynopsisdiv>
<refsect1>
- <title>Description</title>
+ <title>Description</title>
+ <para>
+ This is a utility command which loads the entire content of
+ a file and returns it as a result.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="try">
+ <refnamediv>
+ <refname>try</refname>
+ <refpurpose>
+ Catch error and exception conditions
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>::rivet::try</command>
+ <arg>script</arg>
+ <arg>script</arg>
+ <arg><replaceable>handlers</replaceable></arg>
+ <arg><replaceable>finally script</replaceable></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>Description</title>
+ <para>
+ <command>::rivet::try</command> wraps the core language
+ command and simply traps exceptions that might have raised
+ by <command>::rivet::abort_page</command> and
+ <command>::rivet::exit</command> to throw them again and
+ thus causing <command>AbortScript</command> to be executed.
+ </para>
+ <para>
+ If neither <command>::rivet::abort_page</command> nor
+ <command>::rivet::exit</command> are called from <arg>script</arg>
+ then any handlers specified in the command are tested for execution.
+ Thus <command>::rivet::try</command> can transparently be used
+ as a replacement for Tcl's own <command>try</command> and it's needed
+ if you want <arg>script</arg> to safely bail out to <command>AbortScript</command>
+ </para>
+ <para>
+ This script shows how <command>::rivet:try</command>
+ handles different exceptions or errors. You can drive this script
+ within mod_rivet adding the arguments fail or abort or exit to its URL.
+ You can handle the <quote>exit</quote> and <quote>abort</quote> cases with
+ an <command>AbortScript</command>.
+ See <xref linkend="directives"><command>AbortScript</command></xref>
+ </para>
+ <programlisting><html><?::rivet::try {
+ if {[::rivet::var_qs exists exit]} {
+ ::rivet::exit 100
+ } elseif {[::rivet::var_qs exists abort]} {
+ ::rivet::abort_page
+ } elseif {[::rivet::var_qs exists fail]} {
+ # this is just a non existent command
+ wrong_command
+ } else {
+ puts "<b>OK</b>"
+ }
+
+} on error {e o} {
+ puts "catching error -&gt; $e<br/>"
+ dict for {fd fv} $o {
+
+ puts "$fd --&gt;&gt; $fv<br/>"
+
+ }
+ }
+?></html></programlisting>
<para>
- This is a utility command which loads the entire content of
- a file and returns it as a result.
+ Placing this code in a file (try.rvt) on the
+ web server <emphasis>DocumentRoot</emphasis>
+ directory and setting for example the browser
+ to <command>http://localhost/try.rvt?fail=1</command>.
</para>
- </refsect1>
- </refentry>
+ <programlisting>catching error -> invalid command name "wrong_command"
+-errorcode -->> TCL LOOKUP COMMAND wrong_command
+-code -->> 1
+-level -->> 0
+-errorstack -->> INNER {invokeStk1 wrong_command} UP 1
+-errorinfo -->> invalid command name "wrong_command" while executing "wrong_command" ("::try" body line 9)
+-errorline -->> 9</programlisting>
+ </refsect1>
+ </refentry>
<refentry id="unescape_string">
<refnamediv>
Modified: tcl/rivet/trunk/doc/xml/examples.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/doc/xml/examples.xml?rev=1718749&r1=1718748&r2=1718749&view=diff
==============================================================================
--- tcl/rivet/trunk/doc/xml/examples.xml (original)
+++ tcl/rivet/trunk/doc/xml/examples.xml Wed Dec 9 00:23:45 2015
@@ -280,7 +280,7 @@
apache access.log file, even though the html is never reloaded.
</para>
</example>
- <example id="calendar">
+ <example id="calendar_example">
<title>A Calendar Utility</title>
<para>
Rivet comes with a <emphasis>Calendar</emphasis> package that provides classes for printing
Modified: tcl/rivet/trunk/rivet/packages/asciiglyphs/asciiglyphs.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/trunk/rivet/packages/asciiglyphs/asciiglyphs.tcl?rev=1718749&r1=1718748&r2=1718749&view=diff
==============================================================================
--- tcl/rivet/trunk/rivet/packages/asciiglyphs/asciiglyphs.tcl (original)
+++ tcl/rivet/trunk/rivet/packages/asciiglyphs/asciiglyphs.tcl Wed Dec 9 00:23:45 2015
@@ -26,6 +26,7 @@
namespace eval ::AsciiGlyphs:: {
variable ASCIIGLYPHS
+ variable glyphs_avail
array set ASCIIGLYPHS {}
@@ -44,31 +45,32 @@ namespace eval ::AsciiGlyphs:: {
}
namespace export glyph_catalog
- proc build_hex {hs} {
+ proc build_glyph {c} {
variable ASCIIGLYPHS
+ variable glyphs_avail
- set glyphs_avail [array names ASCIIGLYPHS]
-
- set hs [string toupper $hs]
- for {set i 0} {$i < [string length $hs]} {incr i} {
-
- set c [string index $hs $i]
-
- #if {![string is xdigit $c]}
- if {[lsearch $glyphs_avail $c] < 0} {
- return -code error -errocode invalid_char "Invalid non hexadecimal or non space character"
+ #if {![string is xdigit $c]}
+ puts -nonewline "'$c' -> "
+ if {[lsearch $glyphs_avail $c] < 0} {
+ #return -code error -errocode invalid_char "Invalid non hexadecimal or non space character"
+ if {[string is space $c]} {
+ set c "space"
+ } elseif {$c == "\\"} {
+ set c "backslash"
+ } else {
+ set c "*"
}
+ }
+ puts $c
- set lines [split $ASCIIGLYPHS($c) "\n"]
- set lines [lrange $lines 1 end-1]
+ set lines [split $ASCIIGLYPHS($c) "\n"]
+ set lines [lrange $lines 1 end-1]
- set l 0
- foreach gliphline $lines {
- append hexline($l) $gliphline
- incr l
- }
-
- }
+ set l 0
+ foreach gliphline $lines {
+ append hexline($l) $gliphline
+ incr l
+ }
return [list $hexline(0) \
$hexline(1) \
@@ -80,13 +82,17 @@ namespace eval ::AsciiGlyphs:: {
}
proc toGlyphs {hexstring} {
+ variable ASCIIGLYPHS
+ variable glyphs_avail
- set hexstring_l [split $hexstring " \t"]
+ set glyphs_avail [array names ASCIIGLYPHS]
+
+ set hexstring_l [split [string toupper $hexstring] ""]
foreach s $hexstring_l {
set s [string trim $s]
- set string_l [[namespace current]::build_hex $s]
+ set string_l [[namespace current]::build_glyph $s]
for {set i 0} {$i < 6} {incr i} {
lappend bigstring($i) [lindex $string_l $i]
}
@@ -304,12 +310,12 @@ set ::AsciiGlyphs::ASCIIGLYPHS(V) {
}
set ::AsciiGlyphs::ASCIIGLYPHS(W) {
- __ __
- \ \ / /
- \ \/\/ /
- \ /
- \__/
-
+__ __
+\ \ / /
+ \ \ /\/\ / /
+ \ \/ \/ /
+ \ /\ /
+ \_/ \_/
}
set ::AsciiGlyphs::ASCIIGLYPHS(X) {
@@ -331,12 +337,12 @@ set ::AsciiGlyphs::ASCIIGLYPHS(Y) {
}
set ::AsciiGlyphs::ASCIIGLYPHS(Z) {
- ______
- |____ |
- / /
- / /
- / /___
- /______|
+ _____
+ |___ |
+ / /
+ / /
+ / /___
+ /______|
}
@@ -430,21 +436,21 @@ set ::AsciiGlyphs::ASCIIGLYPHS(9) {
}
set ::AsciiGlyphs::ASCIIGLYPHS(-) {
-
-
- ____
-|____|
-
-
+
+
+ ____
+|____|
+
+
}
set ::AsciiGlyphs::ASCIIGLYPHS(_) {
-
-
-
-
- ______
-|______|
+
+
+
+
+ ______
+|______|
}
set ::AsciiGlyphs::ASCIIGLYPHS(:) {
@@ -456,13 +462,13 @@ set ::AsciiGlyphs::ASCIIGLYPHS(:) {
}
-set ::AsciiGlyphs::ASCIIGLYPHS(;) {
+set ::AsciiGlyphs::ASCIIGLYPHS(\;) {
_
|_|
_
| |
- |/
+ |/
}
set ::AsciiGlyphs::ASCIIGLYPHS(.) {
@@ -483,7 +489,7 @@ set ::AsciiGlyphs::ASCIIGLYPHS(/) {
/_/
}
-set ::AsciiGlyphs::ASCIIGLYPHS(\) {
+set ::AsciiGlyphs::ASCIIGLYPHS(backslash) {
__
\ \
\ \
@@ -492,6 +498,31 @@ set ::AsciiGlyphs::ASCIIGLYPHS(\) {
\_\
}
-package provide AsciiGlyphs 0.1
+set ::AsciiGlyphs::ASCIIGLYPHS(~) {
+ ___
+ / _ \
+ /_/ \ \__
+ \__/
+
+
+}
+set ::AsciiGlyphs::ASCIIGLYPHS(*) {
+
+ \ | /
+ _\|/_
+ /|\
+ / | \
+
+}
+
+set ::AsciiGlyphs::ASCIIGLYPHS(space) {
+
+
+
+
+
+
+}
+package provide AsciiGlyphs 0.1
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: site-cvs-help@tcl.apache.org