Skip to content

Commit

Permalink
Merge branch 'dev' of pieserver.local:TiddlyPlugins/Bob
Browse files Browse the repository at this point in the history
  • Loading branch information
inmysocks committed Sep 14, 2019
2 parents e766938 + 35c1389 commit 87b17e0
Show file tree
Hide file tree
Showing 31 changed files with 1,051 additions and 500 deletions.
80 changes: 80 additions & 0 deletions ActionWidgets/ActionOpenSocket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*\
title: $:/plugins/OokTech/Bob/action-opensocket.js
type: application/javascript
module-type: widget
Action widget that creates a new websocket connection to another server
<$action-opensocket $url=<<someURL>> blah=halb/>
\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

const Widget = require("$:/core/modules/widgets/widget.js").widget;

const ActionOpenSocket = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};

/*
Inherit from the base widget class
*/
ActionOpenSocket.prototype = new Widget();

/*
Render this widget into the DOM
*/
ActionOpenSocket.prototype.render = function(parent,nextSibling) {
this.computeAttributes();
this.execute();
};

/*
Compute the internal state of the widget
*/
ActionOpenSocket.prototype.execute = function() {
this.remoteURL = this.getAttribute('$url', '');
};

/*
Refresh the widget by ensuring our attributes are up to date
*/
ActionOpenSocket.prototype.refresh = function(changedTiddlers) {
const changedAttributes = this.computeAttributes();
if(Object.keys(changedAttributes).length) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers);
};

/*
Invoke the action associated with this widget
*/
ActionOpenSocket.prototype.invokeAction = function(triggeringWidget,event) {
$tw.RemoteConnection = $tw.RemoteConnection || {};
if (this.remoteURL) {
$tw.RemoteConnection.socket = new WebSocket(this.remoteURL);
$tw.RemoteConnection.socket.onopen = openSocket;
$tw.RemoteConnection.socket.onmessage = parseMessage;
$tw.RemoteConnection.socket.binaryType = "arraybuffer";
}
return true; // Action was invoked
};

function openSocket(event) {
console.log(event.target)
event.target.send('HI!')
}

function parseMessage() {

}

