Tiddlers loaded via tiddlywiki.files are not editable

106 views
Skip to first unread message

Saq Imtiaz

unread,
Jun 15, 2017, 9:32:19 AM6/15/17
to TiddlyWiki
The title isn't completely accurate as it is difficult to summarize the problem. Plain text .txt files or .md files, loaded via a tiddlywiki.files declaration load in the TiddlyWiki just fine. However, editing them is problematic.

With a subdir in my tiddlers directory called "notes", containing a file "mynote.txt", editing results in a file "mynote 1.txt" and "mynote 1txt.meta" whereas I would expect the original "mynote.txt" to be updated and a .meta file created. This behavior leads to duplication of tiddler files and is rather confusing. If the intent was that files loaded in this manner should not be editable, then we should find a way to set them as read only.

It is possible that the problem may arise from my tiddlywiki.files declaration as I am new to this, so here it is:

{
  "directories" : [
    {
      "path" : "../notes",
      "filesRegExp" : ".+\\.txt",
      "isTiddlerFile" : false,
      "fields" : {
        "title" : {"source" : "basename-uri-decoded"},
        "created": {"source" : "created"},
        "modified": {"source" : "modified"},
        "type": "text/plain",
        "tags": ["note", "externalnote"]
      }
    }
  ]
}


Digging into the code in boot.js reveals that not .txt or .md files that do not have .meta files and are loaded via a tiddlywiki.files declaration are never added to $tw.boot.files (as they don't have their filepath set):https://github.com/Jermolene/TiddlyWiki5/blob/a4035d34247e2f27efc9cb6228432deea21d73a3/boot/boot.js#L1786

Likely this is the problem and leads the save handler to rename the tiddler because of an assumed file name clash, leading to file names like "mynote 1.txt".

Have I missed something with my configuration? If not, feature or bug?
Regards,

Saq

Saq Imtiaz

unread,
Jun 15, 2017, 10:11:15 AM6/15/17
to TiddlyWiki
Some more configuration information that may help with debugging, as I am little unsure as to what the proper location for the tiddlywiki.files file is.

I have tried the following:

- tiddlers
- - notes
- - - mynote.txt
- - - tiddlywiki.files

and

- tiddlers
- - notes
- - - mynote.txt
- - noteconfig
- - - tiddlywiki.files

Note that I specify how to load the notes directory in tiddlywiki.files but allow all other tiddlers to load as usual.

Saq Imtiaz

unread,
Jun 15, 2017, 1:54:38 PM6/15/17
to TiddlyWiki
So it turns out that if we modify line line 1594 in boot.js from 

tiddlers.push({tiddlers: fileTiddlers});

to

tiddlers.push({filepath: pathname, hasMetaFile: !!metadata && !isTiddlerFile, tiddlers: fileTiddlers});

the files are saved to the accurate and original filename, along with a .meta file for non .tid files. We will need to discuss whether this is the approach we want, however I know feel comfortable assuming that the current behaviour is a bug and will open an issue.

Saq
Reply all
Reply to author
Forward
0 new messages