Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Rexy-Craxy

#1
Hi all.



This patch makes newlispdoc working right when TABs are used in comment lines containing  @keywords.



Also it replaces a partial derivative sign ("∂", "&part;" in HTML) at the bottom of produced pages with a solid pointing-up triangle ("▲", "&#9650;" in HTML) surrounded by '<a href="">' and '</a>', so following the link just reloads the same page from its top. (I made it because a single "∂" looks like small Russian "d" typed in italics, what always perflexed me :) ).



The version of newlispdoc to patch is one distributed with current stable (10.5.0) release of newLISP.



116c116
< <br/><br/><center>- &part; -</center><br/>
---
> <br/><br/><center>- <a href="" title="Go to page top">&#9650;</a> -</center><br/>
454c454
<     (when (find ";; *@index ([^ ]*?) ([^ ]*?)\s*n" page 0)
---
>     (when (find ";;[ t]*@index[ t]+([^ t]*?)[ t]+([^ t]*?)\s*n" page 0)
457c457
<         (when (find ";; *@description (.*?)n" page 0)
---
>         (when (find ";;[ t]*@description[ t]+(.*?)n" page 0)
462c462
<     (if (find ";; *@module " page 0)
---
>     (if (find ";;[ t]*@module[ t]" page 0)
464,465c464,465
<             (replace {;;(.*) @link ([^ ]*?) ([^ ]*?)s} page (string $1 { <a href="} $2 {">} $3 {</a> }) 0)
<             (replace ";; @example *n(.*?)n\s*n" page (format-example $1) 4)
---
>             (replace {;;(.*)[ t]@link[ t]+([^ t]*?)[ t]+([^ t]*?)s} page (string $1 { <a href="} $2 {">} $3 {</a> }) 0)
>             (replace ";; @example[ t]*n(.*?)n\s*n" page (format-example $1) 4)
468,469c468,469
<             (replace ";; *@description (.*?)n" page (begin (set 'desc $1) (string "<p>" desc "</p>n") ) 0)
<             (replace ";; *@module (.*?)n" page (format-module $1 desc outfile)  0)
---
>             (replace ";;[ t]*@description[ t](.*?)n" page (begin (set 'desc $1) (string "<p>" desc "</p>n") ) 0)
>             (replace ";;[ t]*@module[ t](.*?)n" page (format-module $1 desc outfile)  0)
471,473c471,473
<             (replace ";; *@author (.*?)n" page (string "<b>Author: </b>" $1 "<br/>n")  0)
<             (replace ";; *@version (.*?)n" page (string "<b>Version: </b>" $1 "<br/>n")  0)
<             (replace ";; *@location (.*?)n" page
---
>             (replace ";;[ t]*@author[ t](.*?)n" page (string "<b>Author: </b>" $1 "<br/>n")  0)
>             (replace ";;[ t]*@version[ t](.*?)n" page (string "<b>Version: </b>" $1 "<br/>n")  0)
>             (replace ";;[ t]*@location[ t](.*?)n" page
475,477c475,477
<             (replace ";; *@syntax (.*?)n" page (format-syntax $1 outfile) 0)
<             (replace ";; *@param (.*?) (.*?)n" page (format-parameter $1 $2) 0)
<             (replace ";; *@return (.*?)n" page (format-return $1)  0)
---
>             (replace ";;[ t]*@syntax[ t](.*?)n" page (format-syntax $1 outfile) 0)
>             (replace ";;[ t]*@param[ t](.*?)[ t](.*?)n" page (format-parameter $1 $2) 0)
>             (replace ";;[ t]*@return[ t](.*?)n" page (format-return $1)  0)
479c479
<             (replace ";; *@([a-zA-Z_-]*?) (.*?)n" page (string "<b>" (title-case $1) ": </b>" $2 "<br/>n") 0)
---
>             (replace ";;[ t]*@([a-zA-Z_-]*?)[ t](.*?)n" page (string "<b>" (title-case $1) ": </b>" $2 "<br/>n") 0)
#2
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.
#3
Anything else we might add? / TOC + rename + tags patch
September 25, 2011, 06:13:23 AM
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">//http://www.tprimke.net/public/toc_rename.patch) as well as wiki tags. Now "Tags: ..." section is a separate html "<div>" with class="toc".
#4
Anything else we might add? / The patch
September 25, 2011, 01:35:07 AM
*** 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 "rn") 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:
Quote[tags: comma-separated-strings]

Example: [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.
#5
Hi all.



I've added "classical" tags support functions to the http://newlisp.nfshost.com//wiki/">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.