How to embed [$:/plugins/tiddlywiki/tiddlyweb/readonly] to [$:/plugins/tiddlywiki/tiddlyweb/save/offline]

Hi,

I have a tw node server setup, where i have all my tiddlers in individual file. I noticed run this command:

tiddlywiki mywiki --output out --build index

it generated a single index.html file based on this rules in the tiddlywiki.info

        "index": [
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "index.html",
            "text/plain"
        ]

I would like to know how can i apply the $:/plugins/tiddlywiki/tiddlyweb/readonly css rules to the save/offline so that i have a index.html without the save buttons in my exported wiki.

Thanks.

This is not a direct answer, but in case it’s helpful:

@telumire made a solution (and shared it here last year) that would always be part of your wiki, but would check various specifiable conditions – including running as a single-file, if I understand correctly – to decide whether to display as read-only.

It’s very flexible in configuration – allows you convenient tinkering with read-only css, as well as easily tweaking which buttons, tabs, etc. to display in read-only mode. Meanwhile, whenever you’re running in the node.js environment, the read-only specifications are ignored, and you experience full authoring mode.

https://read-only.tiddlyhost.com/#%24%3A%2FControlPanel:%24%3A%2FControlPanel%20%24%3A%2FTiddlyTweaks%2FReadOnly

1 Like

Also not a direct answer but possibly helpful:

I have a number of wikis (mostly behind corporate walls) which I and a few other editors need to be able to regularly edit, but which should not be editable by most users. I’ve settled on a fairly useful approach, starting with two tiddlers borrowed from Reader Mode in Mohammed’s TW-Utility plugin, and with other changes I’ve added.

The idea is that the editors are technically sophisticated, and will run Node locally, committing the Node code back to a shared git repository, where it’s built into a single-file wiki and published.

The code is the same in Node or in single-file, but a startup action checks for the existence of a Node-only plugin. If it’s not present we hide various editing UI components.:

<$list filter="[[$:/plugins/tiddlywiki/tiddlyweb]is[missing]]">
<!-- a number of actions to hide edit mode -->
</$list>

But a key combination will toggle edit mode: CTL-SHIFT-/. This allows users in the know to save copies with suggested changes to submit to the editors.

You can see this in action on TW-TidDox. This is a wiki I’m not really ready to talk about yet, but it’s the only place I have this behavior that’s not behind corporate walls. The relevant tiddlers should show pretty well how it works, with most of the credit going to @Mohammad.

2 Likes

Hi, I believe I got some success with this approach, but when i open the index.html file I still can trigger edit via ctrl+shif+/. Is there a way to disable that?

Not sure if I follow, should I create $:/TiddlyTweaks/ReadOnly tiddler and that is it?

As I said, this is not a direct answer. It is designed around allowing CTR-SHIFT-/ to toggle edit mode, and to default to edit-mode when running in Node but to read-only from a single-file wiki. I would guess, though, that if you can get the build step to not include $:/plugins/kookma/utility/reader-mode/switch-actions, it would just work. I simply don’t know how to do that. Moreover, if we’re messing with precisely what gets built, there are probably better solutions anyway.

Ok, I figured this out. In the Node version, make a copy of $:/plugins/tiddlywiki/tiddlyweb/save/offline, called $:/plugins/tiddlywiki/tiddlyweb/save/offline/read-only. Alter it by adding -$:/plugins/kookma/utility/reader-mode/switch-actions to the filter. In my 5.2.7 version, it looks like this:

\import [[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]
\define saveTiddlerFilter()
[is[tiddler]] -[[$:/boot/boot.css]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/tiddlywiki/tiddlyweb]] -[prefix[$:/temp/]] -$:/plugins/kookma/utility/reader-mode/switch-actions +[sort[title]] $(publishFilter)$
\end
{{$:/core/templates/tiddlywiki5.html}}

Then in tiddlywiki.info add a read-only build target:

   /* ... */
    "build": {
        "index": [
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "index.html",
            "text/plain"
        ],
        "read-only": [
            "--render",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline/read-only",
            "index.html",
            "text/plain"
        ],
       "static": [
    /* ... */
}

Now you can call tiddlywiki path/to/wiki --build read-only to generate a read-only version of the wiki without the CTRL-SHIFT-/ feature.

Hi, thanks! but I tried with TW 5.2.7 and no success :frowning:

I also tried to omit the shortcut tiddlers (no idea if this is allowed)
-[[$:/config/ShortcutInfo/customize-ui]] -[[$:/config/ShortcutInfo/switch-reader-mode]]

Hmm, it worked for me with a copy of the wiki above.

Is you wiki online somewhere we could look at it?

But this is probably a distraction. We’re trying to hack in behavior that was not intended with this technique. I would look carefully at the link @springer sent to @telumire’s work.

Once way to enable and disable something in a wiki without code in the wiki is to create two bookmarklets. One containing the payload tiddlers for one state, another with the same tiddlers but the alternate values.

This logic is then outside the wiki.

If you bundle some tiddlers for this I can generate some bookmarklettes for you. Or your can learn yourself.

Ok, I found the page:
Read only TW — experiment for a read only wiki hosted on tiddlyhost this link made things more clear.

But when i use with my self hosted tw version 5.2.2 I get this:

But when I ran locally with version 5.2.7 I get this:

@Scott_Sauyet, @TW_Tones Thanks for the help, I am playing with the @Springer suggestion but it seems that the changes somehow affect my node.js version.

I wouldn’t worry about what that tiddler itself looks like. The main question is whether you can find the new “Read Only” tab within the ControlPanel’s Appearance area (after saving and reloading – whatever that looks like in node.js mode).