Page 1 of 1

Some additions to newLISP Wiki

Posted: Sat Sep 24, 2011 9:36 am
by Rexy-Craxy
Hi all.

I've added "classical" tags support functions to the newLISP Wiki /CMS v.4.6. Also I've changed its "get-pages" function to work right with non-English locales. Where should/can I post the patch?

Thanks in advance & sorry for poor English.

Re: Some additions to newLISP Wiki

Posted: Sat Sep 24, 2011 2:12 pm
by cormullion
Hi. You could probably post the patch here - I've seen patches posted before (e.g. by Kosh) but if it's too long, I don't know - email it to Lutz, I suppose. There's no github or anything for newLISP... :)

Re: Some additions to newLISP Wiki

Posted: Sat Sep 24, 2011 4:43 pm
by rickyboy
cormullion wrote:There's no github or anything for newLISP... :)
GADFLY!!! ;-)

Re: Some additions to newLISP Wiki

Posted: Sat Sep 24, 2011 5:54 pm
by Lutz
C'mon folks , no offense ;), but how much of a barrier is it, to zip or tar up a file and email it? Or even just post the changed and added functions or the patch on the forum, and everybody can see it and comment on it tooo. The whole wiki/index.cgi thing is only ~ 60K, zipped up, in an email about 12K.

A Github account/site is just another piece of infrastructure to maintain make updates etc., and another third party gate, where you have to walk through to get to what you want. Complete overkill for the amount of contributions I have to handle.

Ps: but if anybody wants to start a Github account for it, go ahead ... and maintain it.

Re: Some additions to newLISP Wiki

Posted: Sat Sep 24, 2011 7:48 pm
by cormullion
rickyboy wrote:
cormullion wrote:There's no github or anything for newLISP... :)
GADFLY!!! ;-)
...Innocent smile ... :)

The patch

Posted: Sun Sep 25, 2011 8:35 am
by Rexy-Craxy

Code: Select all

*** index.cgi.ORIG	2011-09-24 13:14:44.000000000 +0700
--- index.cgi	2011-09-25 15:17:43.000000000 +0700
***************
*** 395,400 ****
--- 395,406 ----
          (replace {\[include:.*\]} (format-page content) " " 512))
  )
  
