gEDA-dev: [PATCH] Allow gschemdoc to access wiki pages with -w.

Peter TB Brett peter at peter-b.co.uk
Tue Apr 17 12:08:26 EDT 2007


Adds the gschemdoc -w switch to make gschemdoc load a wiki page.
It initially tries to find a local export of the wiki; on failure,
it falls back to the online wiki at the gEDA website.

See also SF.net Patch #1702302.

Peter

---

 utils/scripts/gschemdoc.sh |   50 
++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/utils/scripts/gschemdoc.sh b/utils/scripts/gschemdoc.sh
index 6c5679e..71d1584 100644
--- a/utils/scripts/gschemdoc.sh
+++ b/utils/scripts/gschemdoc.sh
@@ -14,10 +14,11 @@
 #    5: symbol directory (currently not used)
 #
 # alternative action:
-# present gschem user's manual
+# present gschem user's manual, or a specific wiki page
 #
 # options:
-#    "-m"       display user's manual instead
+#    "-m"              display user's manual instead
+#    "-w <path>"       display a wiki page
 #
 # deBUG:
 # echo "gschemdoc args are: <$0> <$1> <$2> <$3> <$4> <$5>"
@@ -128,6 +129,44 @@ lookup_manual()
 }
 
 #
+#  Display a wiki page
+#
+#  Tries a local page first; if it doesn't exist, falls back to wiki on gEDA 
+#  website.
+lookup_wiki()
+{
+    LOCALWIKIROOT="${DOCDIR}/wiki/"
+    LIVEWIKIROOT="http://geda.seul.org/wiki/"
+
+    # Munge wiki path to remove bad chars
+    LOCALNAME=$(echo "$1" | tr "?\!*:" "____")
+    if test -z "$LOCALNAME"; then
+	LOCALNAME="index"
+    fi
+    LOCALPATH="$LOCALWIKIROOT$LOCALNAME.html"
+
+    LIVEURL="$LIVEWIKIROOT$1"
+
+    if test -f "$LOCALNAME" ; then
+	view_file_browser $LOCALPATH
+	exit
+    
+    if test "${browser}" != "no" ; then
+	
+	echo "Found ${browser}"
+	echo "Using browser and URL: $LIVEURL"
+	# NOTE: Mozilla and Netscape does not seem to support
+	#       -- on the command line
+	${browser} "$LIVENAME"
+	exit
+    else
+	echo "Did not find a browser application."
+	exit
+    fi
+}
+
+
+#
 #  establish what software we have
 #
 browser="no"
@@ -157,6 +196,13 @@ if test "$1" = "-m"; then
 fi
 
 #
+#  try to load a specific wiki path
+#
+if test "$1" = "-w"; then
+        lookup_wiki "$2"
+fi
+
+#
 #  i.
 #  if there is a file in the documentation directory, we
 #  will of course use that first and foremost

-- 
Fisher Society committee                    http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
CU Spaceflight                              http://tinyurl.com/ognu2

v3sw6YChw7$ln3pr6$ck3ma8u7+Lw3+2m0l7Ci6e4+8t4Gb8en6g6Pa2Xs5Mr4p4
  hackerkey.com                                  peter-b.co.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.seul.org/pipermail/geda-dev/attachments/20070417/05cfd40d/attachment.pgp


More information about the geda-dev mailing list