Dup Ver Goto 📝

the-plan-temp

PT2/pt2 todo stuff does not exist
To
233 lines, 1517 words, 9264 chars Page 'the-plan-temp' does not exist.

DIR

FurtherIdeas KeyboardShortcuts Mobile keyboard/shortcuts

TODO

Plan

  1. AJAX app. Using GET and POST.
  2. Once MathJax or Abc is required, it is loaded. So we need a way to tell the client that these are needed, and what to use if so. So have an example of a box with \(\LaTeX\) that is unrendered upon loading, but when button is clicked, loads the MathJax script and typesets.

FILES OVERLAY

We want /js, /css and /bugs shared between instances. At least the initial skeleton. So we have a skeleton pt2 that appears on all pt2s. Files that fail to lookup in a pt2 then search the next fs in the list. writes go to the top of the list.

AJAX Getter

Write a separate HTML+JS file that uses AJAX to get a named page. It has an input and on enter loads the html and displays. So we want "action=body" for the body.

Push updates

Future idea. When in edit mode, use e.g. COMET.

For now, in side-by-side, have a refresh button.

Scripts and CSS files

Have two arrays. They contain entries of the form

$scripts = [
  [ "text", "var a=1" ],
  [ "src", "highlight.js", "defer" ]
];
$styles = [
  [ "text", "p { color: red; }" ],
  [ "link", "mystyle.css", "attrib=value", "attrib=value" ]; 
];

from which the scripts are generated. Again, this moves them out of the view template.

config file

