Fisheye: Tag 51341f64f5e0defd47d3aa5506ddbc259590666a refers to a dead (removed) revision in file `doc/index.html'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 51341f64f5e0defd47d3aa5506ddbc259590666a refers to a dead (removed) revision in file `generic/predefined.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 51341f64f5e0defd47d3aa5506ddbc259590666a refers to a dead (removed) revision in file `library/lib/pkgIndex.tcl'. Fisheye: No comparison available. Pass `N' to diff? Index: library/xotcl/apps/actiweb/Counter.xotcl =================================================================== diff -u --- library/xotcl/apps/actiweb/Counter.xotcl (revision 0) +++ library/xotcl/apps/actiweb/Counter.xotcl (revision 51341f64f5e0defd47d3aa5506ddbc259590666a) @@ -0,0 +1,42 @@ +#!../../src/xotclsh +# $Id: Counter.xotcl,v 1.4 2006/09/27 08:12:39 neumann Exp $ +#load /Users/neumann/src/xotcl-1.4.1/library/store/XOTclSdbm/libxotclsdbm1.2.dylib +array set opts {-pkgdir .}; array set opts $argv +lappend auto_path $opts(-pkgdir) + +package require XOTcl 1; namespace import -force xotcl::* +package require xotcl::actiweb::htmlPlace +package require xotcl::actiweb::webDocument + +### Instantiate an Html place with the name receive and port 8090 +HtmlPlace ::receiver -port 8090 -allowExit exit + +### Define a class Counter as a special Html Document +Class Counter -superclass HtmlDocument -parameter {{count 0}} + +Counter instproc init args { ;### Constructor + next + my persistent count ;### make count variable persistent + ::receiver exportObjs [self] ;### export the counter object + my exportProcs increment ;### export counter's increment method +} +Counter instproc default {} { ;### Method for updating HTML page + set objName [string trimleft [self] :] + return "The value in $objName is now: [my set count].

+ Increment Counter

+


Last Update: [clock format [clock seconds]] + \n" +} +Counter instproc increment {} { ;### exported increment method + my incr count + return [my default] +} + +### Create two counter instances with the names +### counter-1.html and counter-2.html +Counter counter-1.html +Counter counter-2.html + +### Start event loop and handle connections +receiver startEventLoop + Index: library/xotcl/apps/actiweb/Counter2.xotcl =================================================================== diff -u --- library/xotcl/apps/actiweb/Counter2.xotcl (revision 0) +++ library/xotcl/apps/actiweb/Counter2.xotcl (revision 51341f64f5e0defd47d3aa5506ddbc259590666a) @@ -0,0 +1,65 @@ +#!../../src/xotclsh +# $Id: Counter2.xotcl,v 1.3 2005/09/09 21:09:01 neumann Exp $ +array set opts {-pkgdir .}; array set opts $argv +lappend auto_path $opts(-pkgdir) + +package require XOTcl 1; namespace import -force xotcl::* + +package require xotcl::actiweb::htmlPlace +package require xotcl::actiweb::pageTemplate + +HtmlPlace ::receiver -port 8091 -allowExit exit + +### +### The counter class is an agent implementing the business logic +### +Class Counter -superclass Agent -parameter {{count 1}} + +Counter instproc init args { ;### Constructor + next ;### Call superclass constructor + my persistent count ;### make count variable persistent +} +Counter instproc increment {} { ;### increment method + my incr count +} +### Create two counter instances c1/c2 +Counter c1 +Counter c2 + +### +### Define a specialization of web object as a facade to the counters +### The Page Template Mixin defines the HTML appearance +### + +### Define an HTML Page Template +Class WebCounter -superclass WebObject \ + -instmixin PageTemplateHtml -parameter {counter} + +WebCounter instproc init args { + next + [my set place] exportObjs [self] ;### export the web counter object + my exportProcs increment ;### export counter's increment method +} +WebCounter instproc increment {} { ;### A method that decorates increment with HTML appearence + my instvar counter ;### import var that stores shielded web agent + $counter [self proc] ;### call the actual method on the web agent + my default ;### update HTML page +} +WebCounter instproc default {} { ;### Method for updating HTML page + my instvar count counter ;### importiere var that stores shielded web agent + $counter instvar count ;### importiere count var + # + # and create web-page with counter content + # + my simplePage [self] "Html-Facade for $counter using a page template" \ + "The value in $counter is $count.

+ Increment Counter

" +} +# +# create two web-facade instances; one for each counter +# +WebCounter web-c1 -counter c1 +WebCounter web-c2 -counter c2 + +### Start event loop and handle connections +receiver startEventLoop Index: library/xotcl/apps/actiweb/Counter3.xotcl =================================================================== diff -u --- library/xotcl/apps/actiweb/Counter3.xotcl (revision 0) +++ library/xotcl/apps/actiweb/Counter3.xotcl (revision 51341f64f5e0defd47d3aa5506ddbc259590666a) @@ -0,0 +1,44 @@ +#!../../src/xotclsh +# $Id: Counter3.xotcl,v 1.1.1.1 2004/05/23 22:50:39 neumann Exp $ +array set opts {-pkgdir .}; array set opts $argv +lappend auto_path $opts(-pkgdir) + +package require XOTcl 1; namespace import -force xotcl::* +package require xotcl::actiweb::htmlPlace +package require xotcl::actiweb::webDocument + +### Instantiate an Html place with the name receiver +HtmlPlace ::receiver -port 8093 -allowExit exit + +### Define a class solely for counting +Class Counter -parameter {{count 1}} +Counter instproc increment {} { ;### counter method + my incr count +} + +### Define a special WebCounter as a specialization of the Counter class +Class WebCounter -superclass {Counter HtmlDocument} +WebCounter instproc init args { ;### Constructor + next + my persistent count ;### make count variable persistent + ::receiver exportObjs [self] ;### export the counter object + my exportProcs increment ;### export increment method +} +WebCounter instproc default {} { ;### Method for updating HTML page + set objName [string trimleft [self] :] + return "The value in $objName is [my set count].

+ Increment Counter

+


Last Update: [clock format [clock seconds] -format %m/%d/%y-%H:%M] + \n" +} +WebCounter instproc increment {} { ;### exported increment method + next ;### call superclasses' increment + my default ;### display the result as HTML +} + +### Create two web counter instances with the names c1 and c2 +WebCounter c1 +WebCounter c2 + +### Start event loop and handle connections +receiver startEventLoop Index: library/xotcl/apps/actiweb/Counter4.xotcl =================================================================== diff -u --- library/xotcl/apps/actiweb/Counter4.xotcl (revision 0) +++ library/xotcl/apps/actiweb/Counter4.xotcl (revision 51341f64f5e0defd47d3aa5506ddbc259590666a) @@ -0,0 +1,56 @@ +#!../../src/xotclsh +# $Id: Counter4.xotcl,v 1.2 2004/07/27 21:39:46 neumann Exp $ +array set opts {-pkgdir .}; array set opts $argv +lappend auto_path $opts(-pkgdir) + +package require XOTcl 1; namespace import -force xotcl::* +package require xotcl::actiweb::htmlPlace +package require xotcl::actiweb::webDocument + +### Instantiate an Html place with the name receiver +HtmlPlace ::receiver -port 8094 -allowExit exit + +### Define a class solely for counting +Class Counter -parameter {{count 1}} +Counter instproc increment {} { ;### counter method + my incr count +} + +### Define a Counter subclass for persistent counting +Class PersistentCounter -superclass Counter +PersistentCounter instproc init args { ;### Constructor + next ;### call superclasses' init + my mixinStrategy Persistent=Eager + my persistenceMgr [Place getInstance]::agentPersistenceMgr + my persistent count ;### make count variable persistent +} + +### Create two persistent counter instances with the names c1 and c2 +PersistentCounter c1 +PersistentCounter c2 + + +### Define a proxy class, that handles HTML decoration +### HtmlProxy forwards all unknown calls to "realSubject" +Class HtmlProxyCounter -superclass HtmlProxy +HtmlProxyCounter instproc init args { ;### Constructor + next + my exportProcs increment ;### export increment method +} +HtmlProxyCounter instproc default {} { + my instvar realSubject + $realSubject instvar count + set objName [string trimleft [self] :] + return "The value in $realSubject is $count.

+ Increment Counter

+


Last Update: [clock format [clock seconds] -format %m/%d/%y-%H:%M] +] + \n" +} + +### Create two proxy instances wc1 und wc2 +HtmlProxyCounter wc1 -realSubject c1 +HtmlProxyCounter wc2 -realSubject c2 + +### Start event loop and handle connections +receiver startEventLoop Index: library/xotcl/apps/actiweb/MC.xotcl =================================================================== diff -u --- library/xotcl/apps/actiweb/MC.xotcl (revision 0) +++ library/xotcl/apps/actiweb/MC.xotcl (revision 51341f64f5e0defd47d3aa5506ddbc259590666a) @@ -0,0 +1,212 @@ +#!../../src/xotclsh +# $Id: MC.xotcl,v 1.1.1.1 2004/05/23 22:50:39 neumann Exp $ +# +# A simple multiple choice test application +# +array set opts {-pkgdir .}; array set opts $argv +lappend auto_path $opts(-pkgdir) + +package require XOTcl 1; namespace import -force xotcl::* +#package require xotcl::package; package verbose 1 +package require xotcl::actiweb::htmlPlace +package require xotcl::actiweb::pageTemplate + +HtmlPlace ::receiver -port 8092 -allowExit exit + +# Define a pool of questions: Question and their alternatives +# are defined as classes and all questions are stored in the pool +# +Class Pool +Class Pool::Question -parameter {text {altcounter 1}} +Class Pool::Question::Alternative -parameter {text correct} + +Pool::Question instproc alternatives {pairs} { + my instvar altcounter + foreach {alt correct} $pairs { + incr altcounter + [self class]::Alternative [self]::$altcounter \ + -text $alt -correct $correct + } +} + + +# +# An Exam has a name and is a selection of questions from a pool. +# "requiredCorrect" defines the minimal number of correct answers +# to pass the test. + +Class Exam -parameter {name requiredCorrect pool questions} + + +# +# For every candidate we create an individual exam. We scramble +# the questions and alternatives and use the studentID as a seed. +# + +Class IndividualExam -superclass Agent -parameter {ID exam} + +IndividualExam instproc random modulo { ;### random number generator + my instvar seed + set seed [expr {($seed*12731+34197) % 21473}] + return [expr {$seed % $modulo}] +} +IndividualExam instproc permute {list} { ;### permute random permutation + set permuted {} + for {set nr [llength $list]} {$nr>0} {incr nr -1} { + set select [my random $nr] + lappend permuted [lindex $list $select] + set list [lreplace $list $select $select] + } + return $permuted +} +IndividualExam instproc init args { + my instvar seed ID exam individualTest alternatives + set questions [$exam set questions] + set seed $ID + ### compute order of individual tests and alternatives + foreach index [my permute [$exam set questions]] { + set questionObj [$exam set pool]::$index + lappend individualTest $index + set alts [my permute [lsort [$questionObj info children]]] + lappend alternatives $alts + } + #puts stderr "Individual test [self] has $individualTest" +} + +# +# Define a web facade using a page template +# "testObject" is the individual test that is shielded by the web facade +# +Class WebExam -superclass WebObject \ + -instmixin PageTemplateHtml -parameter {testObject} +WebExam instproc default {} { ;### This method creates the HTML Test + my instvar testObject ;### import var that stores shielded test object + ### import vars from the test + $testObject instvar individualTest alternatives exam + set action [my selfAction result] + ### create Test page + set htmlText "
\n
    \n" + ### iterate over the set of questions/alternatives + ### and add them to the HTML text + foreach question $individualTest alts $alternatives { + append htmlText "
  1. [[$exam pool]::$question text]\n
      \n" + foreach a $alts { + append htmlText "
    • \ + [$a text] ([$a correct])\n" + } + append htmlText "

    \n" + } + ### we have to add a hidden form field, otherwise we get no result, + ### if nothing is tagged + append htmlText "" + ### the submit button lets us send the result back + append htmlText "

