From 7725213f7a89b2e5fcda19bc738f1ab444337720 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 13 Sep 2021 20:19:31 -0500 Subject: [PATCH] Improving remote and local storage for TiddlyWiki. --- repository/TiddlyWiki/TiddlyWiki.class.st | 50 ++++++++++++++++++++++- repository/TiddlyWiki/WikiText.class.st | 1 + 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index e5a3c1e..6d50529 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -9,7 +9,9 @@ Class { #superclass : 'Object', #instVars : [ 'tiddlers', - 'file' + 'file', + 'remote', + 'name' ], #category : 'TiddlyWiki-Model' } @@ -53,6 +55,40 @@ TiddlyWiki >> importJSONFile [ ]) ] +{ #category : 'accessing' } +TiddlyWiki >> local [ + ^ self file +] + +{ #category : 'accessing' } +TiddlyWiki >> local: aFileRefence [ + ^ self file:aFileRefence +] + +{ #category : 'accessing' } +TiddlyWiki >> name [ + + ^ name ifNil: [ + self file + ifNil: [ | tempName suffix | + tempName := self remote file. + (tempName endsWithAnyOf: #('.html' '.htm')) + ifTrue: [ + suffix := (tempName splitOn: '.') last. + tempName := tempName removeSuffix: '.', suffix. + ]. + name := tempName + ] + ifNotNil: [ name := self file basenameWithoutExtension ] + ] +] + +{ #category : 'accessing' } +TiddlyWiki >> name: aString [ + + name := aString +] + { #category : 'accessing' } TiddlyWiki >> networkView [ | view | @@ -72,6 +108,18 @@ TiddlyWiki >> printOn: aStream [ nextPutAll: '( ', self file basename ,' )' ] +{ #category : 'accessing' } +TiddlyWiki >> remote [ + + ^ remote +] + +{ #category : 'accessing' } +TiddlyWiki >> remote: aUrlString [ + + remote := aUrlString asZnUrl +] + { #category : 'accessing' } TiddlyWiki >> taggedWith: aTag [ ^ self tiddlers select: [:tiddler | diff --git a/repository/TiddlyWiki/WikiText.class.st b/repository/TiddlyWiki/WikiText.class.st index 7f05e24..9047aa1 100644 --- a/repository/TiddlyWiki/WikiText.class.st +++ b/repository/TiddlyWiki/WikiText.class.st @@ -31,6 +31,7 @@ WikiText >> convertMarkdownBold [ { #category : 'conversions' } WikiText >> convertMarkdownLinks [ | markdownLinks markdownLinksRegex | + "\[([\w|\s]+)\]\((\S+)\)" markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'. "For the explanation of the Regex details see: http://scottradcliff.com/how-to-parse-urls-in-markdown.html" markdownLinks := self content regex: markdownLinksRegex matchesCollect: [:link | link ].