go back to .config rather than .config.ptmd. But then we need to change the config handler. In this case, it can change the ext to ''' from '.ptmd' and then treat as usual.

Mysql Versions

Also use MySql to store versions of pages (pages only). SQL makes some things easy, a filesystem makes others easy. We are not worried about syncing issues since versions are meant to be immutable.

CREATE TABLE ptversions_sitename ( id INTEGER AUTO_INCREMENT PRIMARY KEY, vtime TIMESTAMP, path VARCHAR(4000), subdir VARCHAR(4000), pagename VARCHAR(1024), source
 LONGTEXT, INDEX (vtime, path(500)), INDEX( pagename(100)), FULLTEXT( source ) );  

Side by side editing

It would be nice to have the left half with text and rhs with resulting rendered markdown. This means getting a page via json, in which case we want to return a rendered page. So PageName?json=true will return the rendered markdown. This needs a little thinking out. Basically if ajax=true, do the rending in Page.php as before, but instead of loading view.php load view_json.php. This will send

{ "result": "success", "html": "<h1>...stuff that goes in contentss", mtime: 1.23 }

we want to return everything in the div.container, so importantly things like $tagsHtml and so on need to be rendered prior to insertion.

so we want to render the header, with a {HEADER} placeholder and {CONTENT} placeholder. We use

$d = [ "HEADER" => "header", "CONTENT" => "content" ];
$body = preg_replace_callback("/\{PT:(\w+)\}/",function ($m) use($d) { return array_get($d,$m[1],""); },$template);

This also means moving the template back into an HTML file with placeholders.

Footer

Link to github and purple tree youtube when done.

Push reload

Simply have a watch mode that polls the server every 5 seconds.

Drafts in local storage

We first want to learn about local storage. We delete it on a successful save.

localstorage.drafts[pageName] = source

update it every few seconds. Then we need a means to see drafts. Obviously this is entirely done client side. Loading a draft changes the url bar, loads the source, sets dirty.

Favicons, Bugs and config

Favicons done -- icons are now loaded correctly, with inheritance. We need to adapt the code for finding bugs too. But in principle it works the same way as for favicons. We want a convenience function to get if possible, and if not return null. So we do

if( $x = get_candidate("one.png") ) { /* echo html */ }

is .config being read? we want to be able to say favion=filename.png in the config, as we do for bugs.

textarea change detection

When we change the textarea, flag it as dirty. When we save, unflag. Do this by adding a class to the textarea, and then using css. When saving, remove it on success. done

Protection bugs

Debugged: you must unprotect in REVERSE order (use `array_reverse). Sometimes we get garbage if the regex's don't work. For now, put a var_dump of protections on the end of the document. We need to have backslash escaping of backquote. Writing

shift-`

borks the formatting. So protect

\`

early. After fenced blocks are protected. Before everything else. We can have a third 'global' protect object. This will do_protect() before wikiword transform, and do_unprotect() after parsedown transform. We can subclass Protect for these cases, rather than having the code in the render() function.

render() {
$protect_global = new ProtectGlobal();
$protect_wikiwords = new ProtectWikiWords();
$protect_parsedown = new ProtectParsedown();
$parsedown = new ParsedownPT();

# use indenting to show protect structure
$x = $protect_global->do_protect($x);
  $x = $protect_wikiwords->do_protect($x);
    $x = transform_wikiwords($x);
  $x = $protect_wikiwords->do_unprotect($x);

  $x = $protect_parsedown->do_protect($x);
    $x = $parsedown->text($x);
  $x = $protect_parsedown->do_unprotect($x);
$x = $protect_globcal->do_unprotect($x);
}

New Style.

Grid with 20% 65% 15%; controls and stuff down the sides. Mobile, have them below the title bar. Flat rectangles style. Bug at the top of the rh column. Then things like touch enable and stuff. Have shift-click on a code block toggle word wrap.

Root page

Copy from current w.allsup.co. Search code python script, and modify to find .ptmd files. done

Files list

ajax mode == if option ajax=true is set, return json rather than a page (this can be used in the editor). some done

Search tag and word

TODO: Also negation e.g. /word/mr/flibble/^salad Rules: must be last except before /i -- disallow pages with names shorter than 3 chars, so we can use 1 and 2 char paths for special meanings without clashing.

Javascript toggle to group by subdir. Use javascript to compile alternative grouping, append with display:none and then switch using display:.

done

Below works -- we are not doing occurrences as this doesn't work when we allow conjuctions and disjunctions (and I'd prefer conjs and disjs). We need to build the results page. Take results page from pt1 and use that for now.

Adapt python code from w.allsup.co done

/w/random/$say.*hello.*mr.*flibble/i
/w/random+borff/$my.regex
/w/random/word/mr+flibble|bobbins+says

where

a+b      = a and b # note that a+b in the query string is decoded to " ", so + and " " are equiv
a/b      = a or b
a|b      = a or b
but
a+b|c+d  = a and (b or c) and d
and
a/b+c|d+e = a or (b and (c or d) and e)

Use PhpSets to do the intersecting and unioning.

xs = query.split("/")
xm = []
for x in xs:
  ys = x.split("+")
  ym = []
  for y in ys:
    zs = y.split("|")
    zm = []
    for z in zs:
      zm.append(byX[z].name)
      counts[name]= byX[z].count
    ym.append(union(zm))
  xm.append(intersection(ym))
matches = {path:counts[path] for path in union(xm)} # path => count dict

Edit mode

We don't want the navbar in edit mode -- rather help text as we have. We do want breadcrumbs in edit mode.

Tags

Tags in navbar works. Drop big box formatting unless touch_friendly is set on body. Need to sort out css for formatting them. Tags don't appear in edit mode.

touch friendly

Copy code from pt1.

right side.

have bug followed by boxes. Have a vertical stack of boxes for things like touch-friendly. edit page can put stuff like save and abort there.

Mobile version

Same stylistic changes as pt1. Make very minimal.

Versions

Border to indicate contents have changed. Store original textarea value in variable. Allow diff between current and original. (Ctrl+Shift+D).

DONE

new key handler

Code from pt1 works as is. done

Drag and Drop Images

Make inserting links work. I thought it already was. works now -- code that sanitises filenames was broken.

Cookie Auth — done

Use .login to log in and .logout to log out. Also use /MrFlibble or /Treaty... to login and /HexVision or /logout to log out. hello

Breadcrumbs — done

Put these on a line below the header and above the navbar.