Changeset 15903 for lang/gauche

Show
Ignore:
Timestamp:
07/16/08 22:58:57 (4 months ago)
Author:
kiyoka
Message:

Supported posting comment feature.

Location:
lang/gauche/oldtype/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/format.scm

    r14311 r15903  
    109109      ;; download link oldtype-mode.el source code 
    110110      ((download-el) "[Download oldtype-mode.el now]") 
     111      ;; comment-data 
     112      ((comment-data) 
     113       (if (< 1 len) 
     114           (string-append (format "----< ~a >----" (uri-decode-string (car arg))) 
     115                          "\n" 
     116                          (uri-decode-string (cadr arg))) 
     117           (format "!!Error : comment-data format error for ##(comment-data user string) command"))) 
     118      ;; else 
    111119      (else 
    112        (format "!!Error : no such macro \"~a\"!!" command))))) 
     120       (format "[~a]" command))))) 
    113121 
    114122 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/oldtype.css

    r14648 r15903  
    681681    color: white; 
    682682} 
     683 
     684pre.comment { 
     685        margin-left:    0.5em; 
     686        font-size:      medium; 
     687        padding-left:   0.5em; 
     688        margin-top:     1px; 
     689        margin-bottom:  1px; 
     690} 
     691 
     692table.comment { 
     693        width: 70%; 
     694} 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/oldtype.kahua

    r14618 r15903  
    1414(use oldtype.timeline) 
    1515(use oldtype.page) 
     16(use oldtype.svn) 
    1617(use srfi-1) 
    1718(use srfi-19) 
     19(use srfi-27) 
    1820(load "oldtype/version.kahua") 
    1921(load "oldtype/util.kahua") 
     
    259261                                ((h5)          `(,@(h5/  (@/ (id "h5"))                  (node-set (rec arg))))) 
    260262                                ((h6)          `(,@(h6/  (@/ (id "h6"))                  (node-set (rec arg)))))))) 
    261                          ((wiki-macro)  `(,@(oldtype:format-macro arg))) 
     263                         ((wiki-macro)  `(,@(oldtype:format-macro arg oldtype-page))) 
    262264                         ((wiki-name)   `(,@(oldtype:expand-wiki-name (car arg)))) 
    263265                         ((hr)          (hr/)) 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/svn.scm

    r15741 r15903  
    4141          status 
    4242          get-fullpath 
     43          save-text-list 
    4344          <svn-work> 
    4445          )) 
     
    107108           (display str) 
    108109           (if (string= "" str) 
    109                #f 
     110               '("" "") 
    110111               (string-split str #/[ ]+/)))))) 
    111112 
     
    121122 
    122123 
     124(define-method save-text-list ((self <svn-work>) wikiname text-list) 
     125  (with-output-to-file (format "~a/edit/~a.ot" (get-fullpath self) wikiname) 
     126    (lambda () 
     127      (for-each 
     128       (lambda (str) 
     129         (display str) 
     130         (newline)) 
     131       text-list)))) 
     132 
     133 
    123134(provide "oldtype/svn") 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/util.kahua

    r15232 r15903  
    230230     (img/ (@/ (src (string-append (oldtype:static-image-path) "icon.article_text.png")) 
    231231               (alt "PLAIN")))) 
     232    ((comment) 
     233     (img/ (@/ (src (string-append (oldtype:static-image-path) "icon.comment_blue.png")) 
     234               (alt "COMMENT")))) 
     235    ((double-comment) 
     236     (img/ (@/ (src (string-append (oldtype:static-image-path) "icon.double_comment.png")) 
     237               (alt "DCOMMENT")))) 
     238    ((alert) 
     239     (img/ (@/ (src (string-append (oldtype:static-image-path) "icon.stop_round.png")) 
     240               (alt "ALERT")))) 
    232241    (else 
    233242     `(p/ ,(format "!!Error : no such icon-image \"~a\"!!" sym))))) 
    234      
    235  
    236 (define (oldtype:format-macro expr) 
     243 
     244 
     245(define (oldtype:add-comment oldtype-page name comment) 
     246  (apply append 
     247         (map 
     248          (lambda (str) 
     249            (if (#/##\(comment\)/ str) 
     250                `( 
     251                  ,(format "##(comment-data ~a ~a)" 
     252                           (uri-encode-string name) 
     253                           (uri-encode-string comment)) 
     254                  ,str) 
     255                `(,str))) 
     256          (get-text-list oldtype-page)))) 
     257 
     258 
     259(define (oldtype:format-macro expr oldtype-page) 
    237260  (let ((command (car expr)) 
    238261        (arg  ;; symbol list to string list. 
     
    337360      ;; input comment 
    338361      ((comment) 
    339        (form/ (@/ (action ".")) 
    340               (table/ 
    341                (tr/ (th/ "Post a comment")) 
    342                (tr/ (td/ 
    343                      "Name:" 
    344                      (input/ 
    345                       (@/ (type "text") (value "") (size 20))))) 
    346                (tr/ (td/ 
    347                      (textarea/ 
    348                       (@/ (cols 120) (rows 3))))) 
    349                (tr/ (td/ 
    350                      (input/ (@/ (type "submit") (value "Submit comment")))))))) 
     362       (form/cont/ 
     363        (@@/ (cont 
     364              (entry-lambda (:keyword name comment) 
     365                (let1 nodes  
     366                      (p/ 
     367                       (oldtype:icon-image 'alert) 
     368                       "Error: commit action missed.") 
     369                      (if (or (> 1 (string-length name)) 
     370                              (> 1 (string-length comment))) 
     371                          (set! nodes (p/ 
     372                                       (oldtype:icon-image 'alert) 
     373                                       "Please input name and comment.")) 
     374                          (let1 work (make <svn-work> 
     375                                       :url      (oldtype:get-arguments 'svn) 
     376                                       :user     (oldtype:get-arguments 'anon-user) 
     377                                       :pass     (oldtype:get-arguments 'anon-pass) 
     378                                       :basepath (oldtype:workpath)) 
     379                                (init work (string-append 
     380                                            (number->string (sys-time)) 
     381                                            "." 
     382                                            (number->string (random-integer 100)))) 
     383                                (save-text-list work (name-of oldtype-page) 
     384                                                (oldtype:add-comment oldtype-page name comment)) 
     385                                (let1 result (status work (name-of oldtype-page)) 
     386                                      (when (string=? "M" (car result)) 
     387                                        (begin 
     388                                          (commit work) 
     389                                          (set! nodes 
     390                                                (p/ 
     391                                                 (oldtype:icon-image 'info) 
     392                                                 "Thank you! Your comment was registered."))))))) 
     393                      (standard-page 
     394                       (name-of oldtype-page) 
     395                       (br/) 
     396                       (div/ 
     397                        nodes 
     398                        (p/ "Back to " (oldtype:expand-wiki-name (name-of oldtype-page)))) 
     399                       "" 
     400                       1))))) 
     401        (table/ (@/ (class "comment")) 
     402                (tr/ (th/ 
     403                      (oldtype:icon-image 'double-comment) 
     404                      "Post a comment")) 
     405                (tr/ (td/ 
     406                      "Name:" 
     407                      (input/ 
     408                       (@/ (type "text") (name "name") (value "") (size 20))))) 
     409                (tr/ (td/ 
     410                      (textarea/ 
     411                       (@/ (cols 120) (rows 3) (name "comment"))))) 
     412                (tr/ (td/ 
     413                      (input/ (@/ (type "submit") (value "Submit comment")))))))) 
     414       
     415      ;; display comment 
     416      ((comment-data) 
     417       (if (> 2 len) 
     418           (p/ "!!Error : No argument ##(comment-data user str) command") 
     419           (table/ (@/ (class "comment")) 
     420                   (tr/ (th/ 
     421                         (oldtype:icon-image 'comment) 
     422                         (uri-decode-string (car arg)))) 
     423                   (tr/ (td/ 
     424                         (pre/ (@/ (class "comment")) 
     425                               (uri-decode-string (cadr arg)))))))) 
    351426 
    352427      ;; no listing to !RecentChanges 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/util.scm

    r14347 r15903  
    4444          oldtype:get-string-of-today 
    4545          oldtype:editpath 
     46          oldtype:workpath 
    4647          oldtype:user-local 
    4748          oldtype:user-backend 
     
    8485   (sys-getenv "OT_SITE") 
    8586   "/tmp/oldtype/edit")) 
     87 
     88(define (oldtype:workpath) 
     89  (string-append 
     90   (sys-getenv "OT_SITE") 
     91   "/tmp/work")) 
    8692 
    8793(define (oldtype:user-local) 
  • lang/gauche/oldtype/trunk/bin/batch.sh

    r15285 r15903  
    3838  #run-parts ${OT_HOME}/hook 
    3939  echo -n [info] sleep... 
    40   sleep 5 
     40  sleep 1 
    4141  echo wakeup 
    4242} 
  • lang/gauche/oldtype/trunk/src/test.scm

    r15746 r15903  
    190190                  #t 
    191191                  (lambda () 
    192                     (string? (init work "123")))) 
     192                    (string? (init work (number->string (sys-time)))))) 
    193193 
    194194            (test "status of wikiname (no changes)" 
    195                   #f 
     195                  '("" "") 
    196196                  (lambda () 
    197197                    (status work "_kiyoka"))) 
     
    200200                  "M" 
    201201                  (lambda () 
    202                     (sys-system (format "echo 'a' >> ~a/~a/~a" (get-fullpath work) "edit" "test.ot")) 
     202                    (save-text-list work 
     203                                    "test" 
     204                                    '("UnitTest用ページ。" "----" "##(comment)")) 
    203205                    (car (status work "test")))) 
    204206             
    205207            (when 
    206                 #f 
     208                #t 
    207209              (test "commit from work" 
    208210                    #t