Some additions to newLISP Wiki

For the Compleat Fan
Locked
Rexy-Craxy
Posts: 5
Joined: Sat Sep 24, 2011 9:20 am

Some additions to newLISP Wiki

Post 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.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Some additions to newLISP Wiki

Post 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... :)

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: Some additions to newLISP Wiki

Post by rickyboy »

cormullion wrote:There's no github or anything for newLISP... :)
GADFLY!!! ;-)
(λx. x x) (λx. x x)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Some additions to newLISP Wiki

Post 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.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Some additions to newLISP Wiki

Post by cormullion »

rickyboy wrote:
cormullion wrote:There's no github or anything for newLISP... :)
GADFLY!!! ;-)
...Innocent smile ... :)

Rexy-Craxy
Posts: 5
Joined: Sat Sep 24, 2011 9:20 am

The patch

Post 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.

Rexy-Craxy
Posts: 5
Joined: Sat Sep 24, 2011 9:20 am

TOC + rename + tags patch

Post 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".
Attachments
toc-rename-tags-patch.zip
toc + rename + tags patch for newLISP Wiki 4.6
(3.68 KiB) Downloaded 269 times

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Some additions to newLISP Wiki

Post 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.

Rexy-Craxy
Posts: 5
Joined: Sat Sep 24, 2011 9:20 am

Re: Some additions to newLISP Wiki

Post 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.
Attachments
script_n_style.zip
index.cgi & DefaultStyle files with TOC, Rename and Tagging features included.
(15.19 KiB) Downloaded 275 times

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Some additions to newLISP Wiki

Post by Lutz »

Thanks, there is also a link to it here: http://www.newlisp.org/index.cgi?Applications

Locked