+ 
+ ;; create tagsearch links
+ (define (make-tagsearch tagstr, taglst)
+   (when (setq taglst (map trim (parse tagstr ",")))
+ 	(join (map (fn (s) (string {<a href="index.cgi?tagsearch=} s {">} s {</a>})) taglst) ", ")))
+ 
  ;; format a line
  (define (format-line str)
  
***************
*** 449,454 ****
--- 455,463 ----
      ;; don't show post option
      (replace {\[post:.*\]} str "" 512)
  
+     ;;; create tag links
+     (replace {\[tags:(.*)\]} str (string "Tags: " (make-tagsearch $1)) 512)
+ 
      ;; system variable with page title
      (replace "%this%" str page-name)
  
***************
*** 683,691 ****
      
  ;; return a list of all pages
  (define (get-pages , files)
!     (set 'files (slice (directory "pages/") 2))
!     (replace ".htaccess" files)
!     (replace "setup.lsp" files))
  
  ;; resturn a list of all backup files
  (define (get-backup , files)
--- 692,698 ----
      
  ;; return a list of all pages
  (define (get-pages , files)
!     (difference (directory "pages/") '("." ".." ".htaccess" "setup.lsp")))
  
  ;; resturn a list of all backup files
  (define (get-backup , files)
***************
*** 1441,1447 ****
                    {<td>&nbsp;} (first fle)   
                    {&nbsp;</td></tr>}) files))
  
!         (if (empty? file-list) 
              (set 'result-text (string "Not found in " no-files " files.<br>"))
              (set 'result-text (append
              {<br><small><font style="color:#888;">found } 
--- 1448,1454 ----
                    {<td>&nbsp;} (first fle)   
                    {&nbsp;</td></tr>}) files))
  
!         (if (empty? file-list)
              (set 'result-text (string "Not found in " no-files " files.<br>"))
              (set 'result-text (append
              {<br><small><font style="color:#888;">found } 
***************
*** 1458,1463 ****
--- 1465,1509 ----
          (exit)))
  
  
+ ;; request for tag search
+ (if (CGI:get "tagsearch")
+     (begin
+       (set 'tag (CGI:get "tagsearch"))
+       (setf show-home (fn () (display-page "Home") (exit)))
+       (if (null? tag)
+ 	  (show-home)
+ 	  (begin
+ 	    (setf match-tag? (fn (pg)
+ 			       (let ((file (open (string "pages/" pg) "r")) (tagstr ""))
+ 				 (when file
+ 				       (and (search file {\[tags:(.*)\]} true 512) (setq tagstr $1))
+ 				       (close file))
+ 				 (find tag (map trim (parse tagstr ","))))))
+ 	    (set 'file-list (filter match-tag? (get-pages)))
+ 	    (set 'no-files (length file-list))
+ 	    (set 'files '("</table>"))
+ 	    (dolist (fle (sort file-list >))
+ 		    (push (string
+ 			   "<tr><td> &nbsp\;<a href=\"index.cgi?page=" 
+ 			   fle "\">" (replace "_" fle " ") "</a>&nbsp\;</td></tr>")
+ 			  files))
+ 
+             (if (empty? file-list)
+ 		(set 'result-text "Not found.<br>")
+ 		(set 'result-text (append
+ 				   "<br><small><font style=\"color:\#888\;\">found "
+ 				   (string no-files) { files</font></small>})))
+ 	    (if (not (empty? file-list))
+ 		(push "<tr><th>&nbsp\;Page</th></tr>" files))
+ 	    
+ 	    (push {<table style="border-width: 0px;">} files)
+ 	    (set 'body (append (join files "\r\n") result-text))
+ 	    (set 'page-name (string "Pages tagged with \"" tag "\""))
+ 	    (CGI:put-page SETUP:template)
+ 	    (exit)))))
+ 
+ 
+ 
  ;; request to show the first page with pattern in content
  ;; mainly used to find posts/comments by author post-time pattern
  (if (CGI:get "find")
***************
*** 1486,1490 ****
--- 1532,1542 ----
  
  (exit)
  
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; Local Variables:     ;;
+ ;; mode:newlisp         ;;
+ ;; coding: utf-8-unix   ;;
+ ;; End:                 ;;
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  ;; eof
Some comments.

1. "get-pages" changed because on my system "directory" might return "." and ".." NOT at first positions.

2. Wiki tags markup:
[tags: comma-separated-strings]
Example:

Code: Select all

[tags: person, 1980s, miners strikes]
Note: don't use multiple "[tags: ...]" tags on a single a page, because tag search function matches/uses only the 1st occurrence in the file.

TOC + rename + tags patch

Posted: Sun Sep 25, 2011 1:13 pm
by Rexy-Craxy
A better patch to be applied to the straight 4.6 wiki. Adds TOC and rename features (http://www.tprimke.net/public/toc_rename.patch) as well as wiki tags. Now "Tags: ..." section is a separate html "<div>" with class="toc".

Re: Some additions to newLISP Wiki

Posted: Mon Sep 26, 2011 3:04 pm
by Lutz
Thank you very much for updating these great additions. I have updated this page:

http://www.newlisp.org/index.cgi?Applications

It would be great to also have these features documented on the "How To Use Advanced Features" page. When that is done, I would include your patch into a new v.4.7 as a standard download.

Applying the patch, I got a little error for the syle sheet:

Code: Select all

~/Sites/wiki> patch -p0 < ~/patch 
patching file ./index.cgi
patching file ./pages/Default_Style
Hunk #1 FAILED at 215.
1 out of 1 hunk FAILED -- saving rejects to file ./pages/Default_Style.rej
~/Sites/wiki> 
seems to be trivial, but perhaps there is a way to avoid it. Perhaps, if you post the entire index.cgi and Default_Style at http://www.tprimke.net, people don't run into the same issue. You could also use Github or Bitbucket for these files.

Re: Some additions to newLISP Wiki

Posted: Wed Sep 28, 2011 9:21 am
by Rexy-Craxy
Lutz, I'm posting index.cgi and DefaultStyle right here, hope you don't mind :)

About documenting the feature: I had no English practice for last few years, so I'm afraid the text would be really Pidgin, not English :-/ But I'll try, in few days, and then will put the wiki page here.

Re: Some additions to newLISP Wiki

Posted: Wed Sep 28, 2011 5:41 pm
by Lutz
Thanks, there is also a link to it here: http://www.newlisp.org/index.cgi?Applications