Re: How to set internal page links in a PicoLisp Wiki?
On Thu, Jan 9, 2025 at 1:26 PM Lindsay Lawrence < lawrence.lindsayj...@gmail.com> wrote: > > PS: After all of that, I realize another, and perhaps contextually better, > solution may be to modify the 'wikiLink function, ={ .. } syntax, to handle > '#' when parsing the document name? > With this change to wiki/gui.l 'wikiLink (de wikiLink (Lst) (let (CurNm (get This 'nm) NmParts (split (car Lst) "#") Nm (or (pack (car NmParts)) CurNm) Loc (pack Nm "#" (cdr NmParts)) Str (or (glue " " (cdr Lst)) (pack (car Lst))) ) (cond ((fetch '(nm . +Doc) (fold Nm 0)) ( Str (pack "?" Loc)) ) (*Login ( '*ID Loc Str)) (T (ht:Prin Str)) ) ) ) I can now write markup like ={DevForum#viprc My viprc} to jump to id in a specific wiki doc and also ={#viprc My viprc} to jump to id within the current wiki doc Yay! Very nice way to hyperlink around long wiki pages, have table of contents on a page, etc, and not have to scroll too much /Lindsay
Re: How to set internal page links in a PicoLisp Wiki?
On Thu, Jan 9, 2025 at 5:18 AM Alexander Burger wrote: > > Cool! If this works, could we also introduce it into the original > version? > > Of course. The ;{ .. } change is straightforward and is useful for more than simple linking. But: Doesn't this conflict with with other URLs having an argument? > Shouldn't it be "#" instead of "?"? > I struggled with this a bit. At the moment, I don't have a use case where it matters. For link jumps not in session, and in session but not editing (when there are additional url params), it works correctly and using the ^{..} syntax (with the suggested code change below), one can now link jump both within the same page and across wiki pages. For example: ^{?DevForum#viprc viprc} When in a session, generates http://localhost:52641/5718579557851~?DevForum#viprc";>viprc And without a session http://localhost:1780/?DevForum#viprc";>viprc > Can you try the changes? > > ... (ifn (pre? "?" (car S)) (prin "???") ( (or (glue " " (cdr S)) (pack (car S))) (if *Login (setq Url (baseHRef NIL *SesId (car S)) ) (setq Url (baseHRef *Port1 (car S)) ) ) ) ) .. Much better! Tested and works as described. First principle of picolisp: Be succinct. Second principle: There is often an existing built-in function to help with the first principle. :) /Lindsay PS: After all of that, I realize another, and perhaps contextually better, solution may be to modify the 'wikiLink function, ={ .. } syntax, to handle '#' when parsing the document name?
Re: How to set internal page links in a PicoLisp Wiki?
On Thu, Jan 09, 2025 at 03:20:30AM -0800, Lindsay Lawrence wrote: > My working version for linking into a wiki page (handling sessions) and > support for raw html looks like the code below > which lets me write wiki code like > > . > Goto my ^{?DevForum#viprc viprc} > . > > and on the DevForum page > > . > ;{My viprc} Cool! If this works, could we also introduce it into the original version? If so, I would suggest some minor improvements: > # >>> lindsay > (ifn (= "?" (car (chop (car S You can check with 'pre?' for the first char of a symbol. Thus: (ifn (pre? "?" (car S)) But: Doesn't this conflict with with other URLs having an argument? Shouldn't it be "#" instead of "?"? > (prin "???") > ( > (or (glue " " (cdr S)) (pack (car S))) > (if *Login >(setq Url (glue "" (list (baseHRef NIL *SesId) (pack (car > S)) )) ) >(setq Url (glue "" (list (baseHRef *Port1) (pack (car S)) > )) ) What is "(setq Url" for? I suspect this just a debugging artefact. Glueing nothing with "(glue "" (list" is just 'pack'. But as 'baseHRef' automatically packs all its arguments anyway, I believe you can simply write: (if *Login (baseHRef NIL *SesId (car S)) (baseHRef *Port1 (car S)) ) (I have not tested) Can you try the changes? ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: How to set internal page links in a PicoLisp Wiki?
On Thu, Jan 09, 2025 at 12:43:50AM -0800, Lindsay Lawrence wrote: > In http.l 'server why is '*Port1 initialized this way? > > *Port1 (or (sys "NAME") Port) This is for the interaction with httpGate @doc/httpGate.html For a serious application, httpGate is stongly recommended. > As it happens, my Linux distribution defaults "NAME" to the machine name. > As the wiki code uses *Port1 it caused a bit of initial confusion at > startup. With httpGate it is not a problem, as it will be set correctly. ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: How to set internal page links in a PicoLisp Wiki?
> This is easy. Set in your initial code > >(setq *HPorts (8040 . 8079)) > > for such a range. > > Thanks!... I was almost there :) One other minor point, with resulting question, I worked through; In http.l 'server why is '*Port1 initialized this way? *Port1 (or (sys "NAME") Port) As it happens, my Linux distribution defaults "NAME" to the machine name. As the wiki code uses *Port1 it caused a bit of initial confusion at startup. (if *Login (baseHRef NIL *SesId "?home") (baseHRef *Port1 "?home") ) ) It was straightforward to resolve, but why is it written that way in http.l? /Lindsay PS: I am quite enjoying my current adventure into the picolisp applications and libraries; vip, wiki, native interfacing, networking, etc. And realizing I still have a lot to learn! A scalpel indeed.
Re: How to set internal page links in a PicoLisp Wiki?
On Thu, Jan 9, 2025 at 1:25 AM Alexander Burger wrote: > > This is for the interaction with httpGate > >@doc/httpGate.html > > Thank you. My working version for linking into a wiki page (handling sessions) and support for raw html looks like the code below which lets me write wiki code like . Goto my ^{?DevForum#viprc viprc} . and on the DevForum page . ;{My viprc} . Regards, /Lindsay In wiki/lib.l (de render (Bin) ... ("\^" # External web link (let (S (split (till "}") " " "^I" "^J" "^M") Url) (char) (if (or (member (car (split (car S) ":")) (quote `(chop "http") `(chop "https") `(chop "irc") `(chop "mailto") ) ) ) ( (or (glue " " (cdr S)) (pack (car S))) (setq Url (pack (car S))) ) # >>> lindsay (ifn (= "?" (car (chop (car S (prin "???") ( (or (glue " " (cdr S)) (pack (car S))) (if *Login (setq Url (glue "" (list (baseHRef NIL *SesId) (pack (car S)) )) ) (setq Url (glue "" (list (baseHRef *Port1) (pack (car S)) )) ) ) ) ) # <<< lindsay ) ) ) # >>> lindsay (";" (renderBlock prin)) # <<< lindsay ...