exports["action-opensocket"] = ActionOpenSocket;

})();
24 changes: 22 additions & 2 deletions BobLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,29 @@ if($tw.node) {
}
if ($tw.settings.logger.useBrowserLogging === 'yes') {
// TODO this!!
const browserLogTiddlerName = '$:/status/Bob/Logs'
const browserErrorTiddlerName = '$:/status/Bob/Errors'
$tw.Bob.logger.browser = {
log: function(){},
error: function(){}
log: function(/* args */){
// Take the message and put it into the logging tiddler
// The key is the timestamp, the value is the message
// Get the current json tiddler

// Add the new message to it

// Save the updated tiddler

},
error: function(/* args */){
// Take the message and put it into the error tiddler
// The key is the timestamp, the value is the message
// Get the current json tiddler

// Add the new message to it

// Save the updated tiddler

}
}
}
if ($tw.settings.logger.useConsoleLogging !== 'no') {
Expand Down
25 changes: 25 additions & 0 deletions Changelog.tid
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
title: $:/plugins/OokTech/Bob/Changelog

!! Version 1.2.5 Tofurkey

- maybe actually set the SaverFilter tiddler correctly

!! Version 1.2.4 Mashed Potatoes with a fine black pepper gravy

- Cleaned up some code in `FileSystemMonitor.js` and `WebsocketAdaptor.js` to better partition what each does, no functional changes.
- Split out the start of the federation components for inter-server communication.
- Change all of the checks to see if a tiddler has changed to use the hash of the tiddler instead of matching fields. It should be less suceptable to bugs. It may be slightly faster but this probably isn't a place where that makes a difference.
- (unfinished) The hashes are cached where appropriate to make things a bit faster. Once again this may be unneeded but it was simple to implement.
- The normalizeTiddler and TiddlerHasChanged functions are used more consistently
- fix some incorrect handing of tags and list fields in normalizeTiddler
- Change code to use new core utility functions
- Used `$tw.utils.generateTiddlerFileInfo` where appropriate
- Used `$tw.utils.saveTiddlerToFileSync`,
- Added collapsing wiki listing
- Fixed a bug that sometimes prevented the file server from working correctly in the root wiki.
- Added the working framework for inter-server federation and messages.
- Added a check to see if Bob was running in an iframe and if so don't treat upgrade requests as websockets
- This is needed to make twederation work with Bob servers.
- Fixed a bug where the list field would be sorted when it shouldn't be.
- Added command to scan a folder for media and create _canonical_uri tiddlers for each thing found. (mediaScan)
- updated to tiddlywiki v5.1.21
- fixed a bug with how filter in $:/config/FileSystemPaths are handled

!! Version 1.2.3 Boiled Potatoes

- Setting up the file server is simpler now
Expand Down
18 changes: 17 additions & 1 deletion Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,23 @@ used. If the json isn't formatted correctly than default values will be used.
"enableFetch": "no",
"enablePush": "no",
"pluginLibrary": "no"
}
},
"logger": {
"useFileLogging":"no",
"outputFolder": "./logs",
"outputBaseFileName": "Log",
"useSeparateErrorFile": "no",
"outputErrorFileName": "Error",
"ignoreErrors": "yes",
"useBrowserLogging": "no",
"browserLogLevel": "2",
"useConsoleLogging": "yes",
"consoleLogLevel": "2",
"useFileLogging": "no",
"fileLogLevel": "2"
},
"includePluginList": [],
"excludePluginList": []
}
```

Expand Down
25 changes: 25 additions & 0 deletions ControlPanel/FederationTab.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
title: $:/plugins/OokTech/Bob/FederationTab
caption: Federation

Coming soon

<!--
Federation stuff!!

We need to add ways to sync with other wikis, a way to configure what gets
synced, stuff like that.

!!Active Connections

<$list
filter='[list[$:/Bob/ActiveConnections]]'
>

</$list>

!!Known Connections

url, name, synced wikis, other actions

something for security, pubilc keys probably
-->
67 changes: 59 additions & 8 deletions ControlPanel/ServerTab/FileServerSetup.tid
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ title: $:/plugins/OokTech/Bob/FileServerSetup.tid
caption: File Server

\define checkActions()
<$list filter='[[$:/WikiSettings/split]getindex[filePathRoot]]' emptyMessage="""<$action-setfield $tiddler='$:/WikiSettings/split' $index='filePathRoot' $value='./files'/>""">
<$list
filter='[[$:/WikiSettings/split]getindex[filePathRoot]]'
emptyMessage="""<$action-setfield $tiddler='$:/WikiSettings/split' $index='filePathRoot' $value='./files'/>"""
>
</$list>
\end

<$reveal type='nomatch' state='$:/settings/Bob/Verbose' text='false'>
<$reveal
type='nomatch'
state='$:/settings/Bob/Verbose'
text='false'
>

These are options for how to turn on and configure the file server included in
Bob.
Expand Down Expand Up @@ -40,11 +47,48 @@ username on the computer you are using.

</$reveal>

<$checkbox actions=<<checkActions>> tiddler='$:/WikiSettings/split' index='enableFileServer' checked='true' unchecked='false'> Enable File Server</$checkbox>

Files Folder: <$edit-text tiddler='$:/WikiSettings/split' index='filePathRoot' tag='input' class='tc-edit-texteditor' default='./files'/>

<$reveal type='nomatch' state='$:/settings/Bob/Verbose' text='false'>
<$checkbox
actions=<<checkActions>>
tiddler='$:/WikiSettings/split'
index='enableFileServer'
checked='true'
unchecked='false'
>
Enable File Server
</$checkbox>

Files Folder:
<$edit-text
tiddler='$:/WikiSettings/split'
index='filePathRoot'
tag='input'
class='tc-edit-texteditor'
default='./files'
/>

After enabling or disabling the file server you must shutdown the server and
then restart it before using the file server.

First click this button:
<$button>
Update Settings
<$action-savesettings/>
</$button>

Then click this button:
<$button>
Shutdown Wiki
<$action-websocketmessage $type=shutdownServer/>
</$button>

Then refresh the page, this is not what the 'reconnect' button is for, refresh
the entire page.

<$reveal
type='nomatch'
state='$:/settings/Bob/Verbose'
text='false'
>

The file URL prefix is used to build the paths to the files on your computer.
Bob is not the same as using a single file wiki, it is a server. When you put
Expand All @@ -55,4 +99,11 @@ See [[serving files|$:/plugins/OokTech/Bob/Serving Files]] for more.

</$reveal>

File URL Prefix: <$edit-text tiddler='$:/WikiSettings/split' index='fileURLPrefix' tag='input' class='tc-edit-texteditor' default='files'/>
File URL Prefix:
<$edit-text
tiddler='$:/WikiSettings/split'
index='fileURLPrefix'
tag='input'
class='tc-edit-texteditor'
default='files'
/>
12 changes: 12 additions & 0 deletions ControlPanel/ThisWikiTab.tid
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ caption: This Wiki
These are options that are specific to this wiki. They don't affect any other
wikis.

This button will unload the current wiki. This means that it will be
disconnected from the server and any changes you make will not be saved.

In order to reconnect you have to reload the wiki page.
</$reveal>

<$button>
Unload Wiki
<$action-websocketmessage
$type='unloadWiki'
wikiName={{$:/WikiName}}
/>
</$button>

<<tabs "[[$:/plugins/OokTech/Bob/SelectPlugins]][[$:/plugins/OokTech/Bob/SelectThemes]]" "$:/plugins/OokTech/Bob/SelectPlugins">>
3 changes: 0 additions & 3 deletions CoreSettingsOverride/SaveFilter.tid

This file was deleted.

3 changes: 3 additions & 0 deletions CoreSettingsOverride/SaverFilter.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: $:/config/SaverFilter

[is[system]!is[system]]
4 changes: 4 additions & 0 deletions Documentation/InterServerFederation.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: title: $:/plugins/OokTech/Bob/InterServerFederation
caption: Inter-server Federation

Coming soon.
3 changes: 3 additions & 0 deletions Documentation/Serving Files.tid
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ To access files on your harddrive you have to enable the file server component
of Bob. To do this open the $:/ControlPanel, then the tab `Bob Settings` and
under that the tab `File Server` and check the `Enable File Server` checkbox.

After the box is checked you have to restart the wiki server before it will
work.

!!! Setting up the file server

After enabling the file server it is easiest to just use the default settings.
Expand Down
51 changes: 51 additions & 0 deletions Documentation/WebSocketMessages/WebSocketMessage-mediaScan.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
title: $:/plugins/OokTech/Bob/WebSocketMessage-mediaScan
tags: [[Websocket Message]]
caption: mediaScan
description: Scan a folder for media and create _canonical_uri tiddlers for each file found

This message is used to scan a folder for media files and create a
_canonical_uri tiddler for each file found.

''NOTE:'' Only folders that are children of the folder set as the
`filePathRoot` in the settings can be scanned.

!!Usage

|!Name |!Description |
|!folder |The folder to scan, either absolute or relative to the file path root. (No Default) |
|!ignoreExisting |If this is set to `yes` any tiddler with _canonical_uri that matches a file exists nothing further is done with that file (this takes precidence over overwrite) (Default `no`) |
|!overwrite |If this is set to `yes` than new tiddlers are made even if they overwrite existing tiddlers. (Default `no`) |
|!prune |If this is set to `yes` than any tiddlers that have _canonical_uri fields that point to a file that would be in the folder being scanned that doesn't exist the tiddler is removed. (Default `no`) |
|!mediaTypes |(Optional) A space separated list of file extensions to scan for. If no list is given all types listed in the mimeMap will be used. |

```
<$action-websocketmessage $type='mediaScan' folder='wikiFolderPath' ignoreExisting='editionName' overwrite='newWikiName' prune='basePath' mediaTypes='.jpg .png .jpeg'/>
```

The default mimeMap is:

```
{
'.aac': 'audio/aac',
'.avi': 'video/x-msvideo',
'.csv': 'text/csv',
'.doc': 'application/msword',
'.epub': 'application/epub+zip',
'.gif': 'image/gif',
'.html': 'text/html',
'.htm': 'text/html',
'.ico': 'image/x-icon',
'.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg',
'.mp3': 'audio/mpeg',
'.mpeg': 'video/mpeg',
'.oga': 'audio/ogg',
'.ogv': 'video/ogg',
'.ogx': 'application/ogg',
'.png': 'image/png',
'.svg': 'image/svg+xml',
'.weba': 'audio/weba',
'.webm': 'video/webm',
'.wav': 'audio/wav'
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: $:/plugins/OokTech/Bob/WebSocketMessage-openRemoteConnection
tags: [[Websocket Message]]
caption: openRemoteConnection
description: A message that tells the server to open a connection to a remote server.

This message tells the server to try and open a connection to a remote server.

This is the first step to having federated communication between wikis.
11 changes: 0 additions & 11 deletions Documentation/WebSocketMessages/WebSocketMessage-restartServer.tid

This file was deleted.

Loading

0 comments on commit 87b17e0

Please sign in to comment.