From bknr at bknr.net Sat Oct 14 06:59:37 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 02:59:37 -0400 (EDT) Subject: [bknr-cvs] r1985 - in branches/xml-class-rework/projects/bos: . statistics Message-ID: <20061014065937.0E6B248145@common-lisp.net> Author: hhubner Date: 2006-10-14 02:59:35 -0400 (Sat, 14 Oct 2006) New Revision: 1985 Added: branches/xml-class-rework/projects/bos/statistics/ branches/xml-class-rework/projects/bos/statistics/Makefile branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt Log: Generate SVG charts from statistical data. Added: branches/xml-class-rework/projects/bos/statistics/Makefile =================================================================== --- branches/xml-class-rework/projects/bos/statistics/Makefile 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/Makefile 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,21 @@ + +BASE_URL = http://192.168.254.132:8080/reports-xml +YEAR = 2005 +LOGIN = ?__username=hans&__password=ognep + +GRAPHICS = contracts-by-week.svg + +all: + $(MAKE) graphics YEAR=2005 + $(MAKE) graphics YEAR=2006 + +graphics: $(GRAPHICS) + +.SUFFIXES: .lxsl .xsl .svg + +.lxsl.xsl: + xsltproc -o $@ loop-compiler.xslt $*.lxsl + +.xsl.svg: + xsltproc -o $*.xml $*.xsl '$(BASE_URL)/$*/$(YEAR)$(LOGIN)' + xsltproc -o $*-$(YEAR).svg buildSVGLineChart.xsl $*.xml \ No newline at end of file Property changes on: branches/xml-class-rework/projects/bos/statistics/Makefile ___________________________________________________________________ Name: svn:executable + * Name: svn:eol-style + native Added: branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,827 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + stroke:;stroke-width: 3; fill : none; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + vertical + + + + + + + horizontal + + + 1 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + stroke: stroke-width: 3; fill : none; + + + + + + + + + + + + + + + + + + + + + + + + + + Legend: + + + 15 + + + + + + + + stroke-width:1;stroke:;fill: + + + + + + + + + + + + + + + + + + rotate(315, + + + + + +,1014) + + + + + + + + + + + + + 0 + vertical + + + + + + + + + + + 1 + + rotate(, , + + + + + ) + + text-anchor: + + end + start + + + + + + + + + + + + + + + + + + horizontal + + + + + + + + + + + + + + + + + -150 + 150 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + circle + red + + + stroke:;fill: + + + ShowTooltip(evt,'') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rotate(45,,) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + false + + + + + + + + + + + + + + + + + + +" + + + + + + 0 + + vertical + + + + + + + + + + + + + + + + + + 0 + + + + false + + + + 1 + + + + + + + + + + + + + + + + + text-anchor: + + end + start + + ;font-size: + + 40 + 40 + 20 + + + + + + + + + + + + horizontal + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 1000 + + + + + + + + + + + + + + + + + + 1 + + + + end + start + + + + + + + + + + + + + + + + + + + + + + + + Property changes on: branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl ___________________________________________________________________ Name: svn:executable + * Added: branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,75 @@ +Contracts by week for year 2005204060Legend:Contracts Added: branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,75 @@ +Contracts by week for year 2006204060Legend:Contracts Added: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 52 + 0 + + Contracts by week for year <xsl:value-of select="$year"/> + + + + + + true + + + + + + Property changes on: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl ___________________________________________________________________ Name: svn:executable + * Added: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,2 @@ + +1142193624195106473849910201129121413131417151516317818719102015219222823122482519261527372816291130631113212337341035663683732381339154016412152066Contracts by week for year 200620true40true60true Added: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 52 + 0 + + Contracts by week for year <xsl:value-of select="$year"/> + + + + + + + + + + true + + Property changes on: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl ___________________________________________________________________ Name: svn:executable + * Added: branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt =================================================================== --- branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt 2006-09-24 19:13:31 UTC (rev 1984) +++ branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt 2006-10-14 06:59:35 UTC (rev 1985) @@ -0,0 +1,504 @@ + + + + + + + + + + + + + + + + + + + + error(s) detected + + + + + + + File generated by translating loops into recursive template calls. + XSLT Loop Compiler, Version 1.0 + GPL (c) O. Becker + + + + + + + + + + + + Missing required attribute 'name' of ' + ' + + . + + + + Missing required attribute 'from' of ' + ' + + . + + + + Missing required attribute 'to' of ' + ' + + . + + + + + Unknown attribute ' + + ' of ' + ' + + . + + + + + + + + + Missing required attribute 'test' of ' + ' + + . + + + + + Unknown attribute ' + + ' of ' + ' + + . + + + + + + Forbidden + + + text ' + + + + element ' + + + + ' - expected ' + + :variable', ' + + :do', ' + + :last' or ' + + :update' + + . + + + + + Warning: ' + ' contains no ' + + :update' - infinite loop! + + + + + + + + + + ' + ' must not follow a preceding ' + + :do' + + . + + + + ' + ' must not follow a preceding ' + + :last' + + . + + + + ' + ' must not follow a preceding ' + + :update' + + . + + + + + + + + ' + ' must be an immediate child of ' + + :while' + + . + + + + Unknown attribute ' + + ' of ' + ' + + . + + + + + ' + ' must not follow a preceding ' + + :do' + + . + + + + ' + ' must not follow a preceding ' + + :last' + + . + + + + ' + ' must not follow a preceding ' + + :update' + + . + + + + + + + + + ' + ' must be an immediate child of ' + + :for' or ' + + :while' + + . + + + + Missing required attribute 'name' of ' + ' + + . + + + + + Unknown attribute ' + + ' of ' + ' + + . + + + + + ' + ' for variable ' + + ' already defined + + . + + + + + + + + + + + Unknown element ' + ' + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + >= + <= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cannot update variable ' + + ' - not locally visible at parent node ' + ' + + . + + + + + + + + + + + + + Property changes on: branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt ___________________________________________________________________ Name: svn:executable + * From bknr at bknr.net Sat Oct 14 07:00:18 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 03:00:18 -0400 (EDT) Subject: [bknr-cvs] r1986 - branches/xml-class-rework/projects/bos/statistics Message-ID: <20061014070018.2B3044E009@common-lisp.net> Author: hhubner Date: 2006-10-14 03:00:17 -0400 (Sat, 14 Oct 2006) New Revision: 1986 Removed: branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml Modified: branches/xml-class-rework/projects/bos/statistics/ Log: Remove generated files Property changes on: branches/xml-class-rework/projects/bos/statistics ___________________________________________________________________ Name: svn:ignore + contracts-by-week.xml *.svg Deleted: branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg 2006-10-14 06:59:35 UTC (rev 1985) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2005.svg 2006-10-14 07:00:17 UTC (rev 1986) @@ -1,75 +0,0 @@ -Contracts by week for year 2005204060Legend:Contracts Deleted: branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg 2006-10-14 06:59:35 UTC (rev 1985) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week-2006.svg 2006-10-14 07:00:17 UTC (rev 1986) @@ -1,75 +0,0 @@ -Contracts by week for year 2006204060Legend:Contracts Deleted: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml 2006-10-14 06:59:35 UTC (rev 1985) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xml 2006-10-14 07:00:17 UTC (rev 1986) @@ -1,2 +0,0 @@ - -1142193624195106473849910201129121413131417151516317818719102015219222823122482519261527372816291130631113212337341035663683732381339154016412152066Contracts by week for year 200620true40true60true From bknr at bknr.net Sat Oct 14 07:05:32 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 03:05:32 -0400 (EDT) Subject: [bknr-cvs] r1987 - branches/xml-class-rework/projects/bos/statistics Message-ID: <20061014070532.AA3F358000@common-lisp.net> Author: hhubner Date: 2006-10-14 03:05:32 -0400 (Sat, 14 Oct 2006) New Revision: 1987 Modified: branches/xml-class-rework/projects/bos/statistics/Makefile Log: Remove login Modified: branches/xml-class-rework/projects/bos/statistics/Makefile =================================================================== --- branches/xml-class-rework/projects/bos/statistics/Makefile 2006-10-14 07:00:17 UTC (rev 1986) +++ branches/xml-class-rework/projects/bos/statistics/Makefile 2006-10-14 07:05:32 UTC (rev 1987) @@ -1,7 +1,7 @@ BASE_URL = http://192.168.254.132:8080/reports-xml YEAR = 2005 -LOGIN = ?__username=hans&__password=ognep +LOGIN = GRAPHICS = contracts-by-week.svg @@ -18,4 +18,5 @@ .xsl.svg: xsltproc -o $*.xml $*.xsl '$(BASE_URL)/$*/$(YEAR)$(LOGIN)' - xsltproc -o $*-$(YEAR).svg buildSVGLineChart.xsl $*.xml \ No newline at end of file + xsltproc -o $*-$(YEAR).svg buildSVGLineChart.xsl $*.xml + rm $*.xml \ No newline at end of file From bknr at bknr.net Sat Oct 14 07:07:34 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 03:07:34 -0400 (EDT) Subject: [bknr-cvs] r1988 - branches/xml-class-rework/projects/bos/statistics Message-ID: <20061014070734.155C158000@common-lisp.net> Author: hhubner Date: 2006-10-14 03:07:33 -0400 (Sat, 14 Oct 2006) New Revision: 1988 Modified: branches/xml-class-rework/projects/bos/statistics/Makefile branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt Log: remove x bits Property changes on: branches/xml-class-rework/projects/bos/statistics/Makefile ___________________________________________________________________ Name: svn:executable - * Property changes on: branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl ___________________________________________________________________ Name: svn:executable - * Property changes on: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl ___________________________________________________________________ Name: svn:executable - * Property changes on: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl ___________________________________________________________________ Name: svn:executable - * Property changes on: branches/xml-class-rework/projects/bos/statistics/loop-compiler.xslt ___________________________________________________________________ Name: svn:executable - * From bknr at bknr.net Sat Oct 14 07:51:44 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 03:51:44 -0400 (EDT) Subject: [bknr-cvs] r1989 - in branches/xml-class-rework/projects/bos: m2 payment-website/images payment-website/images/statistics statistics worldpay-test Message-ID: <20061014075144.D76DB5831F@common-lisp.net> Author: hhubner Date: 2006-10-14 03:51:44 -0400 (Sat, 14 Oct 2006) New Revision: 1989 Added: branches/xml-class-rework/projects/bos/payment-website/images/statistics/ branches/xml-class-rework/projects/bos/worldpay-test/reports-xml-handler.lisp branches/xml-class-rework/projects/bos/worldpay-test/rss.lisp Removed: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl Modified: branches/xml-class-rework/projects/bos/m2/m2.lisp branches/xml-class-rework/projects/bos/statistics/ branches/xml-class-rework/projects/bos/statistics/Makefile branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl branches/xml-class-rework/projects/bos/worldpay-test/packages.lisp branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.asd branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.lisp Log: XML statistics generation and batch SVG rendering. Modified: branches/xml-class-rework/projects/bos/m2/m2.lisp =================================================================== --- branches/xml-class-rework/projects/bos/m2/m2.lisp 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/m2/m2.lisp 2006-10-14 07:51:44 UTC (rev 1989) @@ -387,3 +387,6 @@ (make-contract sponsor (random-elt (cons (1+ (random 300)) '(1 1 1 1 1 5 5 10 10 10 10 10 10 10 10 10 10 10 10 10 30 30 30))) :paidp t)))) + + + \ No newline at end of file Property changes on: branches/xml-class-rework/projects/bos/payment-website/images/statistics ___________________________________________________________________ Name: svn:ignore + * Property changes on: branches/xml-class-rework/projects/bos/statistics ___________________________________________________________________ Name: svn:ignore - contracts-by-week.xml *.svg + contracts-by-week.xsl contracts-by-week.xml *.svg Modified: branches/xml-class-rework/projects/bos/statistics/Makefile =================================================================== --- branches/xml-class-rework/projects/bos/statistics/Makefile 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/statistics/Makefile 2006-10-14 07:51:44 UTC (rev 1989) @@ -1,7 +1,8 @@ BASE_URL = http://192.168.254.132:8080/reports-xml YEAR = 2005 -LOGIN = +LOGIN = +OUTPUT_DIR = ../payment-website/images/statistics GRAPHICS = contracts-by-week.svg @@ -18,5 +19,5 @@ .xsl.svg: xsltproc -o $*.xml $*.xsl '$(BASE_URL)/$*/$(YEAR)$(LOGIN)' - xsltproc -o $*-$(YEAR).svg buildSVGLineChart.xsl $*.xml + xsltproc -o $(OUTPUT_DIR)/$*-$(YEAR).svg buildSVGLineChart.xsl $*.xml rm $*.xml \ No newline at end of file Modified: branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl 2006-10-14 07:51:44 UTC (rev 1989) @@ -21,7 +21,7 @@ - + Modified: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week.lxsl 2006-10-14 07:51:44 UTC (rev 1989) @@ -17,17 +17,26 @@ - + 1 - 52 + 365 0 Contracts by week for year + + + + + + true + + + Deleted: branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/statistics/contracts-by-week.xsl 2006-10-14 07:51:44 UTC (rev 1989) @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 52 - 0 - - Contracts by week for year <xsl:value-of select="$year"/> - - - - - - - - - - true - - Modified: branches/xml-class-rework/projects/bos/worldpay-test/packages.lisp =================================================================== --- branches/xml-class-rework/projects/bos/worldpay-test/packages.lisp 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/worldpay-test/packages.lisp 2006-10-14 07:51:44 UTC (rev 1989) @@ -2,6 +2,7 @@ (defpackage :worldpay-test (:use :cl + :date-calc :extensions :cl-user :cl-interpol @@ -11,7 +12,7 @@ :xhtml-generator :cxml :puri - :mime + #+(or) :mime :acl-compat.socket :acl-compat.mp :bknr.web Added: branches/xml-class-rework/projects/bos/worldpay-test/reports-xml-handler.lisp =================================================================== --- branches/xml-class-rework/projects/bos/worldpay-test/reports-xml-handler.lisp 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/worldpay-test/reports-xml-handler.lisp 2006-10-14 07:51:44 UTC (rev 1989) @@ -0,0 +1,99 @@ + +(in-package :worldpay-test) + +(enable-interpol-syntax) + +(defclass reports-xml-handler (prefix-handler) + ()) + +(defvar *report-generators* (make-hash-table)) +(defvar *contracts-to-process*) +(defvar *year*) +(defvar *month-names* '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")) + +(defmacro defreport (name arguments &body body) + `(setf (gethash ',name *report-generators*) (lambda (, at arguments) , at body))) + +(defun contract-year (contract) + (multiple-value-bind (second minute hour date month year day-of-week is-dst tz) (decode-universal-time (contract-date contract)) + year)) + +(defmethod handle ((handler reports-xml-handler) req) + (with-xml-response req + (destructuring-bind (name *year* &rest arguments) (decoded-handler-path handler req) + (setf *year* (parse-integer *year*)) + (let ((*contracts-to-process* (sort (remove-if (lambda (contract) + (or (not (contract-paidp contract)) + (and *year* + (not (eql *year* (contract-year contract)))))) + (class-instances 'contract)) + #'< :key #'contract-date))) + (setf name (intern (string-upcase name) :worldpay-test)) + (apply (or (gethash name *report-generators*) + (error "invalid report name ~A" name)) + arguments))))) + + +(defreport all-contracts () + (dolist (contract *contracts-to-process*) + (with-element "contract" + (attribute "date-time" (format-date-time (contract-date contract) :xml-style t)) + (attribute "country" (sponsor-country (contract-sponsor contract))) + (attribute "sqm-count" (length (contract-m2s contract)))))) + +(defun week-of-contract (contract) + "Return Week key (YYYY-WW) for given contract." + (multiple-value-bind (second minute hour date month year day-of-week is-dst tz) (decode-universal-time (contract-date contract)) + (multiple-value-bind (week-no week-year) + (week-of-year year month date) + (when (and (> week-no 50) + (eql month 1)) + ;; If the date falls within the last week of the previous + ;; year, we put it into the first week of the current year in + ;; order to simplify graphics drawing. + (setf week-no 1)) + (format nil "~A-~A" week-year week-no)))) + +(defun week-first-yday (contract) + "Return the day-of year of the first day of the contract's date" + (multiple-value-bind (second minute hour date month year day-of-week is-dst tz) (decode-universal-time (contract-date contract)) + (max 0 (- (day-of-year year month date) (day-of-week year month date))))) + +(defreport contracts-by-week () + (dolist (week-contracts (group-on *contracts-to-process* + :test #'equal + :key #'week-of-contract)) + (with-element "week" + (attribute "week-first-yday" (week-first-yday (first (cdr week-contracts)))) + (attribute "key" (first week-contracts)) + (attribute "contracts" (length (cdr week-contracts))) + (attribute "sqms" (apply #'+ (mapcar (lambda (contract) (length (contract-m2s contract))) (cdr week-contracts)))))) + (dotimes (month 12) + (with-element "month" + (attribute "number" month) + (attribute "name" (nth month *month-names*)) + (attribute "start-yday" (1- (day-of-year *year* (1+ month) 1)))))) + +(defreport contract-sizes () + (let ((contract-sizes (make-hash-table :test #'equal)) + (thresholds '(1 10 30 100 10000000))) + (dolist (threshold thresholds) + (setf (gethash threshold contract-sizes) 0)) + (dolist (contract *contracts-to-process*) + (dolist (threshold thresholds) + (when (<= (length (contract-m2s contract)) threshold) + (incf (gethash threshold contract-sizes)) + (return)))) + (dolist (threshold thresholds) + (with-element "contracts" + (attribute "threshold" threshold) + (attribute "count" (gethash threshold contract-sizes)))))) + +(defreport contract-countries () + (dolist (country-contracts (sort (group-on *contracts-to-process* + :test #'equal + :key (lambda (contract) (sponsor-country (contract-sponsor contract)))) + #'> :key (lambda (entry) (length (cdr entry))))) + (with-element "country" + (attribute "code" (car country-contracts)) + (attribute "contracts" (length (cdr country-contracts)))))) \ No newline at end of file Added: branches/xml-class-rework/projects/bos/worldpay-test/rss.lisp =================================================================== --- branches/xml-class-rework/projects/bos/worldpay-test/rss.lisp 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/worldpay-test/rss.lisp 2006-10-14 07:51:44 UTC (rev 1989) @@ -0,0 +1,21 @@ +(in-package :worldpay-test) + +(defmethod rss-item-channel ((item news-item)) + "news") + +(defmethod rss-item-published ((item news-item)) + (format t "Language: ~A~%" (current-website-language)) + t) + +(defmethod rss-item-title ((item news-item)) + (news-item-title item (current-website-language))) + +(defmethod rss-item-description ((item news-item)) + (news-item-text item (current-website-language))) + +(defmethod rss-item-link ((item news-item)) + (format nil "http://createrainforest.org/~A/news-extern/~A" (current-website-language) (store-object-id item))) + +(defmethod rss-item-guid ((item news-item)) + (format nil "http://createrainforest.org/~A/news-extern/~A" (current-website-language) (store-object-id item))) + Modified: branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.asd =================================================================== --- branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.asd 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.asd 2006-10-14 07:51:44 UTC (rev 1989) @@ -28,6 +28,7 @@ (:file "poi-handlers" :depends-on ("web-utils")) (:file "boi-handlers" :depends-on ("web-utils")) (:file "contract-handlers" :depends-on ("web-utils")) + (:file "reports-xml-handler" :depends-on ("boi-handlers")) (:file "sponsor-handlers" :depends-on ("web-utils")) (:file "news-handlers" :depends-on ("web-utils")) (:file "allocation-area-handlers" :depends-on ("web-utils")) Modified: branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.lisp =================================================================== --- branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.lisp 2006-10-14 07:07:33 UTC (rev 1988) +++ branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.lisp 2006-10-14 07:51:44 UTC (rev 1989) @@ -185,6 +185,7 @@ ("/edit-poi-image" edit-poi-image-handler) ("/edit-sponsor" edit-sponsor-handler) ("/contract" contract-handler) + ("/reports-xml" reports-xml-handler) ("/complete-transfer" complete-transfer-handler) ("/edit-news" edit-news-handler) ("/make-poi" make-poi-handler) From bknr at bknr.net Sat Oct 14 09:33:54 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 05:33:54 -0400 (EDT) Subject: [bknr-cvs] r1990 - branches/xml-class-rework/projects/bos/statistics Message-ID: <20061014093354.5DEA06D1AF@common-lisp.net> Author: hhubner Date: 2006-10-14 05:33:53 -0400 (Sat, 14 Oct 2006) New Revision: 1990 Modified: branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl Log: Increase Y-Label font size Modified: branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl =================================================================== --- branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl 2006-10-14 07:51:44 UTC (rev 1989) +++ branches/xml-class-rework/projects/bos/statistics/buildSVGLineChart.xsl 2006-10-14 09:33:53 UTC (rev 1990) @@ -446,7 +446,7 @@ ) - + text-anchor: end From bknr at bknr.net Sat Oct 14 09:35:08 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 05:35:08 -0400 (EDT) Subject: [bknr-cvs] r1991 - in branches/xml-class-rework: bknr/src bknr/src/utils modules Message-ID: <20061014093508.CB5887021A@common-lisp.net> Author: hhubner Date: 2006-10-14 05:35:08 -0400 (Sat, 14 Oct 2006) New Revision: 1991 Added: branches/xml-class-rework/bknr/src/utils/date-calc.lisp Modified: branches/xml-class-rework/bknr/src/bknr-utils.asd branches/xml-class-rework/modules/bknr-modules.asd Log: Import date calculation routines. Modified: branches/xml-class-rework/bknr/src/bknr-utils.asd =================================================================== --- branches/xml-class-rework/bknr/src/bknr-utils.asd 2006-10-14 09:33:53 UTC (rev 1990) +++ branches/xml-class-rework/bknr/src/bknr-utils.asd 2006-10-14 09:35:08 UTC (rev 1991) @@ -37,5 +37,6 @@ (:file "capability" :depends-on ("utils")) (:file "make-fdf-file" :depends-on ("utils")) (:file "xml" :depends-on ("utils")) + (:file "date-calc") (:file "acl-mp-compat" :depends-on ("package")))))) Added: branches/xml-class-rework/bknr/src/utils/date-calc.lisp =================================================================== --- branches/xml-class-rework/bknr/src/utils/date-calc.lisp 2006-10-14 09:33:53 UTC (rev 1990) +++ branches/xml-class-rework/bknr/src/utils/date-calc.lisp 2006-10-14 09:35:08 UTC (rev 1991) @@ -0,0 +1,719 @@ +;;; Package: date-calc.lisp +;;; Heiko Schroeter, Dec 2005 +;;; +;;; Ver 0.2 ALPHA +;;; License: GNU, Version 2, June 1991 +;;; +;;; Legal issues: +;;; ------------- +;;; This package with all its parts is +;;; Copyright (c) 2005 by Heiko Schroeter. + +;;; This package is free software; you can use, modify and redistribute +;;; under the "GNU General Public License" and the "Artistic License". + +;;; This package is intended as a date-calc module for "everyday" purposes. It is not intended +;;; , nor claims to be, +;;; a bullet proofed implementation of 'scientific' datum calculus. + +;;; Parts taken from DateCalc.el (EMACS, Doug Alcorn, , Ver. 0.1, 2003) +;;; and the +;;; Perl Package "Date::Calc" Version 5.4,Copyright (c) 1995 - 2004 by Steffen Beyer. + +;;; Some Documentation strings are only slightly edited from DateCalc.el + +;;; THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +;;; IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +;;; WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +;;; The following routines are a sidestep for CL Day Of Week (DOW) conformance. +;;; (See Hyperspec 25.1.4.1 X3J13). +;;; "An integer between 0 and 6, inclusive; 0 means Monday, 1 means Tuesday, and so on; 6 means Sunday." +;;; PERLs Date::Calc module range is from 1(Monday) to 7(Sunday). + + +;;; CL conform ,Perl' Conform +;;; ---------- -------------- +;;; cl-day-of-week day-of-week +;;; cl-weeks-in-year weeks-in-year +;;; cl-check-business-p check-business-p +;;; cl-nth-weekday-of-month-year nth-weekday-of-month-year +;;; cl-standard-to-business standard-to-business +;;; cl-business-to-standard business-to-standard +;;; cl-system-clock system-clock +;;; cl-decode-day-of-week decode-day-of-week + +;;; Pls report bugs to schroete @ iup physik uni-bremen de + + +(in-package #:cl-user) + +(defpackage #:date-calc + (:use #:cl) + (:export #:*language* + #:decode-day-of-week + #:cl-decode-day-of-week + #:decode-month + #:decode-language + #:iso-lc + #:iso-uc + #:year-to-days + #:fixed-window + #:center + #:valid-year-p + #:valid-month-p + #:leap-year + #:leap-year-p + #:days-in-month + #:days-in-year + #:check-date + #:check-business-p + #:check-time-p + #:day-of-year + #:date-to-days + #:day-of-week + #:weeks-in-year + #:delta-days + #:week-number + #:week-of-year + #:add-delta-days + #:monday-of-week + #:nth-weekday-of-month-year + #:standard-to-business + #:business-to-standard + #:delta-hms + #:delta-dhms + #:delta-ymd + #:delta-ymdhms + #:normalize-dhms + #:add-delta-dhms + #:add-year-month + #:add-delta-ym + #:add-delta-ymd + #:add-delta-ymdhms + #:system-clock + #:cl-system-clock + #:gmtime + #:localtime + #:today + #:yesterday + #:tomorrow + #:now + #:today-and-now + #:this-year + #:date-to-text + #:date-to-text-long + #:cl-day-of-week + #:cl-weeks-in-year + #:cl-check-business-p + #:cl-nth-weekday-of-month-year + #:cl-standard-to-business + #:cl-business-to-standard)) + +(pushnew :date-calc *features*) +(in-package #:date-calc) + +;;;; Parameters +(defparameter year-of-epoc 70 "Year of reference (epoc)") +(defparameter century-of-epoc 1900 "Century of reference (epoc)") +(defparameter eopoc (+ year-of-epoc century-of-epoc) "reference year (epoc)") + +(defparameter days-in-year-arr (make-array '(2 13) :initial-contents + '((0 31 59 90 120 151 181 212 243 273 304 334 365) + (0 31 60 91 121 152 182 213 244 274 305 335 366)))) + +(defparameter days-in-month-arr (make-array '(2 13) :initial-contents + '((0 31 28 31 30 31 30 31 31 30 31 30 31) + (0 31 29 31 30 31 30 31 31 30 31 30 31)))) + +(defparameter languages 11) +(defparameter *language* 1) ; Default English + +;; (defconstant num-of-lingos (1+ languages)) + +(defparameter month-to-text (make-hash-table)) +(setf (gethash 0 month-to-text) + #("???" "???" "???" "???" + "???" "???" "???" "???" + "???" "???" "???" "???" "???")) +(setf (gethash 1 month-to-text) + #("???" "January" "February" "March" + "April" "May" "June" "July" "August" + "September" "October" "November" "December")) +(setf (gethash 2 month-to-text) + #("???" "janvier" "fevrier" "mars" + "avril" "mai" "juin" "juillet" "aout" + "septembre" "octobre" "novembre" "decembre")) +(setf (gethash 3 month-to-text) + #("???" "Januar" "Februar" "Maerz" + "April" "Mai" "Juni" "Juli" "August" + "September" "Oktober" "November" "Dezember")) +(setf (gethash 4 month-to-text) + #("???" "enero" "febrero" "marzo" + "abril" "mayo" "junio" "julio" "agosto" + "septiembre" "octubre" "noviembre" "diciembre")) +(setf (gethash 5 month-to-text) + #("???" "janeiro" "fevereiro" "marco" + "abril" "maio" "junho" "julho" "agosto" + "setembro" "outubro" "novembro" "dezembro")) +(setf (gethash 6 month-to-text) + #("???" "januari" "februari" "maart" + "april" "mei" "juni" "juli" "augustus" + "september" "october" "november" "december")) +(setf (gethash 7 month-to-text) + #("???" "Gennaio" "Febbraio" "Marzo" + "Aprile" "Maggio" "Giugno" "Luglio" "Agosto" + "Settembre" "Ottobre" "Novembre" "Dicembre")) +(setf (gethash 8 month-to-text) + #("???" "januar" "februar" "mars" + "april" "mai" "juni" "juli" "august" + "september" "oktober" "november" "desember")) +(setf (gethash 9 month-to-text) + #("???" "januari" "februari" "mars" + "april" "maj" "juni" "juli" "augusti" + "september" "oktober" "november" "december")) +(setf (gethash 10 month-to-text) + #("???" "januar" "februar" "marts" + "april" "maj" "juni" "juli" "august" + "september" "oktober" "november" "december")) +(setf (gethash 11 month-to-text) + #("???" "tammikuu" "helmikuu" "maaliskuu" + "huhtikuu" "toukokuu" "kesaekuu" "heinaekuu" + "elokuu" "syyskuu" "lokakuu" "marraskuu" "joulukuu")) + +(defparameter day-of-week-to-text (make-hash-table)) +(setf (gethash 0 day-of-week-to-text) + #("???" "???" "???" "???" "???" "???" "???" "???")) +(setf (gethash 1 day-of-week-to-text) + #("???" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")) +(setf (gethash 2 day-of-week-to-text) + #("???" "Lundi" "Mardi" "Mercredi" "Jeudi" "Vendredi" "Samedi" "Dimanche")) +(setf (gethash 3 day-of-week-to-text) + #("???" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag" "Samstag" "Sonntag")) +(setf (gethash 4 day-of-week-to-text) + #("???" "Lunes" "Martes" "Miercoles" "Jueves" "Viernes" "Sabado" "Domingo")) +(setf (gethash 5 day-of-week-to-text) + #("???" "Segunda-feira" "Terca-feira" "Quarta-feira" "Quinta-feira" "Sexta-feira" "Sabado" "Domingo")) +(setf (gethash 6 day-of-week-to-text) + #("???" "Maandag" "Dinsdag" "Woensdag" "Donderdag" "Vrijdag" "Zaterdag" "Zondag")) +(setf (gethash 7 day-of-week-to-text) + #("???" "Lunedi" "Martedi" "Mercoledi" "Giovedi" "Venerdi" "Sabato" "Domenica")) +(setf (gethash 8 day-of-week-to-text) + #("???" "mandag" "tirsdag" "onsdag" "torsdag" "fredag" "loerdag" "soendag")) +(setf (gethash 9 day-of-week-to-text) + #("???" "mandag" "tisdag" "onsdag" "torsdag" "fredag" "loerdag" "soendag")) +(setf (gethash 10 day-of-week-to-text) + #("???" "mandag" "tirsdag" "onsdag" "torsdag" "fredag" "loerdag" "soendag")) +(setf (gethash 11 day-of-week-to-text) + #("???" "maanantai" "tiistai" "keskiviikko" "torstai" "perjantai" "lauantai" "sunnuntai")) + +(defparameter day-of-week-abbreviation (make-hash-table)) +(setf (gethash 0 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 1 day-of-week-abbreviation) #("??" "Mon" "Tue" "Wen" "Thu" "Fri" "Sat" "Sun")) +(setf (gethash 2 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 3 day-of-week-abbreviation) #("??" "Mo" "Di" "Mi" "Do" "Fr" "Sa" "So")) +(setf (gethash 4 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 5 day-of-week-abbreviation) #("???" "2" "3" "4" "5" "6" "Sam" "Dom")) +(setf (gethash 6 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 7 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 8 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 9 day-of-week-abbreviation) #("??" "Mo" "Ti" "On" "To" "Fr" "Lo" "So")) +(setf (gethash 10 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) +(setf (gethash 11 day-of-week-abbreviation) #("" "" "" "" "" "" "" "")) + +(defparameter long-format (make-array '(12) :initial-contents + '(("~A, ~A ~A ~A" 10) ; 0 Default, the second value describes order: + ("~A, ~A ~A ~A" 10) ; 1 English 11=DMY 10=MDY see #'date-to-text-long + ("~A ~A ~A ~A" 10) ; 2 Francais + ("~A, den ~A ~A ~A" 11) ; 3 Deutsch + ("~A, ~A de ~A de ~A" 10) ; 4 Espanol + ("~A, dia ~A de ~A de ~A" 10) ; 5 Portugues + ("~A, ~A ~A ~A" 10) ; 6 Nederlands + ("~A, ~A ~A ~A" 10) ; 7 Italiano + ("~A, ~A. ~A ~A" 10) ; 8 Norsk + ("~A, ~A ~A ~A" 10) ; 9 Svenska + ("~A, ~A. ~A ~A" 10) ; 10 Dansk + ("~A, ~A. ~A ta ~A" 10)))) ; 11 suomi + +(defparameter language-to-text + (vector "???" "English" "Francais" "Deutsch" "Espanol" + "Portugues" "Nederlands" "Italiano" "Norsk" + "Svenska" "Dansk" "suomi")) + +;;;; Functions +(defun decode-day-of-week (str) + "Returns number of weekday. STR can partially name the Weekday. DOW is not CL conform." + (let ((week-vector (gethash *language* day-of-week-to-text)) + (i 0)) + (loop for weekday across week-vector + until (search str weekday :test #'char-equal) + do (incf i) + finally (return (if (<= i 7) i nil))))) + +(defun cl-decode-day-of-week (str) + "Returns number of weekday. STR can partially name the Weekday. DOW is CL conform." + (let ((week-vector (gethash *language* day-of-week-to-text)) + (i 0)) + (loop for weekday across week-vector + until (search str weekday :test #'char-equal) + do (incf i) + finally (return (if (<= i 7) (1- i) nil))))) + +(defun decode-month (str) + "Returns number of month. STR can partially name the month. Computes a (search ...:test #'char-equal)." + (let ((month-vector (gethash *language* month-to-text)) + (i 0)) + (loop for month across month-vector + until (search str month :test #'char-equal) + do (incf i) + finally (return (if (<= i 12) i nil))))) + +(defun decode-language (num) + "Returns the Language of number NUM." + (svref language-to-text num)) + +(defun iso-lc (char) + "Returns lower case CHAR." + (char-downcase char)) + +(defun iso-uc (char) + "Returns upper case CHAR." + (char-upcase char)) + +(defun year-to-days (year) + "Returns the number of days for YEAR since 1 Jan 1." + (+ (- (+ (* year 365) (ash year -2)) + (floor (/ (ash year -2) 25))) + (ash (floor (/ (ash year -2) 25)) -2))) + +(defun fixed-window (year) + "Convert two digit YEAR to four digit YEAR; YEAR<=70 -> 2000+YEAR; YEAR<100&&>70 -> 1900+YEAR." + (if (and (> year 70) (< year 100)) + (+ 1900 year) + (+ 2000 year))) + +(defun center (string width) + "Return a string that is WIDTH long with STRING centered in it." + (let* ((pad (- width (length string))) + (lpad (truncate pad 2)) + (rpad (- pad (truncate pad 2)))) + (if (<= pad 0) + string + (concatenate 'string (make-string lpad :initial-element #\Space) string (make-string rpad :initial-element #\Space))))) + +(defun normalize-time (dd dh dm ds) +"Internal fn for normalize-dhms. Returns the normalized (values DD DH DM DS)." + (values (+ dd (floor (+ dh (floor (+ dm (floor ds 60)) 60)) 24)) ; dd + (- (+ dh (floor (+ dm (floor ds 60)) 60)) + (* (floor (+ dh (floor (+ dm (floor ds 60)) 60)) 24) 24)) ; dh + (- (+ dm (floor ds 60)) (* (floor (+ dm (floor ds 60)) 60) 60)) ;dm + (- ds (* (floor ds 60) 60)))) ;ds + +(defun normalize-ranges (dd dh dm ds) +"Internal fn for normalize-dhms. Returns the normalized (values DD DH DM DS). This function prevents overflow errors on systems with short longs (e.g. 32-bits) (If need be for CL ???)." + (normalize-time (+ dd (floor dh 24)) + (+ (- dh (* (floor dh 24) 24)) (floor dm 60)) + (- dm (* (floor dm 60) 60)) + ds)) + +(defun normalize-signs (dd dh dm ds) +"Internal fn for normalize-dhms." + (let* ((quot (floor ds 86400)) + (ds1 (- ds (* quot 86400))) + (dd1 (+ dd quot))) + (setq dh 0 dm 0) + (if (not (= dd1 0)) + (if (> dd1 0) + (when (< ds 0) + (setq ds1 (+ ds 86400) + dd1 (1- dd1))) + (when (> ds 0) + (setq ds1 (- ds 86400) + dd1 (1+ dd1))))) + (if (not (= ds1 0)) + (normalize-time dd1 dh dm ds1) + (values dd1 dh dm ds1)))) + +(defun valid-year-p (year) (>= year 1)) +(defun valid-month-p (month) (and month (>= month 1) (<= month 12))) + +(defun leap-year (year) + "This function returns 1 if the given YEAR is a leap year and 0 otherwise." + (if (or (and (zerop (mod year 4)) + (not (zerop (mod year 100)))) + (zerop (mod year 400))) + 1 + 0)) + +(defun leap-year-p (year) + "This function returns t if the given YEAR is a leap year and nil otherwise." + (if (or (and (zerop (mod year 4)) + (not (zerop (mod year 100)))) + (zerop (mod year 400))) + t + nil)) + +(defun days-in-month (year month) + "This function returns the number of days in the given MONTH of the given YEAR." + (if (and (valid-year-p year) + (valid-month-p month)) + (aref days-in-month-arr (leap-year year) month))) + +(defun days-in-year (year &optional month) + "This function returns the number of days in the given YEAR and optional MONTH. If MONTH is [1..12], return the number of days in that YEAR as of the last of that MONTH." + (aref days-in-year-arr (leap-year year) (if (and month (>= month 0) (<= month 12)) + month + 12))) + +(defun check-date (year month day) + "This function returns t if the given three numerical values YEAR MONTH DAY constitute a valid date, and nil otherwise." + (and (valid-year-p year) + (valid-month-p month) + (>= day 1) + (<= day (days-in-month year month)))) + +(defun check-time-p (hour min sec) + "This function returns t if the given three numerical values HOUR MIN SEC constitute a valid time, and nil otherwise." + (and (>= hour 0) (< hour 24) + (>= min 0) (< min 60) + (>= sec 0) (< sec 60))) + +(defun day-of-year (year month day) + "This function returns the sum of the number of days in the months starting with January up to and including MONTH in + the given year YEAR. 0 on failure." + (if (check-date year month day) + (+ day (aref days-in-year-arr (leap-year year) (1- month))) + 0)) + +(defun date-to-days (year month day) + "This function returns the (absolute) number of the day of the given date, where counting starts at the 1.Jan 1." + (if (check-date year month day) + (+ (year-to-days (1- year)) + (day-of-year year month day)) + 0)) + +(defun day-of-week (year month day) + "This function returns the DOW of YEAR MONTH DAY. DOW not CL conform." + (let ((days (date-to-days year month day))) + (if (> days 0) + (1+ (mod (1- days) 7)) + days))) + +(defun cl-day-of-week (year month day) + "This function returns the DOW of YEAR MONTH DAY. DOW CL conform." + (let ((days (date-to-days year month day))) + (if (> days 0) + (mod (1- days) 7) + days))) + +(defun weeks-in-year (year) + "This function returns the number of weeks in the given YEAR, i.e., either 52 or 53." + (if (or (= 4 (day-of-week year 1 1)) + (= 4 (day-of-week year 12 31))) + 53 52)) + +(defun cl-weeks-in-year (year) + "This function returns the number of weeks in the given YEAR for CL DOW conform numbering (Monday=0)., i.e., either 52 or 53." + (if (or (= 3 (cl-day-of-week year 1 1)) + (= 3 (cl-day-of-week year 12 31))) + 53 52)) + +(defun check-business-p (year week dow) + "This function returns true if the given three numerical values YEAR WEEK DOW constitute a valid date in business format, and nil otherwise. Beware that this function does NOT compute whether a given date is a business day (i.e., Monday to Friday)! To do so, use (< (day-of-week year month day) 6) instead. DOW not CL conform." + (and (>= year 1) + (>= week 1) + (<= week (weeks-in-year year)) + (>= dow 1) + (<= dow 7))) + +(defun cl-check-business-p (year week dow) + "This function returns true if the given three numerical values YEAR WEEK DOW constitute a valid date in business format for CL (Monday=0), and nil otherwise. DOW is CL conform." + (and (>= year 1) + (>= week 1) + (<= week (weeks-in-year year)) + (>= dow 0) + (<= dow 6))) + +(defun delta-days (year1 month1 day1 year2 month2 day2) + "This function returns the difference in days between Y1 M1 D1 and Y2 M2 D2." + (- (date-to-days year2 month2 day2) + (date-to-days year1 month1 day1))) + +(defun week-number (year month day) + "This function returns the number of the week of the given Y M D lies in. If the given date lies in the LAST week of the PREVIOUS year, 0 is returned." + (let ((first-jan (1- (day-of-week year 1 1)))) + (if (< first-jan 4) + (1+ (truncate (+ first-jan (delta-days year 1 1 year month day)) 7)) + (+ 0 (truncate (+ first-jan (delta-days year 1 1 year month day)) 7))))) ; + 0..-> only return one value + +(defun week-of-year (year month day) + "Return (values week year) where week is the week number of YEAR" + (if (not (check-date year month day)) + nil + (progn + (let ((week (week-number year month day))) + (if (= week 0) + (values (weeks-in-year (1- year)) year) + (progn + (if (> week (weeks-in-year year)) + (values 1 (1+ year)) + (values week year)))))))) + +(defun add-delta-days (year month day delta) + "This function returns (values year month day) such that it is YEAR MONTH DAY plus DELTA days" +;; Be careful when changing things in this fn ! Side effects ! +;; Fairly direct port from the PERL routine. Pretty imperative style. + (let* ((days (+ (date-to-days year month day) delta)) + (y1 (round (/ days 365.2425))) + (d1 (- days (year-to-days y1)))) + (when (> days 0) + (progn + (if (< d1 1) + (setf d1 (- days (year-to-days (1- y1)))) ; then + (setf y1 (1+ y1))) ; else + (if (> d1 (days-in-year y1)) + (setf d1 (- d1 (days-in-year y1)) + y1 (1+ y1))) + (loop for index downfrom 12 to 1 + until (> d1 (days-in-year y1 index)) + finally (return (values y1 (1+ index) (- d1 (days-in-year y1 index))))))))) ; index=month just one to low here after until, thats why (1+ index) as return value + +(defun monday-of-week (week year) + "Return (values year month day) where month and day correspond to the Monday of WEEK in YEAR" + (let ((erst (1- (day-of-week year 1 1)))) + (if (< erst 4) + (add-delta-days year 1 1 (- (* (1- week) 7) erst)) + (add-delta-days year 1 1 (- (* week 7) erst))))) + +(defun nth-weekday-of-month-year (year month dow n) + "This function returns the (year month day) of the N-th day of week DOW in the given MONTH and YEAR; such as, for example, the 3rd Thursday of a given month and year. DOW is not CL conform." + (when (and (check-date year month 1) ; check params + (>= dow 1) (<= dow 7) + (> n 0) (< n 5)) + (let* ((erst (day-of-week year month 1)) + (tow (if (< dow erst) + (+ dow 7) + dow))) + (multiple-value-bind (y m d) + (add-delta-days year month 1 (+ (- tow erst) (* (1- n) 7))) + (when (= month m) + (values y m d)))))) + +(defun cl-nth-weekday-of-month-year (year month dow n) + "This function returns the (year month day) of the N-th day of week DOW in the given MONTH and YEAR; such as, for example, the 3rd Thursday of a given month and year. DOW is CL conform." + (when (and (check-date year month 1) ; check params + (>= dow 0) (<= dow 6) + (> n 0) (< n 5)) + (let* ((erst (cl-day-of-week year month 1)) + (tow (if (< dow erst) + (+ dow 7) + dow))) + (multiple-value-bind (y m d) + (add-delta-days year month 1 (+ (- tow erst) (* (1- n) 7))) + (when (= month m) + (values y m d)))))) + +(defun standard-to-business (year month day) + "This function converts a given date from standard notation YEAR MONTH DAY to business notation year week dow. DOW is not CL conform." + (multiple-value-bind (week y) (week-of-year year month day) + (when week + (values y week (day-of-week year month day))))) + +(defun cl-standard-to-business (year month day) + "This function converts a given date from standard notation YEAR MONTH DAY to business notation year week day of week. DOW is CL conform." + (multiple-value-bind (week y) (week-of-year year month day) + (when week + (values y week (cl-day-of-week year month day))))) + + +(defun business-to-standard (year week dow) + "This function converts a given date from business notation YEAR WEEK DOW to standard notation year month day. DOW is not CL conform." + (when (check-business-p year week dow) + (let* ((erst (day-of-week year 1 1)) + (delta (+ (- dow erst) (* 7 (1- (+ week (if (> erst 4) 1 0))))))) + (add-delta-days year 1 1 delta)))) + +(defun cl-business-to-standard (year week dow) + "This function converts a given date from business notation YEAR WEEK DOW to standard notation year month day. DOW is CL conform." + (when (cl-check-business-p year week dow) + (let* ((erst (cl-day-of-week year 1 1)) + (delta (+ (- dow erst) (* 7 (1- (+ week (if (> erst 4) 1 0))))))) + (add-delta-days year 1 1 delta)))) + +(defun delta-hms (hour1 min1 sec1 hour2 min2 sec2) + "This function returns the difference of H1 M1 S1 and H2 M2 S2 in (values d h m s)." + (when (and (check-time-p hour1 min1 sec1) + (check-time-p hour2 min2 sec2)) + (normalize-signs 0 0 0 (- (+ sec2 (* 60 (+ min2 (* 60 hour2)))) + (+ sec1 (* 60 (+ min1 (* 60 hour1)))))))) + +(defun delta-dhms (year1 month1 day1 hour1 min1 sec1 year2 month2 day2 hour2 min2 sec2) + "Returns the difference in (values d h m s) between the two given dates with times (Y1 M1 D1 H1 MIN1 SEC1 and Y2 M2 D2 H2 MIN2 SEC2)." + (let ((dd (delta-days year1 month1 day1 year2 month2 day2))) + (multiple-value-bind (d h m s) (delta-hms hour1 min1 sec1 hour2 min2 sec2) + (if d + (values (+ d dd) h m s) + (values d h m s))))) + +(defun delta-ymd (year1 month1 day1 year2 month2 day2) + "This function returns the difference (values YEAR MONTH DAYS) between the two dates Y1M1D1 and Y2M2D2." + (if (and (check-date year1 month1 day1) + (check-date year2 month2 day2)) + (values (- year2 year1)(- month2 month1)(- day2 day1)) + nil)) + +(defun delta-ymdhms (year1 month1 day1 hour1 min1 sec1 + year2 month2 day2 hour2 min2 sec2) + "This function returns the difference (values YEAR MONTH DAYS HOUR MINUTE SEC) between +the two dates Y1 M1 D1 H1 MI1 S1 and Y2 M2 D2 H2 MI2 S2." + (multiple-value-bind (y m d) (delta-ymd year1 month1 day1 year2 month2 day2) + (when y + (multiple-value-bind (dd hh mm ss) + (delta-hms hour1 min1 sec1 hour2 min2 sec2) + (when dd + (values y m (+ dd d) hh mm ss)))))) + +(defun normalize-dhms (day hour min sec) + "This function takes four arbitrary values for days, hours, minutes and seconds (which may have different signs) and renormalizes them so that the values for hours, minutes and seconds will lie in the ranges [-23..23], [-59..59] and [-59..59], respectively, and so that they have the same sign." + (multiple-value-bind (dd dh dm ds) (normalize-ranges day hour min sec) + (when ds + (normalize-signs dd dm dh (+ ds (* 60 (+ dm (* 60 dh)))))))) + +(defun add-delta-dhms (year month day hour min sec dd dh dm ds) + "This function serves to add a days, hours, minutes and seconds offset to a given date and time (YEAR MONTH DAY HOUR MINUTE SECOND DDAY DHOUR DMINUTE DSECOND), in order to answer questions like \"today and now plus 7 days but minus 5 hours and then plus 30 minutes, what date and time gives that?\". Returns: (values y m d h min sec)" + (when (and (check-date year month day) + (check-time-p hour min sec)) + (multiple-value-bind (d1 h1 m1 s1) (normalize-ranges dd dh dm ds) + (when d1 + (progn + (let ((s2 (+ s1 (* 60 (+ m1 (* 60 h1))) (+ sec (* 60 (+ min (* 60 hour))))))) + (when (= 0 s2) + (multiple-value-bind (yy mm ddd) (add-delta-days year month day d1) + (values yy mm ddd 0 0 0))) + (when (< s2 0) + (multiple-value-bind (dd1 ss2) (truncate s2 86400) + (multiple-value-bind (ddd hh mm ss) (normalize-time (+ d1 dd1) 0 0 ss2) + (multiple-value-bind (yy mmm dddd) (add-delta-days year month day ddd) + (values yy mmm dddd hh mm ss))))) + (when (> s2 0) + (multiple-value-bind (ddd hh mm ss) (normalize-time d1 0 0 s2) + (multiple-value-bind (yy mmm dddd) (add-delta-days year month day ddd) + (values yy mmm dddd hh mm ss)))))))))) + +(defun add-year-month (year month dy dm) + "This function adds DYEAR and DMONTH offset to YEAR and MONTH." + (let ((mt (+ month dm))) + (if (> mt 0) + (multiple-value-bind (jahre monate) (truncate (1- mt) 12) + (values (+ jahre (+ year dy)) (1+ monate))) + (multiple-value-bind (jahre monate) (truncate mt 12) + (values (+ (+ year dy) jahre -1) (+ 12 monate)))))) + +(defun add-delta-ym (year month day dy dm) + "This function adds DYEAR and DMONTH offset to YEAR MONTH DAY." + (when (check-date year month day) + (multiple-value-bind (jahr monat) (add-year-month year month dy dm) + (values jahr monat day)))) + +(defun add-delta-ymd (year month day dy dm dd) + "This function adds DYEAR DMONTH and DDAY offset to YEAR MONTH DAY." + (when (check-date year month day) + (multiple-value-bind (jahr monat tag) (add-delta-ym year month day dy dm) + (when jahr + (add-delta-days jahr monat tag dd))))) + +(defun add-delta-ymdhms (year month day hour min sec dyear dmonth dday dh dm ds) + "This function is the same as add-delta-ymd except that a time offset may be given in addition to the year, month and day offset" + (multiple-value-bind (jahr monat) (add-year-month year month dyear dmonth) + (when jahr + (add-delta-dhms jahr monat 1 hour min sec (+ dday (1- day)) dh dm ds)))) + +(defun system-clock (gmt time) + "This function returns (values year month day hour min sec doy dow dst) based on current system clock. DOW is not CL conform." + (multiple-value-bind (second minute hour day month year dow daylight-p dst) + (decode-universal-time time) + (declare (ignorable daylight-p)) + (let ((doy (day-of-year year month day))) + (if gmt + (multiple-value-bind (jahr monat tag std min sek) + (add-delta-dhms year month day hour minute second 0 0 dst 0) + (values jahr monat tag std min sek doy (1+ dow) dst)) + (values year month day hour minute second doy (1+ dow) dst))))) + +(defun cl-system-clock (gmt time) + "This function returns (values year month day hour min sec doy dow dst) based on current system clock. DOW is CL conform." + (multiple-value-bind (second minute hour day month year dow daylight-p dst) + (decode-universal-time time) + (declare (ignorable daylight-p)) + (let ((doy (day-of-year year month day))) + (if gmt + (multiple-value-bind (jahr monat tag std min sek) + (add-delta-dhms year month day hour minute second 0 0 dst 0) + (values jahr monat tag std min sek doy dow dst)) + (values year month day hour minute second doy dow dst))))) + +;;;;;;; Add gmt flag +(defun gmtime () + (system-clock t (get-universal-time))) + +(defun localtime () + (system-clock nil (get-universal-time))) + +(defun today () + "This function returns (year month day) for today." + (multiple-value-bind (sec minute hour day month year) (get-decoded-time) + (declare (ignorable sec minute hour)) + (values year month day))) + +(defun yesterday () + (multiple-value-bind (jahr monat tag) (today) + (add-delta-days jahr monat tag -1))) + +(defun tomorrow () + (multiple-value-bind (jahr monat tag) (today) + (add-delta-days jahr monat tag 1))) + +(defun now () + "This function returns (hour minute second) for right now." + (multiple-value-bind (second minute hour) (get-decoded-time) + (values hour minute second))) + +(defun today-and-now () + "This function returns (year month day hour minute second) for the current date and time." + (multiple-value-bind (second minute hour day month year) (get-decoded-time) + (values year month day hour minute second))) + +(defun this-year () + "This function returns the current year in localtime." + (multiple-value-bind (second minute hour day month year) (get-decoded-time) + (declare (ignorable second minute hour day month)) + year)) + +(defun date-to-text (year month day) + "Return a pretty print string of YEAR MONTH DAY in DOW-TXT(SHORT) DAY MONTH YEAR with a little bit of sorting for language." + (let ((prn (first (aref long-format *language*)))) ; get print format + (multiple-value-bind (a b c) ; What order is the date DMY , MDY .... + (let ((k (second (aref long-format *language*)))) + (case k ; return the order of DMY + (10 (values month day year)) + (11 (values day month year)) + (otherwise (values month day year)))) ; return english by default + (format nil prn ; make the return string + (svref (gethash *language* day-of-week-abbreviation) ; Get Name of Weekday + (day-of-week year month day)) + a b c)))) + +(defun date-to-text-long (year month day) + "Return a pretty print string of YEAR MONTH DAY in DOW-TXT(LONG) DAY MONTH YEAR with a little bit of sorting for language." + (let ((prn (first (aref long-format *language*)))) ; get print format + (multiple-value-bind (a b c) ; What order is the date DMY , MDY .... + (let ((k (second (aref long-format *language*)))) + (case k ; return the order of DMY + (10 (values month day year)) + (11 (values day month year)) + (otherwise (values month day year)))) ; return english by default + (format nil prn ; make the return string + (svref (gethash *language* day-of-week-to-text) ; Get Name of Weekday + (day-of-week year month day)) + a b c)))) + Modified: branches/xml-class-rework/modules/bknr-modules.asd =================================================================== --- branches/xml-class-rework/modules/bknr-modules.asd 2006-10-14 09:33:53 UTC (rev 1990) +++ branches/xml-class-rework/modules/bknr-modules.asd 2006-10-14 09:35:08 UTC (rev 1991) @@ -25,7 +25,7 @@ :bknr-utils :puri :stem - :mime + #+(or) :mime :bknr :klammerscript #+(not allegro) From bknr at bknr.net Sat Oct 14 11:25:19 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Sat, 14 Oct 2006 07:25:19 -0400 (EDT) Subject: [bknr-cvs] r1992 - in branches/xml-class-rework/projects/bos: m2 payment-website/infosystem payment-website/infosystem/de worldpay-test Message-ID: <20061014112519.B02985B067@common-lisp.net> Author: hhubner Date: 2006-10-14 07:25:17 -0400 (Sat, 14 Oct 2006) New Revision: 1992 Added: branches/xml-class-rework/projects/bos/worldpay-test/contract-image-handler.lisp Modified: branches/xml-class-rework/projects/bos/m2/m2.lisp branches/xml-class-rework/projects/bos/m2/packages.lisp branches/xml-class-rework/projects/bos/payment-website/infosystem/de/satellitenkarte.htm branches/xml-class-rework/projects/bos/payment-website/infosystem/javascript.js branches/xml-class-rework/projects/bos/worldpay-test/sponsor-handlers.lisp branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.asd branches/xml-class-rework/projects/bos/worldpay-test/worldpay-test.lisp Log: Improved rendering of sold areas. The rendering is now done on the server side, which greatly improves performance with large contracts. Modified: branches/xml-class-rework/projects/bos/m2/m2.lisp =================================================================== --- branches/xml-class-rework/projects/bos/m2/m2.lisp 2006-10-14 09:35:08 UTC (rev 1991) +++ branches/xml-class-rework/projects/bos/m2/m2.lisp 2006-10-14 11:25:17 UTC (rev 1992) @@ -158,6 +158,7 @@ ;;; CONTRACT-PAIDP (contract) => boolean ;;; CONTRACT-DATE (contract) => Universal-Timestamp ;;; CONTRACT-M2S (contract) => list of m2 +;;; CONTRACT-BOUNDING-BOX (contract) => (list left top width height) ;;; ;;; CONTRACT-SET-PAIDP (contract newval) => newval @@ -266,6 +267,15 @@ image-tiles)) image-tiles)) +(defmethod contract-bounding-box ((contract contract)) + (let (min-x min-y max-x max-y) + (dolist (m2 (contract-m2s contract)) + (setf min-x (min (m2-x m2) (or min-x (m2-x m2)))) + (setf min-y (min (m2-y m2) (or min-y (m2-y m2)))) + (setf max-x (max (m2-x m2) (or max-x (m2-x m2)))) + (setf max-y (max (m2-y m2) (or max-y (m2-y m2))))) + (list min-x min-y (1+ (- max-x min-x)) (1+ (- max-y min-y))))) + (defun tx-make-contract (sponsor m2-count &key date paidp expires) (warn "Old tx-make-contract transaction used, contract dates may be wrong") (tx-do-make-contract sponsor m2-count :date date :paidp paidp :expires expires)) @@ -321,30 +331,19 @@ "Erzeugt das Quadratmeter-Javascript f?r die angegebenen Contracts" (with-output-to-string (*standard-output*) (let ((paid-contracts (remove nil (sponsor-contracts sponsor) :key #'contract-paidp))) - (format t "profil = [];~%") - (format t "qms = [ undefined ];~%") + (format t "profil = {};~%") (format t "profil['id'] = ~D;~%" (store-object-id sponsor)) (format t "profil['name'] = ~S;~%" (string-safe (or (user-full-name sponsor) "[anonym]"))) (format t "profil['country'] = ~S;~%" (or (sponsor-country sponsor) "[unbekannt]")) (format t "profil['anzahl'] = ~D;~%" (loop for contract in paid-contracts sum (length (contract-m2s contract)))) (format t "profil['nachricht'] = '~A';~%" (string-safe (sponsor-info-text sponsor))) + (format t "profil['contracts'] = [ ];~%" (store-object-id (first paid-contracts))) (loop for contract in paid-contracts - for m2s = (sort (copy-list (contract-m2s contract)) #'(lambda (a b) (if (eql (m2-y a) (m2-y b)) - (< (m2-x a) (m2-x b)) - (< (m2-y a) (m2-y b))))) - do (progn - (format t "var qm = [];~%") - (format t "qm['x'] = ~D;~%" (m2-x (first (contract-m2s contract)))) - (format t "qm['y'] = ~D;~%" (m2-y (first (contract-m2s contract)))) - (format t "qm['datum'] = ~S;~%" (format-date-time (contract-date contract) :show-time nil)) - (format t "qm['qm_x'] = [0, ~D~{,~D~}];~%" - (m2-x (first m2s)) - (mapcar #'m2-x (cdr m2s))) - (format t "qm['qm_y'] = [0, ~D~{,~D~}];~%" - (m2-y (first m2s)) - (mapcar #'m2-y (cdr m2s))) - (format t "qms.push(qm);~%")))))) + do (destructuring-bind (left top width height) (contract-bounding-box contract) + (format t "profil.contracts.push({ left: ~A, top: ~A, width: ~A, height: ~A, date: ~S });~%" + left top width height + (format-date-time (contract-date contract) :show-time nil))))))) (defun delete-directory (pathname) (when (probe-file pathname) Modified: branches/xml-class-rework/projects/bos/m2/packages.lisp =================================================================== --- branches/xml-class-rework/projects/bos/m2/packages.lisp 2006-10-14 09:35:08 UTC (rev 1991) +++ branches/xml-class-rework/projects/bos/m2/packages.lisp 2006-10-14 11:25:17 UTC (rev 1992) @@ -97,6 +97,7 @@ #:contract-paidp #:contract-date #:contract-m2s + #:contract-bounding-box #:contract-color #:contract-cert-issued #:contract-set-paidp Modified: branches/xml-class-rework/projects/bos/payment-website/infosystem/de/satellitenkarte.htm =================================================================== --- branches/xml-class-rework/projects/bos/payment-website/infosystem/de/satellitenkarte.htm 2006-10-14 09:35:08 UTC (rev 1991) +++ branches/xml-class-rework/projects/bos/payment-website/infosystem/de/satellitenkarte.htm 2006-10-14 11:25:17 UTC (rev 1992) @@ -310,6 +310,9 @@ - \ No newline at end of file + From bknr at bknr.net Thu Oct 26 04:11:11 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Thu, 26 Oct 2006 00:11:11 -0400 (EDT) Subject: [bknr-cvs] r2047 - trunk/projects/bos/payment-website/infosystem Message-ID: <20061026041111.BE6C755395@common-lisp.net> Author: hhubner Date: 2006-10-26 00:11:11 -0400 (Thu, 26 Oct 2006) New Revision: 2047 Modified: trunk/projects/bos/payment-website/infosystem/javascript.js Log: Slightly changed API for panoramas. This file needs to be totally re-done. Modified: trunk/projects/bos/payment-website/infosystem/javascript.js =================================================================== --- trunk/projects/bos/payment-website/infosystem/javascript.js 2006-10-25 16:41:23 UTC (rev 2046) +++ trunk/projects/bos/payment-website/infosystem/javascript.js 2006-10-26 04:11:11 UTC (rev 2047) @@ -841,14 +841,16 @@ } function show_poi_panorama() { + var the_poi = poi[aktuelles_objekt]; help_page = 'panorama'; hide_poi_luftbild(); - if (poi[aktuelles_objekt]['panorama']) { + if (the_poi.panoramas) { + var panorama_id = the_poi.panoramas[0]; document.getElementById("Panorama").style.visibility = "visible"; document.getElementById("PoiInfoText").innerHTML = msg('Das Laden des Panoramas dauert einen Moment und ben?tigt Java in Ihrem Browser.