\n" + ### create simple HTML Page + my simplePage [$exam name] \ + "Exam [$exam name] for [string trimleft $testObject :] \ + (Exam: $exam)" $htmlText +} +WebExam instproc result {} { ;# This method analyses the results of the test + my instvar testObject ;### import var that stores shielded test + set exam [$testObject exam] + $testObject instvar individualTest alternatives + foreach question $individualTest alts $alternatives { + foreach a $alts {set ca($a) 0} + } + foreach a [my getFormData] {set ca([$a set content]) 1} + set htmlText "You have answered:\n + if {$correctAnswers < [$exam requiredCorrect]} { + my simplePage [self] "Sorry" "$htmlText\ + Only $correctAnswers question were answered correctly. You have not succeeded :(" + } else { + my simplePage [self] "Congratulations" "$htmlText\ + $correctAnswers questions were answered correctly. You have succeeded :-)" + } +} +WebExam instproc init args { + next + [my place] exportObjs [self] ;# export object + my exportProcs result ;# export methods +} + + + + + +# Create a Pool P with 6 example questions with 3 alternatives for each. + +Pool p +Pool::Question p::1 \ + -text "When was the first XOTcl Version released?" -alternatives { + "1998" 0 + "1999" 1 + "2000" 0 + } +Pool::Question p::2 -text "Who is author of XOTcl?" -alternatives { + "Gustaf Neumann" 1 + "Mika Haekinnen" 0 + "Uwe Zdun" 1 +} +Pool::Question p::3 -text "Which of the systems are other OO extensions of Tcl?" \ + -alternatives { + "XTCL" 0 + "ITCL" 1 + "OTCL" 1 + } +Pool::Question p::4 \ + -text "Which methods are provided by the Object class?" -alternatives { + "set" 1 + "instvar" 0 + "filter" 1 + } +Pool::Question p::5 \ + -text "Which methods are provided by the Object class?" -alternatives { + "unset" 1 + "instproc" 0 + "mixin" 1 + } +Pool::Question p::6 \ + -text "Which methods are provided by the Class class?" -alternatives { + "proc" 0 + "instproc" 1 + "mixin" 0 + } + +### Define an exam + +Exam xotclTest \ + -pool p \ + -name "XOTcl Test" \ + -questions {1 2 3 4 5} \ + -requiredCorrect 4 + + +### Define two Student tests with the XOTcl Test + +foreach {Student ID} { + Uwe 7850247 + Gustaf 7850248 +} { + ## Define the individual exams + IndividualExam $Student -exam xotclTest -ID $ID + ### Define a web facade for each student + WebExam $Student.html -testObject $Student + +} +receiver startEventLoop Index: library/xotcl/apps/actiweb/univ/UNIVERSAL.xotcl =================================================================== diff -u --- library/xotcl/apps/actiweb/univ/UNIVERSAL.xotcl (revision 0) +++ library/xotcl/apps/actiweb/univ/UNIVERSAL.xotcl (revision 51341f64f5e0defd47d3aa5506ddbc259590666a) @@ -0,0 +1,267 @@ +#!/usr/bin/env tclsh +#$Id: UNIVERSAL.xotcl,v 1.8 2007/08/14 16:38:26 neumann Exp $ +package require XOTcl 1; namespace import -force xotcl::* +array set opts { + -ssl 0 -instanceFile UNIVERSAL.rdf -cssFile UNIVERSAL.css -root . -pkgdir .} +array set opts $argv + +@ @File { + description { + This is a demo of a Webserver that presents the contents of + an RDF source file in a friendly and easy readable manner. +

+ The RDF file is parsed first into triples which + are added to the resource database RDFdb. This RDFdb used in this + example replaces the standard triple database of xoRDF by an + application specific version, which is easier to process. The triple + database is the source of the Catalog, which displays a short, easy to read + summary of the entries. The database is used as well for the "detailed + view", which presents all the data of the triples through nested HTML tables. +

+ The demo program uses either HTTP or HTTPS (in which case you will require + the SSL/TLS extension of Tcl). + } +} + +lappend auto_path $opts(-pkgdir) +if {$opts(-ssl)} { + package require xotcl::actiweb::secureHtmlPlace + SecureHtmlPlace ::receiver -port 443 -root $opts(-root) +} else { + package require xotcl::actiweb::htmlPlace + HtmlPlace ::receiver -port 8095 -root $opts(-root) -allowExit exit +} +package require xotcl::actiweb::webDocument + +# load RDF processing components +package require xotcl::rdf::parser +package require xotcl::rdf::triple +package require xotcl::xml::printVisitor + +proc loadFile filename { + set F [open $filename r]; set c [read $F]; close $F + return $c +} +# +# instantiate parser and parser an example text into a node tree +# + +#puts stderr "parsing [loadFile $opts(-instanceFile)]" +RDFParser R +R parse [loadFile $opts(-instanceFile)] +puts stderr "parsing done" + +# +# load the nodetree from the parser into the triple database +# +#section Triples +TripleVisitor tv -parser R +tv proc interprete {} { + my instvar topNode parser + if {![my exists topNode]} {set topNode ${parser}::topNode1} + my reset + my interpretNodeTree $topNode +} + +#### Define a simple Resource Database +Class RDFdb -superclass RDFTripleDB +RDFdb instproc isContainer c { + regexp ^[self]::rdfdoc\# $c +} +RDFdb instproc add {predicate subject object} { + set s [self]::$subject + if {[my info children $s] eq ""} { + #puts stderr "create new resource $s" + Resource create $s + } + $s set $predicate $object + next ;# for passing to RDFTripleDB (which provides e.g. prettyTriples) +} +RDFdb instproc reset {} { + foreach c [my info children] { $c destroy } + next +} +RDFdb instproc resources {} { + set result "" + foreach c [my info children] { + if {![my isContainer $c] && + [$c istype Resource]} {lappend result $c} + } + return $result +} +RDFdb instproc querySubject {subject} { + set s [self]::$subject + set result "" + if {[my info children $s] ne ""} { + foreach att [lsort [$s info vars]] { + lappend result $att [$s set $att] + } + } + return $result +} + +# create an Instance of the Resource Database +RDFdb tv::db + + + +# define Resources with its methods +Class Resource +Resource instproc dump {} { + foreach att [lsort [my info vars]] { puts stderr "\t$att = [my set $att]" } +} +Resource instproc substitute {lines} { + set result "" + foreach line [split $lines \n] { + if {[regexp {^ *http:} $line]} { + set value "" + set o [self] + set line [string trim $line] + foreach step $line { + set value [$o set $step] + set o tv::db::$value + } + append result $value + } else { + append result $line + } + } + return $result +} + +Resource instproc pretty {} { + set q [univ selfAction "details [namespace tail [self]]"] + my substitute " + http://nm.wu-wien.ac.at/universal/rdf-lifecycle#Contribute \ + http://nm.wu-wien.ac.at/universal/rdf-lifecycle#Entity +: + http://nm.wu-wien.ac.at/universal/rdf-general#Title +, + http://nm.wu-wien.ac.at/universal/rdf-education#LearningResourceType +, + http://nm.wu-wien.ac.at/universal/rdf-education#TypicalLearningTime +, + http://nm.wu-wien.ac.at/universal/rdf-lifecycle#Contribute \ + http://nm.wu-wien.ac.at/universal/rdf-lifecycle#Date + ([my pretty-access])" +} +Resource instproc pretty-title {} { + my substitute "http://nm.wu-wien.ac.at/universal/rdf-general#Title" +} +Resource instproc pretty-access {} { + set tech http://nm.wu-wien.ac.at/universal/rdf-technical + set format [my substitute "$tech#Format"] + set location [my substitute "$tech#Location"] + if {$format eq "text/html"} { + set label "go" } else { + set label "Download [my substitute $tech#Size] bytes" + } + return "$label" +} + + + +### Definition of the Learning Resource Manager: +Class LrManager -superclass WebDocument -parameter { + {defaultUrl http://nm.wu-wien.ac.at/Lehre/oo2/} +} +LrManager instproc html-title {t} { + my contentType text/html + return "$t\n\n" +} +LrManager instproc html-head {t} { + return "

