Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ W2 wiki is a web-based, wiki-like notepad that you can host yourself.
- Page history from git (with the git integration): the versions of a page (also from before it was renamed), an old version, what changed in it or how it differs from the current text, and restoring it in the editor
- Support for renaming and deleting pages
- Markdown formatting syntax help on edit page
- Formatting toolbar above the text in the editor: bold, italic, headings (level 1 to 4), links (also to pages of the wiki), bulleted and numbered lists, quotes, code (inline, or a fenced block with the cursor where the language goes), horizontal rules, tables of a chosen size (or made of selected lines separated by tabs or commas, as copied from a spreadsheet), upload and the formatting help. Each change is one step for Ctrl+Z; the toolbar is one stop of Tab, with the arrow keys between its buttons (Alt+F10 goes there from the text). Only shown with JavaScript
- Insert the text of Markdown or text files into the editor (button below the text, or drag & drop on the text); a new page gets the file's name
- Formatting toolbar above the text in the editor: bold, italic, headings (level 1 to 4), links (also to pages of the wiki), bulleted and numbered lists, quotes, code (inline, or a fenced block with the cursor where the language goes), horizontal rules, tables of a chosen size (or made of selected lines separated by tabs or commas, as copied from a spreadsheet), upload, the text of a Markdown or text file, and the formatting help. Each change is one step for Ctrl+Z; the toolbar is one stop of Tab, with the arrow keys between its buttons (Alt+F10 goes there from the text). Only shown with JavaScript
- Insert the text of Markdown or text files into the editor (button of the formatting toolbar, or drag & drop on the text); a new page gets the file's name
- Live preview in the editor (button below the text): rendered by the server like the page itself (links, embeds, uploads), next to the text on wide screens and instead of it on narrow ones; the choice is remembered in the browser
- Keyboard shortcuts (`?` shows the list): `/` search, `e` edit, `n` new page, `g` `h` home page, `g` `a` all pages, `h` history (with git); in the editor Ctrl+S or Ctrl+Enter save, Ctrl+B bold, Ctrl+I italic, Ctrl+K link, Ctrl+Alt+P preview, Alt+F10 formatting toolbar, Tab indents (Cmd and Option on a Mac). They only use the links of the page, and are left alone while typing; the pages work without them (and without JavaScript)
- Localization support (en/de/ja/oc translations included)
- Improved icon-based interface
- Phones: the lists leave out the columns which say little there (the author and version in the history of a page, the size of pages and files, how to refer to a file), the list of all pages shows the name above the date and the icons, the title bar is one line (the title above the date, the page's icons next to them), the title bar and the toolbar are hidden while the text of the editor is typed, and on touch screens the icons are larger, with room to tap them; form fields have text of at least 16px, as iOS zooms into smaller text
- Optional sidebar fed by a special page (shown when viewing pages, in the page list and in search results, but not when editing)
- Merged All/Recent list of all pages
- Links:
Expand Down
10 changes: 6 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,16 +939,18 @@ function humanFilesize($bytes, $decimals = 2) {
*
* @param string $action the action which shows the table (the headings are links to it)
* @param string $sortBy the column which the table is sorted by
* @param array<int, array{0: string, 1: string|null}> $columns the label of each column, and what to sort by to
* sort by it (or null for a column which can't be sorted by)
* @param array<int, array{0: string, 1: string|null, 2?: string}> $columns the label of each column, what to sort by
* to sort by it (or null for a column which can't be sorted by), and the class of its cell
* (optional, e.g. "wideonly" for a column which narrow screens don't show)
* return W2\Html
*/
function sortableHeadings($action, $sortBy, $columns)
{
$headings = array();
foreach ($columns as list($label, $key))
foreach ($columns as $column)
{
$headings[] = array('label' => $label, 'current' => ($key !== null && $key === $sortBy),
list($label, $key) = $column;
$headings[] = array('label' => $label, 'current' => ($key !== null && $key === $sortBy), 'class' => $column[2] ?? '',
'href' => ($key === null || $key === $sortBy) ? null : SELF . "?action=" . $action . "&sortBy=" . $key);
}
return templates()->render('table-head', array('columns' => $headings));
Expand Down
184 changes: 177 additions & 7 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ table {
}
td, th {
padding: .1em 1em .1em .1em;
word-break: break-all;
/* (long words are broken only where they don't fit, so that a table can be narrower than the window) */
overflow-wrap: anywhere;
}
thead {
border-bottom: 1px solid var(--table-rule);
Expand Down Expand Up @@ -547,6 +548,8 @@ input.search:focus {

input.pagename {
width: 20em;
max-width: 100%;
box-sizing: border-box;
}

input[type="button"],
Expand Down Expand Up @@ -906,7 +909,7 @@ body.editor form#edit > .editorbox {

/*
* The formatting toolbar directly above the text of the editor (format-bar.php, setupFormatBar() in wiki.js): flat
* buttons with icons (or short labels in the font of the text), in groups with lines between them, which wrap on narrow
* buttons with icons, in groups with lines between them, which wrap on narrow
* screens; the button of the Markdown help is at the end, apart from them. The menu of the headings drops down from its
* button, with the level of the cursor's line checked. The dialog for the size of a table looks like the one to upload
* files. Where the preview takes the place of the text (narrow screens), the toolbar goes with the text.
Expand Down Expand Up @@ -952,11 +955,6 @@ body.editor form#edit > .formatbar + .editorbox {
height: 1.25em;
color: var(--page-fg);
}
.formatbar .textlabel {
font-family: Courier, monospace;
font-weight: bold;
white-space: nowrap;
}
.formatsep {
align-self: stretch;
width: 1px;
Expand Down Expand Up @@ -1116,3 +1114,175 @@ body.editor form#edit > .formatbar + .editorbox {
animation: none;
}
}

/*
* Small screens and touch screens. Narrow screens (phones) don't show the columns of the lists which say little
* there (.wideonly: the author and version in the history of a page, which the page of a version has, the size of
* pages and files, how to refer to a file). The title bar is one line, to leave the space to the page: the title (cut
* off with "…" if it is too long) above the date, and the icons of the page next to them; in the toolbar, the search box
* takes the space which the icons leave. On touch screens, the icons are larger and have room around them for a finger;
* the text of form fields has at least 16px, as iOS zooms into smaller text when the field gets the focus. While the
* text of the editor has the focus on a phone (with the on-screen keyboard), the title bar and the toolbar are hidden.
*/
@media (max-width: 600px) {
.wideonly {
display: none;
}
.main {
padding-right: .75em;
}
img {
max-width: 100%;
}
.login {
margin: 1em;
}
.titlebar {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
grid-template-areas: "title actions" "date actions";
align-items: center;
column-gap: .5em;
padding-top: 2px;
padding-bottom: 2px;
}
.titlebar span.title {
grid-area: title;
align-self: end;
font-size: 1.15em;
line-height: 1.2;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* (without a date, the title is in the middle of the bar) */
.titlebar:not(:has(.titledate)) span.title {
grid-row: 1 / span 2;
align-self: center;
}
.titledate {
grid-area: date;
align-self: start;
margin: 0;
font-size: .8em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.titlebar .pageactions {
grid-area: actions;
white-space: nowrap;
}
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.toolbar .searchform {
display: block;
flex: 1 1 5em;
min-width: 5em;
margin-right: .5em;
}
input.search, input.search:focus {
width: 100%;
box-sizing: border-box;
}
.toolbar .themeswitch {
float: none;
}
.pageActions {
padding-left: 0;
padding-right: 0;
white-space: nowrap;
}
/* (headings are broken between words, unless a word is wider than the column) */
th {
overflow-wrap: break-word;
}
/* (the list of all pages: each row in two lines, the name above the date and the icons, which don't fit next to it) */
table.pagelist, table.pagelist thead, table.pagelist tbody {
display: block;
max-width: none;
}
table.pagelist tr {
display: grid;
grid-template-columns: 1fr auto;
grid-template-areas: "name name" "modified actions";
align-items: center;
column-gap: .5em;
padding: .2em 0 0 .2em;
}
table.pagelist thead tr {
grid-template-areas: "name modified";
}
table.pagelist thead th:last-child {
display: none;
}
table.pagelist td, table.pagelist th {
padding: 0;
}
table.pagelist .pagename {
grid-area: name;
}
table.pagelist .modified {
grid-area: modified;
font-size: .9em;
}
table.pagelist .pageActions {
grid-area: actions;
white-space: nowrap;
}
table.history td:first-child, td.modified {
overflow-wrap: normal;
}
/* (the date of the lists can wrap before the time) */
td.modified nobr {
white-space: normal;
}
}
@media (pointer: coarse) {
.titlebar .pageactions a, .toolbar > a, .pageActions a {
display: inline-block;
padding: 6px;
margin: 0;
line-height: 0;
}
.toolbar > a:not(:has(svg)) {
line-height: normal;
}
.toolbar {
padding: 0 4px 0 calc(1em - 6px);
}
.titlebar svg.icon, .toolbar svg.icon, .pageActions svg.icon {
width: 1.5rem;
height: 1.5rem;
}
.themeswitch button {
padding: 6px;
}
.themeswitch svg.icon {
width: 1.5rem;
height: 1.5rem;
}
input[type="text"], input[type="password"], input[type="number"], input.search, textarea, select {
font-size: 16px;
}
input[type="button"], input[type="submit"] {
padding: .7em 1.2em;
margin-bottom: .3em;
}
.sidebar li, .linkshere li {
line-height: 2em;
}
}
@media (pointer: coarse) and (max-width: 600px), (pointer: coarse) and (max-height: 500px) {
body.editor:has(#text:focus) > .titlebar, body.editor:has(#text:focus) > .toolbar {
display: none;
}
}
@media (hover: none) {
a > svg.icon:hover {
outline: none;
}
}
1 change: 0 additions & 1 deletion locales/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
'Pages which mention the name without a link:' => 'Seiten, die den Namen ohne Link erwähnen:',
'Save (Ctrl+S)' => 'Speichern (Strg+S)',
'Tab indents lines, Shift+Tab outdents them. To leave the text with Tab, press Esc first.' => 'Tab rückt Zeilen ein, Umschalt+Tab rückt sie aus. Um den Text mit Tab zu verlassen, zuerst Esc drücken.',
'Insert text from file…' => 'Text aus Datei einfügen…',
'Insert the text of a Markdown or text file at the cursor (also by dropping the file on the text)' => 'Den Text einer Markdown- oder Textdatei an der Cursorposition einfügen (auch durch Ziehen der Datei auf den Text)',
'The file %s is larger than 2 MB and was not inserted.' => 'Die Datei %s ist größer als 2 MB und wurde nicht eingefügt.',
'The file %s is not a text file (.md, .markdown or .txt) and was not inserted.' => 'Die Datei %s ist keine Textdatei (.md, .markdown oder .txt) und wurde nicht eingefügt.',
Expand Down
6 changes: 3 additions & 3 deletions src/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function allPages(string $sortBy): Html
return templates()->render('all-pages', array(
'total' => count($pageNames), 'rows' => $rows,
'head' => sortableHeadings('all', $sortBy, array(
array(translate('Name'), 'name'), array(translate('Modified'), 'recent'), array(translate('Size'), 'size'), array(translate('Action'), null)))
array(translate('Name'), 'name'), array(translate('Modified'), 'recent'), array(translate('Size'), 'size', 'wideonly'), array(translate('Action'), null)))
));
}

Expand Down Expand Up @@ -81,8 +81,8 @@ public function uploads(string $sortBy, string $prevPage): Html
}
}

$columns = array(array(translate('Name'), 'name'), array(translate('Usage'), null),
array(translate('Modified'), 'recent'), array(translate('Size'), 'size'), array(translate('Action'), null));
$columns = array(array(translate('Name'), 'name'), array(translate('Usage'), null, 'wideonly'),
array(translate('Modified'), 'recent'), array(translate('Size'), 'size', 'wideonly'), array(translate('Action'), null));
if (SHOW_PAGES_WHERE_FILE_USED)
{
$columns[] = array(translate('Used on page'), null);
Expand Down
7 changes: 4 additions & 3 deletions src/templates/all-pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
*
* The list of all pages (inside the main part of page).
*
* Values: total (number), head (Html: the heading cells, see table-head),
* Values: total (number), head (Html: the heading cells, see table-head; narrow screens don't show the size, see
* "wideonly" in index.css, and show each row in two lines: the name, then the date and the icons),
* rows (list of: href, name, modified (text), size (text), actions (Html: see page-actions))
*/
?>
<p><?= __('Total') ?>: <?= $this->total ?> <?= __("pages") ?></p><table><thead><tr><?= $this->head ?></tr></thead><tbody>
<p><?= __('Total') ?>: <?= $this->total ?> <?= __("pages") ?></p><table class="pagelist"><thead><tr><?= $this->head ?></tr></thead><tbody>
<?php foreach ($this->rows as $row): ?>
<tr><td><a href="<?= $row['href'] ?>"><?= $row['name'] ?></a></td><td valign="top"><nobr><?= $row['modified'] ?></nobr></td><td valign="top"><nobr><?= $row['size'] ?></nobr></td><td class="pageActions"><?= $row['actions'] ?></td></tr>
<tr><td class="pagename"><a href="<?= $row['href'] ?>"><?= $row['name'] ?></a></td><td valign="top" class="modified"><nobr><?= $row['modified'] ?></nobr></td><td valign="top" class="wideonly"><nobr><?= $row['size'] ?></nobr></td><td class="pageActions"><?= $row['actions'] ?></td></tr>
<?php endforeach ?>
</tbody></table>
2 changes: 0 additions & 2 deletions src/templates/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
<input type="hidden" name="isNew" value="<?= $this->isNew ? 'true' : '' ?>" />
<input id="save" type="submit" value="<?= __('Save') ?>" title="<?= __('Save (Ctrl+S)') ?>" aria-keyshortcuts="Control+S Meta+S Control+Enter Meta+Enter" />
<input id="cancel" type="button" onclick="<?= HANDLER_GO_BACK ?>" value="<?= __('Cancel') ?>" />
<input id="importbutton" type="button" value="<?= __('Insert text from file…') ?>" title="<?= __('Insert the text of a Markdown or text file at the cursor (also by dropping the file on the text)') ?>" />
<input id="importfile" type="file" multiple="multiple" accept=".md,.markdown,.txt,text/markdown,text/plain" hidden="hidden" />
<input id="previewbutton" type="button" value="<?= __('Preview') ?>" title="<?= __('Show the text as it will look in the page (next to the text on wide screens, instead of it on narrow ones)') ?>" aria-pressed="false" aria-controls="preview" aria-keyshortcuts="Control+Alt+P Meta+Alt+P" hidden="hidden" />
</p></form>
<?= $this->render('table-dialog') ?>
Expand Down
10 changes: 7 additions & 3 deletions src/templates/format-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*
* The formatting toolbar directly above the text of the editor (inside the form of editor): buttons which format the
* selected text or the lines of the cursor (bold, italic, headings, links, lists, quotes, code), insert a rule or a
* table (with the dialog of table-dialog), upload files, and show the Markdown help (the drawer). The buttons only work
* table (with the dialog of table-dialog), upload files, insert the text of Markdown or text files (the hidden field
* of the files to choose, see setupImport() in wiki.js), and show the Markdown help (the drawer). The buttons only work
* with the script (setupFormatBar() in wiki.js), so the toolbar is hidden until the script shows it.
* The buttons name their keyboard shortcut in their label (their tooltip); the arrow keys move between them, and Alt+F10
* in the text goes to them.
Expand All @@ -22,8 +23,9 @@
<?php endforeach ?>
</span></span>
<span class="formatsep" role="separator"></span>
<button type="button" data-format="link" title="<?= __('Link (Ctrl+K)') ?>" aria-keyshortcuts="Control+K Meta+K"><?= iconSvg('link', translate('Link (Ctrl+K)')) ?></button>
<button type="button" data-format="wikilink" class="textlabel" title="<?= __('Link to a page of the wiki: [[selected text]]') ?>" aria-label="<?= __('Link to a page of the wiki: [[selected text]]') ?>">[[ ]]</button>
<?php /* (a link to an address has the globe which marks such links in the pages; one to a page of the wiki, the chain) */ ?>
<button type="button" data-format="link" title="<?= __('Link (Ctrl+K)') ?>" aria-keyshortcuts="Control+K Meta+K"><?= iconSvg('internet', translate('Link (Ctrl+K)')) ?></button>
<button type="button" data-format="wikilink" title="<?= __('Link to a page of the wiki: [[selected text]]') ?>"><?= iconSvg('link', translate('Link to a page of the wiki: [[selected text]]')) ?></button>
<span class="formatsep" role="separator"></span>
<button type="button" data-format="bullets" title="<?= __('Bulleted list') ?>"><?= iconSvg('format-list-unordered', translate('Bulleted list')) ?></button>
<button type="button" data-format="numbers" title="<?= __('Numbered list') ?>"><?= iconSvg('format-list-ordered', translate('Numbered list')) ?></button>
Expand All @@ -35,5 +37,7 @@
<?php if ($this->uploads): ?>
<button type="button" id="uploadbutton" title="<?= __('Upload a file and insert a link to it at the cursor (also by dropping files on the editor, or pasting an image)') ?>" aria-haspopup="dialog"><?= iconSvg('upload', translate('Upload a file and insert a link to it at the cursor (also by dropping files on the editor, or pasting an image)')) ?></button>
<?php endif ?>
<button type="button" id="importbutton" title="<?= __('Insert the text of a Markdown or text file at the cursor (also by dropping the file on the text)') ?>"><?= iconSvg('insert-file', translate('Insert the text of a Markdown or text file at the cursor (also by dropping the file on the text)')) ?></button>
<input id="importfile" type="file" multiple="multiple" accept=".md,.markdown,.txt,text/markdown,text/plain" hidden="hidden" />
<button type="button" id="drawer-control" class="helpbutton" title="<?= __('Formatting help') ?>" aria-controls="drawer" aria-expanded="false"><?= iconSvg('help', translate('Formatting help')) ?></button>
</div>
Loading
Loading