Klicken und Ziehen Sie mit der Maus, um sich im Panorama umzusehen!'); document.getElementById("PanoramaApplet").innerHTML = ' ' - + ' ' + + ' ' + ' ' + ' ' + ''; @@ -896,7 +898,7 @@ if (the_poi['luftbild']) { poi_menu_items.push([ msg('Luftbild'), show_poi_luftbild ]); } - if (the_poi['panorama']) { + if (the_poi.panoramas) { poi_menu_items.push([ msg('Panorama'), show_poi_panorama ]); } From bknr at bknr.net Thu Oct 26 04:12:16 2006 From: bknr at bknr.net (bknr at bknr.net) Date: Thu, 26 Oct 2006 00:12:16 -0400 (EDT) Subject: [bknr-cvs] r2048 - in trunk/projects/bos: m2 worldpay-test Message-ID: <20061026041216.62D0662001@common-lisp.net> Author: hhubner Date: 2006-10-26 00:12:15 -0400 (Thu, 26 Oct 2006) New Revision: 2048 Modified: trunk/projects/bos/m2/m2.lisp trunk/projects/bos/m2/packages.lisp trunk/projects/bos/m2/poi.lisp trunk/projects/bos/worldpay-test/poi-handlers.lisp trunk/projects/bos/worldpay-test/sponsor-handlers.lisp trunk/projects/bos/worldpay-test/tags.lisp Log: New panoramas API for sat application. Fixed dowload-only certificates with manual money transfer. Modified: trunk/projects/bos/m2/m2.lisp =================================================================== --- trunk/projects/bos/m2/m2.lisp 2006-10-26 04:11:11 UTC (rev 2047) +++ trunk/projects/bos/m2/m2.lisp 2006-10-26 04:12:15 UTC (rev 2048) @@ -181,7 +181,7 @@ (paidp :update) (m2s :read) (color :read) - (download-only :read) + (download-only :update) (cert-issued :read) (worldpay-trans-id :update :initform nil) (expires :read :documentation "universal time which specifies the time the contract expires (is deleted) when it has not been paid for" :initform nil)) @@ -235,6 +235,9 @@ (or (contract-download-only contract) (< (contract-price contract) *mail-amount*))) +(deftransaction contract-set-download-only-p (contract newval) + (setf (contract-download-only contract) newval)) + (defmethod contract-fdf-pathname ((contract contract) language) (merge-pathnames (make-pathname :name (format nil "~D-~(~A~)" (store-object-id contract) Modified: trunk/projects/bos/m2/packages.lisp =================================================================== --- trunk/projects/bos/m2/packages.lisp 2006-10-26 04:11:11 UTC (rev 2047) +++ trunk/projects/bos/m2/packages.lisp 2006-10-26 04:12:15 UTC (rev 2048) @@ -102,6 +102,7 @@ #:contract-color #:contract-cert-issued #:contract-set-paidp + #:contract-set-download-only-p #:contract-price #:contract-issue-cert #:contract-worldpay-trans-id Modified: trunk/projects/bos/m2/poi.lisp =================================================================== --- trunk/projects/bos/m2/poi.lisp 2006-10-26 04:11:11 UTC (rev 2047) +++ trunk/projects/bos/m2/poi.lisp 2006-10-26 04:12:15 UTC (rev 2048) @@ -129,26 +129,38 @@ (not (poi-published poi)))) (store-objects-with-class 'poi)) #'(lambda (poi-1 poi-2) (string-lessp (slot-string poi-1 'title language) (slot-string poi-2 'title language))))) - (format t "var poi = [];~%") - (format t "poi['symbol'] = ~S;~%" (poi-name poi)) - (format t "poi['icon'] = ~S;~%" (poi-icon poi)) - (format t "poi['name'] = ~S;~%" (slot-string poi 'title language)) - (format t "poi['untertitel'] = ~S;~%" (slot-string poi 'subtitle language)) - (format t "poi['text'] = ~S;~%" (escape-nl (slot-string poi 'description language))) - (format t "poi['x'] = ~D;~%" (poi-center-x poi)) - (format t "poi['y'] = ~D;~%" (poi-center-y poi)) - (format t "poi['thumbnail'] = ~D;~%" (length (poi-images poi))) + (format t " +var poi = { symbol: ~S, + icon: ~S, + name: ~S, + untertitel: ~S, + text: ~S, + x: ~D, + y: ~D, + thumbnail: ~D +}; +" + (poi-name poi) + (poi-icon poi) + (slot-string poi 'title language) + (slot-string poi 'subtitle language) + (escape-nl (slot-string poi 'description language)) + (poi-center-x poi) + (poi-center-y poi) + (length (poi-images poi))) + (format t "poi.thumbnail = ~D;~%" (length (poi-images poi))) (when (poi-airals poi) - (format t "poi['luftbild'] = ~D;~%" (store-object-id (first (poi-airals poi))))) + (format t "poi.luftbild = ~D;~%" (store-object-id (first (poi-airals poi))))) (when (poi-panoramas poi) - (format t "poi['panorama'] = ~D;~%" (store-object-id (first (poi-panoramas poi))))) + (let ((panorama-ids (mapcar #'store-object-id (poi-panoramas poi)))) + (format t "poi.panoramas = [ ~D~{, ~D~} ];~%" (first panorama-ids) (rest panorama-ids)))) (loop for slot-name in '(title subtitle description) for javascript-name in '("imageueberschrift" "imageuntertitel" "imagetext") for slot-values = (mapcar #'(lambda (image) (escape-nl (slot-string image slot-name language))) (poi-images poi)) when slot-values - do (format t "poi[~S] = [~S~{, ~S~}];~%" javascript-name (car slot-values) (cdr slot-values))) + do (format t "poi.~A = [ ~S~{, ~S~} ];~%" javascript-name (car slot-values) (cdr slot-values))) (format t "pois.push(poi);~%")) (dolist (allocation-area (remove-if (complement #'allocation-area-active-p) (class-instances 'allocation-area))) (destructuring-bind (x y) (allocation-area-center allocation-area) Modified: trunk/projects/bos/worldpay-test/poi-handlers.lisp =================================================================== --- trunk/projects/bos/worldpay-test/poi-handlers.lisp 2006-10-26 04:11:11 UTC (rev 2047) +++ trunk/projects/bos/worldpay-test/poi-handlers.lisp 2006-10-26 04:12:15 UTC (rev 2048) @@ -140,15 +140,16 @@ :br (submit-button "upload-airal" "upload-airal"))))) (:tr (:td "panorama view") - (:td (if (poi-panoramas poi) - (html ((:a :href (format nil "/image/~D" (store-object-id (first (poi-panoramas poi)))) - :target "_new") - " view ") - (submit-button "delete-panorama" "delete-panorama" :confirm "Really delete the panorama image?")) - (html "Upload new panorama view" - ((:input :type "file" :name "image-file")) - :br - (submit-button "upload-panorama" "upload-panorama"))))) + (:td (dolist (panorama (poi-panoramas poi)) + (html (:princ-safe (format-date-time (blob-timestamp panorama))) + ((:a :href (format nil "/image/~D" (store-object-id panorama)) :target "_new" :class "cmslink") + " view ") + (submit-button "delete-panorama" "delete-panorama" :confirm "Really delete this panorama image?") + :br)) + (html "Upload new panorama view" + ((:input :type "file" :name "image-file")) + :br + (submit-button "upload-panorama" "upload-panorama")))) (:tr (:td (submit-button "save" "save") (submit-button "delete" "delete" :confirm "Really delete the POI?")))))))) (defmethod handle-object-form ((handler edit-poi-handler) @@ -212,8 +213,9 @@ (cl-gd:with-image-from-file* (uploaded-file) ; just open the image to make sure that gd can process it ) - (change-slot-values poi 'panoramas (list (import-image uploaded-file - :class-name 'store-image)))) + (change-slot-values poi 'panoramas (cons (import-image uploaded-file + :class-name 'store-image) + (poi-panoramas poi)))) (redirect (format nil "/edit-poi/~D" (store-object-id poi)) req)) @@ -221,9 +223,10 @@ (action (eql :delete-panorama)) (poi poi) req) - (let ((panoramas (poi-panoramas poi))) - (change-slot-values poi 'panoramas nil) - (mapc #'delete-object panoramas)) + (with-query-params (req panorama-id) + (let ((panorama (find-store-object (parse-integer panorama-id)))) + (change-slot-values poi 'panoramas (remove panorama (poi-panoramas poi))) + (mapc #'delete-object panorama))) (redirect (format nil "/edit-poi/~D" (store-object-id poi)) req)) Modified: trunk/projects/bos/worldpay-test/sponsor-handlers.lisp =================================================================== --- trunk/projects/bos/worldpay-test/sponsor-handlers.lisp 2006-10-26 04:11:11 UTC (rev 2047) +++ trunk/projects/bos/worldpay-test/sponsor-handlers.lisp 2006-10-26 04:12:15 UTC (rev 2048) @@ -205,8 +205,10 @@ (:td (text-field "name" :size 50))) (:tr (:td "Email-Address") (:td (text-field "email" :size 20))) - (:tr (:td "Postal address for certificate" - (:td (textarea-field "postaladdress" :rows 5 :cols 40)))) + (unless (contract-download-only-p contract) + (html + (:tr (:td "Postal address for certificate" + (:td (textarea-field "postaladdress" :rows 5 :cols 40)))))) (:tr (:td (submit-button "process" "process" :formcheck "javascript:return check_complete_sale()")))))))))) (defmethod handle-object-form ((handler complete-transfer-handler) (action (eql :process)) contract req) Modified: trunk/projects/bos/worldpay-test/tags.lisp =================================================================== --- trunk/projects/bos/worldpay-test/tags.lisp 2006-10-26 04:11:11 UTC (rev 2047) +++ trunk/projects/bos/worldpay-test/tags.lisp 2006-10-26 04:12:15 UTC (rev 2048) @@ -100,7 +100,12 @@ (mapc #'emit-template-node children)) (define-bknr-tag mail-transfer () - (mail-manual-sponsor-data (get-template-var :request))) + (with-query-params ((get-template-var :request) contract-id mail-certificate) + (let* ((contract (store-object-with-id (parse-integer contract-id))) + (download-only (or (< (contract-price contract) *mail-certificate-threshold*) + (not mail-certificate)))) + (contract-set-download-only-p contract download-only) + (mail-manual-sponsor-data (get-template-var :request))))) (define-bknr-tag when-certificate (&key children) (let ((sponsor (bknr-request-user (get-template-var :request))))