$t

\n" +} + +LrManager instproc details {subject} { + set result [my html-title "Details about a Learning Resource"] + append result [my html-head "Details about the Learning Resource
'[::tv::db::$subject pretty-title]'"] + #append result "The subject: '$subject' has the following properties:

\n" + append result [my attributeTable $subject outer] "" +} + +LrManager instproc attributeTable {subject cls} { + set result "" + set lastns "" + foreach {attr value} [tv::db querySubject $subject] { + if {[tv::db isContainer $value]} { + #set q [univ selfAction "details $value"]; set value "$value" + set value [my attributeTable $value inner] + } + regexp {^(.*)\#(.*)$} $attr _ ns property + if {$ns != $lastns} { + if {$lastns ne ""} { append result

\n } + append result "Attributes from namespace $ns:\n\n" + set lastns $ns + } + append result \ + "" \ + "" \n + } + append result "
$property$value
\n" +} + + +LrManager instproc catalog {} { + set result [my html-title "Universal Resources"] + append result [my html-head "Local Learning Resources:"]

+} + +LrManager instproc source {file} { + my contentType text/plain + return [loadFile $file] +} + +LrManager instproc nav {} { + set right [my selfAction "catalog"] + set result [my html-title "Universal Navigation Bar"] + set rdfsrc [my selfAction "source $::opts(-instanceFile)"] + set csssrc [my selfAction "source $::opts(-root)/$::opts(-cssFile)"] + set src [my selfAction "source [info script]"] + append result \n \ + "UNIVERSAL HOME \n\ +

All local Resources

+

Search for Title

+

Search for Authors

+
Internal Use only: +

XML:RDF Source

+

CSS Source

+

Source of Meta-Data Application Server

" +} + +LrManager instproc default {} { + set right [my selfAction "catalog"] + set nav [my selfAction "nav"] + set result [my html-title "Universal"] + append result " + + + + <body>\n\<h2>Query UNIVERSAL database for Resource:</h2>\n\ + +" +} + +LrManager instproc init args { + next + ::receiver exportObjs [self] ;# export object + my exportProcs details catalog nav source ;# export methods +} + + +# create an instance of the Learning Resource manager +LrManager univ +receiver proc default {} {univ default} ;# call it like index.html as default + +# Invoke Tiple Visitor to feed the database +tv interprete +#puts stderr [tv::db prettyTriples] + + +receiver startEventLoop ;# Start event loop + Fisheye: Tag 51341f64f5e0defd47d3aa5506ddbc259590666a refers to a dead (removed) revision in file `library/xotcl/library/store/XOTclSdbm/Makefile'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 51341f64f5e0defd47d3aa5506ddbc259590666a refers to a dead (removed) revision in file `library/xotcl/library/xml/TclExpat-1.1/Makefile'. Fisheye: No comparison available. Pass `N' to diff?