1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-09 03:19:56 +00:00
Commit Graph

50 Commits

Author SHA1 Message Date
Arlen22
603c564872 Add the "tiddlywiki" argument to the server start hook (#3592)
* Update Hook__th-server-command-post-start.tid

* Update server.js

* Update listen.js
2018-11-29 09:51:11 +00:00
snlhnk
c05c0d3df6 Module-ize server routes, add static file support and other enhancements(#2679)
* Module-ize server routes and add static file support (#2510)

* Refactor server routes to modules

New module type: serverroute

Caveats: Loading order is not deterministic but this would only matter
if two route modules attempted to use the same path regexp (that would
be silly).

* Add static assets plugin

This plugin allows the node server to fetch static assets in the /assets
directory. I felt that this was a feature that goes above the core
functionality. That is why I added it as a plugin. with the modular
route extensions this was a breeze.

* Add serverroute description to ModuleTypes

* Coding standards tweaks

* Fix filename typo

* Move support for attachments from a plugin into the core

* Missing "else"

* Refactor server handling

* Introduce a new named parameter scheme for commands
* Move the SimpleServer class into it's own module
* Deprecate the --server command because of the unwieldy syntax
* Add a new --listen command using the new syntax

For example:

tiddlywiki mywiki --listen host:0.0.0.0 port:8090

* Add check for unknown parameters

* Add support for multiple basic authentication credentials in a CSV file

Beware: Passwords are stored in plain text. If that's a problem, use an authenticating proxy and the trusted header authentication approach.

* Refactor module locations

* Rename "serverroute" module type to "route"

* Remove support for verifying optional named command parameters

The idea was to be able to flag unknown parameter names, but requiring a command to pre-specify all the parameter names makes it harder for (say) the listen command to be extensible so that plugins can add new optional parameters that they handle. (This is particularly in the context of work in progress to encapsulate authenticators into their own modules).

* Refactor the two authenticators into separate modules and add support for authorization

* Correct mistaken path.join vs. path.resolve

See https://stackoverflow.com/a/39836259

* Docs for the named command parameters

I'd be grateful if anyone with sufficient Windows experience could confirm that the note about double quotes in "NamedCommandParameters" is correct.

* Be consistent about lower case parameter names

* Do the right thing when we have a username but no password

With a username parameter but no password parameter we'll attribute edits to that username, but not require authentication.

* Remove obsolete code

* Add support for requiring authentication without restricting the username

* Refactor authorization checks

* Return read_only status in /status response

* Fix two code typos

* Add basic support for detecting readonly status and avoiding write errors

We now have syncadaptors returning  readonly status and avoid attempting to write to the server if it's going to fail

* Add readonly-styles

We hide editing-related buttons in read only mode

I've made this part of the tiddlyweb plugin but I think a case could be made for putting it into the core.

* Add custom request header as CSRF mitigation

By default we require the header X-Requested-With to be set to TiddlyWiki. Can be overriden by setting csrfdisable to "yes"

See https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Protecting_REST_Services:_Use_of_Custom_Request_Headers

* Add support for HTTPS

* First pass at a route for serving rendered tiddlers

cc @Drakor

* Tweaks to the single tiddler static view

Adding a simple sidebar

* Switch to "dash" separated parameter names

* Typo

* Docs: Update ServerCommand and ListenCommand

* First pass at docs for the new web server stuff

Writing the docs is turning out to be quite an undertaking, much harder than writing the code!

* Get rid of extraneous paragraphs in static renderings

* Rejig anonymous user handling

Now we can support wikis that are read-only for anonymous access, but allow a user to login for read/write access.

* More docs

Slowly getting there...

* Static tiddler rendering: Fix HTML content in page title

* Docs updates

* Fix server command parameter names

Missed off 30ce7ea

* Docs: Missing quotes

* Avoid inadvertent dependency on Node.js > v9.6.0

The listenOptions parameter of the plain HTTP version of CreateServer was only introduced in v9.6.0

cc @Drakor @pmario

* Typo
2018-07-18 16:54:43 +01:00
Jermolene
1ce9973bed Add optional debug logging to the server command 2018-06-20 12:43:41 +01:00
Jermolene
c29f5a1b61 Server command: map missing path to "/"
Otherwise, the user gets a 404 if we use a path prefix and the user omits the trailing slash
2018-06-20 12:18:35 +01:00
Arlen22
2163302190 Invoke hook when server starts (#3024)
* Invoke hook when server starts

Invokes the `th-server-command-start` hook when the server is started, with the server object as the parameter. This allows adding a WebSocket listener to the server.

* Return the HTTP server from the listen function

Returns the node HTTP server created in the listen function to allow extension

* Add node HTTP server to server-command-start hook

* Change hook to post start in case we add a pre-start hook

* Create Hook__th-server-command-post-start.tid
2018-04-10 21:55:54 +01:00
Jermolene
f4fd5e76f8 Server command: support environment variables for specifying port number 2018-03-28 11:58:46 +01:00
Jermolene
51b1ead5c9 Add more colour to command line output 2017-09-04 14:55:12 +01:00
Arlen22
1530b3e2d8 Put request handler on SimpleServer.prototype (#2627)
The request handler may be used by ExpressJS apps directly and can do most of the heavy lifting without any modification. Note that the self variable must be assignee using `[Function].bind(null,SimpleServer instance)`.
2016-12-17 15:06:10 +00:00
Jermolene
ac00aa8407 Allow server module to work under Node even if $tw.browser is defined
Needed for TiddlyDesktop, where want to be able to run the HTTP server
in a hybrid browser/node environment.
2015-11-10 18:13:30 +00:00
Jermolene
eb9fb6635d Fix issues with creation and modification dates
There were several places where tiddlers were being written without the
creation/modification details being updated.

See
https://groups.google.com/d/msgid/tiddlywiki/17ef8ab0-0128-4467-8a9d-f17
bdbcf3618%40googlegroups.com
2015-09-11 13:34:01 +01:00
Jermolene
862e358b57 Refine check for client server plugins
Fixes #1870
2015-07-08 15:48:13 +01:00
Jermolene
1c72e77106 Add warning if required client-server plugins are missing 2015-05-22 09:05:25 +01:00
Jermolene
7f9fb117e9 Clarify warning 2014-10-22 16:47:20 +01:00
Jermolene
e62e38d66c Add warning when serving a non-existent wiki folder
The warning will be yellow to make it noticeable
2014-10-21 19:31:29 +01:00
Jermolene
3a67fdb768 Obeisance to JSHint for core modules
There are still some warnings about making functions in a loop, but
I’ll fix those as a separate pull request because the fixes are more
than typographic errors.
2014-08-30 20:44:26 +01:00
Jermolene
eee3a0cf8e Extend server command to allow a path prefix
Thereby making the number of parameters to the command ludicrous
2014-06-13 14:44:34 +01:00
Jermolene
da273be054 Workaround Firefox "no element found" bug
See https://bugzilla.mozilla.org/show_bug.cgi?id=884693

Fixes #468
2014-05-27 09:49:48 +01:00
Skeeve
0595619d39 Show site title when logging in
I have several TW5 servers running on the same host and think it would be good, would the password prompt display the $:/SiteTitle
2014-03-31 08:58:13 +02:00
Jermolene
dd451800c7 Specify encoding for incoming requests
Fixes #397
2014-02-11 19:42:45 +00:00
Jermolene
6d3d3322e5 Fix problem in server with URI encoding of titles in etags
Fixes #398
2014-02-05 19:39:29 +00:00
Jermolene
12770ca3e6 Use an explicit default host
Thus fixing #339
2014-01-13 09:09:54 +00:00
Jermolene
bd7db62da0 Added support for specifying hostname for the --server command
Fixes #301
2013-12-29 13:07:06 +00:00
Jermolene
6c1489fc2f Remove duplicate header
And provide a slightly more informative prompt
2013-12-19 16:53:48 +00:00
Jermolene
2b72e48a3a Improve prompt for --server command 2013-12-18 21:11:16 +00:00
Jermolene
a4e3f66809 Add favicon.ico support to the server 2013-12-18 17:27:24 +00:00
Jermolene
1b75242345 Fix up caller of wiki.forEachTiddler() 2013-12-11 22:01:20 +00:00
Jermolene
50e1727ef7 Stop falling back to anonymous username
The `serve` command used to fallback the username parameter to
“ANONYMOUS” if it was not provided. Better is just to not set a
username if it is not provided; newly created tiddlers won’t get a
‘modifier’ field at all.
2013-12-11 07:45:36 +00:00
Jermolene
7d12d89a0a Added primitive support for basic authentication
Note that the password will be passed over HTTP in plain text.
2013-11-28 14:03:08 +00:00
Jermolene
b805633dc9 Reorganise the main file saving templates
We’re introducing a mechanism that allows us to decide which tiddlers
get saved. Using `$:/core/save/all` gives all tiddlers, as before.
Using `$:/core/save/empty` gives an empty wiki. Saving an empty wiki
from tw5.com isn’t the same as the empty wiki cooked from
editions/empty because the two editions have different plugins and
other system tiddlers.
2013-11-25 21:16:27 +00:00
Jeremy Ruston
ec481415f9 Fixes for TiddlyWeb 2013-11-08 20:18:26 +00:00
Jeremy Ruston
cc0011abd3 Get rid of the "new_" prefix we had on some methods
There's still the "old_" prefix to get rid of too.
2013-11-08 08:51:14 +00:00
Jeremy Ruston
925e22c46f Fix up the server command to use the new widget mechanism 2013-10-25 22:30:15 +01:00
Jeremy Ruston
a427702628 Allow username to be set for the built-in server 2013-08-21 09:53:45 +01:00
Jeremy Ruston
39b6091258 Don't set modification fields on synced tiddlers 2013-08-06 15:26:48 +01:00
Jeremy Ruston
86e73ee323 Set modified field and other metadata for newly created and modified tiddlers
Right now we're setting the created/modified time, and only setting the
creator/modifier if the tiddler `$:/status/UserName` is defined.
2013-08-04 14:02:07 +01:00
Jeremy Ruston
b51fb9cfa9 Linting 2013-07-05 22:37:55 +01:00
Jeremy Ruston
b6345a9223 Remove logging from the server command
We really need to update the logging infrastructure
2013-03-25 20:19:36 +00:00
Jeremy Ruston
70def07d63 Clearer logging preparatory to implementing file synchronisation 2013-03-24 12:53:09 +00:00
Jeremy Ruston
638ed6429c Show affected filepaths on the server
Preparatory to doing file sync on the server
2013-03-23 22:43:39 +00:00
Jeremy Ruston
d19fa16ca6 Fix inclusion of revision field when getting a tiddler 2013-03-17 19:25:59 +00:00
Jeremy Ruston
210f596d0c Marginally improve the elegance of the simple HTTP server 2013-03-17 17:57:46 +00:00
Jeremy Ruston
dbde2bf23b Started refactoring TiddlyWeb syncer into generic syncer + TiddlyWeb adaptor
The refactored plugin is `tiddlyweb2` for the moment. The idea is to be
able to use the same syncer with a different adaptor for syncing
changes to the local file system.
2013-03-17 15:28:49 +00:00
Jeremy Ruston
71ecb022ef Update TiddlyWeb support
Lots of changes:
* Make the built-in server support recipes and bags, albeit there's
just one of each, called "default"
* Correctly parse returned Etag to get bag of freshly PUT tiddlers
* URI encoding for tiddler titles, so that tiddlers with slashes and so
on work OK
2013-03-12 19:18:56 +00:00
Jeremy Ruston
6b78352764 Fixed handling of deleting tiddlers over HTTP 2013-03-11 10:04:44 +00:00
Jeremy Ruston
ab8fc26ba1 Update server command to be compatible with the TiddlyWeb syncer
Now TW5 in the browser can use the TiddlyWeb syncer to talk to TW5 on
the server
2013-03-10 19:28:24 +00:00
Jeremy Ruston
0dbe4c0291 Get rid of more vestiges of the old empty generation mechanism 2012-11-16 22:40:25 +00:00
Jeremy Ruston
fc6e563c17 Fixed problem with the --server command
I hadn't updated the code since using parametic substitution in the
main template
2012-10-24 22:11:01 +01:00
Jeremy Ruston
1b5beefb8d Fixed default TW5 template 2012-06-01 18:26:55 +01:00
Jeremy Ruston
34edb48784 A quick sweep for missing or inaccurate code comments 2012-05-19 18:23:14 +01:00
Jeremy Ruston
e2c7df5574 Added HTTP server command 2012-05-11 17:36:04 +01:00