From 3713ee4fa98cb3a9e0ccc3a23348e9a4fed54da4 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Wed, 16 Nov 2022 17:27:10 +0000 Subject: [PATCH 1/9] Update release note --- editions/prerelease/tiddlers/Release 5.2.4.tid | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/editions/prerelease/tiddlers/Release 5.2.4.tid b/editions/prerelease/tiddlers/Release 5.2.4.tid index 3f38343a8..aec127496 100644 --- a/editions/prerelease/tiddlers/Release 5.2.4.tid +++ b/editions/prerelease/tiddlers/Release 5.2.4.tid @@ -1,6 +1,6 @@ caption: 5.2.4 -created: 20221101094408196 -modified: 20221101094408196 +created: 20221116172656216 +modified: 20221116172656216 tags: ReleaseNotes title: Release 5.2.4 type: text/vnd.tiddlywiki @@ -9,13 +9,14 @@ type: text/vnd.tiddlywiki ! Plugin Improvements -* +* New [[Twitter Archivist|./editions/twitter-archivist]] plugin to imports the tweets and associated media from a Twitter Archive as individual tiddlers ! Translation improvement Improvements to the following translations: * Chinese +* French * Polish * Spanish * Japanese @@ -37,6 +38,7 @@ Improvements to the translation features of TiddlyWiki: * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/36896c3db8c9678c0385a561996248a6f00a45ff">> opening a tiddler in a new window to use the [[View Template Body Cascade]] * <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6970">> detection of infinite recursion errors in widgets and filters * <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/6877">> default styles for [[styled runs|Styles and Classes in WikiText]] +* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6881">> upgrade wizard to make the version number more prominent ! Widget Improvements @@ -55,7 +57,10 @@ Improvements to the translation features of TiddlyWiki: * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/166a1565843878083fb1eba47c73b8e67b78400d">> safe mode to prevent globally disabling parser rules * <<.link-badge-removed "https://github.com/Jermolene/TiddlyWiki5/commit/1df4c29d73073788ba3859668112e8bb46171a6c">> restriction of the LetWidget being unable to create variables whose names begin with a dollar sign * <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/6735">> keyboard shortcut handling to allow to global shortcuts to override all other shortcuts - +* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/commit/965bd090a905f5756e79124b698c894f7f72ad5b">> [[list-links Macro]] to allow the rendered field to be overriden +* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6913">> [[Table-of-Contents Macros]] to allow the default icons to be overridden +* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6939">> ''data-tags-*'' and ''data-tiddler-title'' attributes to the edit preview area +* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/5947">> [[timeline Macro]] to override the link template ! Bug Fixes @@ -71,6 +76,9 @@ Improvements to the translation features of TiddlyWiki: ! Node.js Improvements * <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6947">> console logging to avoid spaces and `` message +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7014">> problem with lazy loading deleting tiddler bodies under certian circumstances +* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/344110e2890caf711ab8f3c4f4deaa7d86771231">> handling of ".mp4" file extension so that it defaults to video not audio +* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6588">> test server to the plugin library edition ! Performance Improvements @@ -83,6 +91,7 @@ Improvements to the translation features of TiddlyWiki: [[@Jermolene|https://github.com/Jermolene]] would like to thank the contributors to this release who have generously given their time to help improve TiddlyWiki: <<.contributors """ +AnthonyMuscio bestony btheado BramChen From 39e8c8b12550db63a72d36cbb61f0e3476aaee73 Mon Sep 17 00:00:00 2001 From: Talha Mansoor Date: Sun, 20 Nov 2022 03:11:46 +0500 Subject: [PATCH 2/9] Fix modified timestamp (#7046) --- .../tiddlers/nodejs/Installing TiddlyWiki on Node.js.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/nodejs/Installing TiddlyWiki on Node.js.tid b/editions/tw5.com/tiddlers/nodejs/Installing TiddlyWiki on Node.js.tid index 447975ffc..7f98e3b13 100644 --- a/editions/tw5.com/tiddlers/nodejs/Installing TiddlyWiki on Node.js.tid +++ b/editions/tw5.com/tiddlers/nodejs/Installing TiddlyWiki on Node.js.tid @@ -4,7 +4,7 @@ created: 20131219100608529 delivery: DIY description: Flexible hosting on your own machine or in the cloud method: sync -modified: 20221151230831173 +modified: 20221115230831173 tags: Saving [[TiddlyWiki on Node.js]] Windows Mac Linux title: Installing TiddlyWiki on Node.js type: text/vnd.tiddlywiki From c663d2ba00219f15df581d00ea24790a5c61972d Mon Sep 17 00:00:00 2001 From: Talha Mansoor Date: Sun, 20 Nov 2022 03:13:02 +0500 Subject: [PATCH 3/9] Sort completed tasks by 'modified' instead of 'created' field (#7047) --- .../demonstrations/Tasks/TaskManagementExampleDraggable.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/demonstrations/Tasks/TaskManagementExampleDraggable.tid b/editions/tw5.com/tiddlers/demonstrations/Tasks/TaskManagementExampleDraggable.tid index e981edd09..4ec1de69a 100644 --- a/editions/tw5.com/tiddlers/demonstrations/Tasks/TaskManagementExampleDraggable.tid +++ b/editions/tw5.com/tiddlers/demonstrations/Tasks/TaskManagementExampleDraggable.tid @@ -16,7 +16,7 @@ This is a version of the TaskManagementExample enhanced with the ability to drag //(Listed in reverse order of completion)// -<$list filter="[!has[draft.of]tag[task]tag[done]sort[created]]"> +<$list filter="[!has[draft.of]tag[task]tag[done]sort[modified]]">
<$checkbox tag="done"> ~~<$link/>~~
From ea150029f51e777d171f3f1afc1e623ac3e77941 Mon Sep 17 00:00:00 2001 From: Maurycy Zarzycki Date: Sat, 19 Nov 2022 23:13:35 +0100 Subject: [PATCH 4/9] add a lot of small language tweaks and fixes to Polish translation (#7045) --- languages/pl-PL/Buttons.multids | 6 ++-- languages/pl-PL/ControlPanel.multids | 50 +++++++++++++++------------- languages/pl-PL/ThemeTweaks.multids | 6 ++-- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/languages/pl-PL/Buttons.multids b/languages/pl-PL/Buttons.multids index 571e3600a..54691581d 100644 --- a/languages/pl-PL/Buttons.multids +++ b/languages/pl-PL/Buttons.multids @@ -81,7 +81,7 @@ Palette/Caption: paleta Palette/Hint: Wybierz paletę kolorów Permalink/Caption: bezpośredni link Permalink/Hint: Ustaw adres w przeglądarce na bezpośredni link do tego tiddlera -Permaview/Caption: permanenty widok +Permaview/Caption: link do obecnego widoku Permaview/Hint: Ustaw adres w przeglądarce na bezpośredni link do obecnego Story River Print/Caption: wydrukuj stronę Print/Hint: Drukuje aktualną stronę @@ -97,7 +97,7 @@ HideSideBar/Caption: ukryj menu boczne HideSideBar/Hint: Ukryj menu boczne ShowSideBar/Caption: pokaż menu boczne ShowSideBar/Hint: Pokaż menu boczne -TagManager/Caption: Menedżer tagów +TagManager/Caption: menedżer tagów TagManager/Hint: Otwórz menedżer tagów Timestamp/Caption: aktualizacje czasu Timestamp/Hint: Wybierz czy zmiany mają aktualizować czas @@ -124,7 +124,7 @@ Excise/Caption/Replace/Macro: makro Excise/Caption/Replace/Link: link Excise/Caption/Replace/Transclusion: transkluzja Excise/Caption/Tag: Otaguj nowego tiddlera nazwą tego -Excise/Caption/TiddlerExists: Uwaga: Tiddler już istnieje +Excise/Caption/TiddlerExists: Uwaga: tiddler już istnieje Excise/Hint: Wytnij zaznaczony tekst i wstaw go do nowego tidlera Heading1/Caption: nagłówek 1 Heading1/Hint: Zmień zaznaczony tekst na nagłówek 1. stopnia diff --git a/languages/pl-PL/ControlPanel.multids b/languages/pl-PL/ControlPanel.multids index a11d35298..38e4b7fad 100644 --- a/languages/pl-PL/ControlPanel.multids +++ b/languages/pl-PL/ControlPanel.multids @@ -5,17 +5,19 @@ Advanced/Hint: Wewnętrzne informacje na temat TiddlyWiki Appearance/Caption: Wyświetlanie Appearance/Hint: Dostosowywanie wyglądu tej TiddlyWiki Basics/AnimDuration/Prompt: Długość animacji -Basics/AutoFocus/Prompt: Domyślne pole z fokusem dla nowych tiddlerów +Basics/AutoFocus/Prompt: Domyślne wybrane pole do edycji przy tworzeniu nowego tiddlera Basics/Caption: Podstawowe -Basics/DefaultTiddlers/BottomHint: Używaj [[podwójnych nawiasów kwadratowych]] dla nazw ze spacjami. Możesz też {{przywrócić ostatnią sesję||$:/snippets/retain-story-ordering-button}} +Basics/DefaultTiddlers/BottomHint: Tiddlery, które mają spację w nazie otocz [[podwójnymi nawiasami kwadratowymi]]. Możesz też ustawić, by zawsze widzieć {{ostatnio otwarte tiddlery||$:/snippets/retain-story-ordering-button}} +Basics/DefaultTiddlers/BottomHint: Use [[double square brackets]] for titles with spaces. Or you can choose to <$button set="$:/DefaultTiddlers" setTo="[list[$:/StoryList]]">retain story ordering +Basics/DefaultTiddlers/BottomHint: Use [[double square brackets]] for titles with spaces. Or you can choose to {{retain story ordering||$:/snippets/retain-story-ordering-button}} Basics/DefaultTiddlers/Prompt: Domyślnie otwarte tiddlery Basics/DefaultTiddlers/TopHint: Wybierz które tiddlery mają być widoczne przy uruchomieniu Basics/Language/Prompt: Cześć! Wybrany język to: -Basics/NewJournal/Title/Prompt: Tytuł nowych dzienników -Basics/NewJournal/Text/Prompt: Treść nowych dzienników -Basics/NewJournal/Tags/Prompt: Tagi nowych dzienników -Basics/NewTiddler/Title/Prompt: Tytuł nowych tiddlerów -Basics/NewTiddler/Tags/Prompt: Tagi nowych tiddlerów +Basics/NewJournal/Title/Prompt: Domyślny tytuł nowych dzienników +Basics/NewJournal/Text/Prompt: Domyślna treść nowych dzienników +Basics/NewJournal/Tags/Prompt: Domyślne tagi nowych dzienników +Basics/NewTiddler/Title/Prompt: Domyślny tytuł nowych tiddlerów +Basics/NewTiddler/Tags/Prompt: Domyślne tagi nowych tiddlerów Basics/OverriddenShadowTiddlers/Prompt: Liczba nadpisanych tiddlerów-cieni Basics/RemoveTags: Zaktualizuj do obecnego formatu Basics/RemoveTags/Hint: Zaktualizuj konfigurację tagów do najnowszego formatu @@ -58,7 +60,7 @@ LoadedModules/Caption: Wczytane Moduły LoadedModules/Hint: To są wszystie wczytane moduły podlinkowane do swoich tiddlerów źródłowych. Te zapisane kursywą nie posiadają źródłowych tiddlerów, zwykle dlatego, że były skonfigorwane podczas procesu uruchomienia. Palette/Caption: Paleta Palette/Editor/Clone/Caption: kopiuj -Palette/Editor/Clone/Prompt: Zalecane jest skopiowanie taj ukrytej palety przed edycją +Palette/Editor/Clone/Prompt: Zalecamy skopiowanie tej palety przed zmianą kolorów Palette/Editor/Delete/Hint: usuń tą konfigurację z obecnej palety Palette/Editor/Names/External/Show: Pokaż nazwy kolorów, które nie są częścią wybranej palety Palette/Editor/Prompt/Modified: Ukryta paleta została zmieniona @@ -144,7 +146,7 @@ Settings/AutoSave/Disabled/Description: Nie zapisuj zmian automatycznie Settings/AutoSave/Enabled/Description: Zapisuj zmiany automatycznie Settings/AutoSave/Hint: Próbuj automatycznie zapisać zmiany podczas edycji, gdy używasz wspierającego to modułu zapisującego Settings/CamelCase/Caption: Camel Case WikiLinki -Settings/CamelCase/Hint: Możesz wyłączyć automatyczne linkowanie fraz w ~CamelCase. Wymaga ponownego uruchomienia. +Settings/CamelCase/Hint: Możesz wyłączyć automatyczne linkowanie fraz w ~CamelCase; wymaga ponownego uruchomienia Settings/CamelCase/Description: Włącz automatyczne linkowanie ~CamelCase Settings/Caption: Ustawienia Settings/EditorToolbar/Caption: Pasek Narzędzi Edytora @@ -165,11 +167,11 @@ Settings/NavigationHistory/Hint: Aktualizuj historię nawigacji przeglądarki pr Settings/NavigationHistory/No/Description: Nie aktualizuj historii Settings/NavigationHistory/Yes/Description: Aktualizuj historię Settings/NavigationPermalinkviewMode/Caption: Tryb linków bezpośrednich/widoku -Settings/NavigationPermalinkviewMode/Hint: Ustal jak linki bezośrednie/widok się zachowują: +Settings/NavigationPermalinkviewMode/Hint: Ustal jak linki bezpośrednie/widok się zachowują: Settings/NavigationPermalinkviewMode/CopyToClipboard/Description: Skopiuj URL do linku bezpośredniego/widoku do schowka Settings/NavigationPermalinkviewMode/UpdateAddressBar/Description: Zaktualizuj pasek adresu o URL do linku bezpośredniego/widoku -Settings/PerformanceInstrumentation/Caption: Logowanie w Konsoli -Settings/PerformanceInstrumentation/Hint: Uruchamia lokowanie w konsoli deweloperskiej przeglądarki. Wymagane ponowne uruchmoenie +Settings/PerformanceInstrumentation/Caption: Logowanie wydajności w Konsoli +Settings/PerformanceInstrumentation/Hint: Uruchamia logowanie wydajności w konsoli deweloperskiej przeglądarki; wymaga ponownego uruchomienia Settings/PerformanceInstrumentation/Description: Włącz logowanie Settings/ToolbarButtonStyle/Caption: Styl Przycisków Paska Narzędzi Settings/ToolbarButtonStyle/Hint: Wybierz styl przycisków w pasku narzędzi @@ -208,22 +210,22 @@ Stylesheets/Hint: To jest wyrenderowany CSS obecnych tiddlerów otagowanych jako Stylesheets/Restore/Caption: Przywróć Theme/Caption: Motyw Theme/Prompt: Obecny motyw: -TiddlerFields/Caption: Pola Tiddlerów +TiddlerFields/Caption: Pola tiddlerów TiddlerFields/Hint: To jest pełna lista wszystich pól użytych w tej wiki (wliczając systemowe tiddlery ale nie tiddlery-cienie) -TiddlerColour/Caption: Kolor Tiddlera +TiddlerColour/Caption: Kolor tiddlera TiddlerColour/Hint: Ta kaskada określa kolor używany do wyswietlania tiddlera (kolor ikony oraz taga). -TiddlerIcon/Caption: Ikona Tiddlera -TiddlerIcon/Hint: Ta kaskada określa ikonę używaną przez Tiddlera. +TiddlerIcon/Caption: Ikona tiddlera +TiddlerIcon/Hint: Ta kaskada określa ikonę używaną przez tiddlera. Toolbars/Caption: Paski Narzędzi -Toolbars/EditToolbar/Caption: Edytuj Pasek Narzędzi -Toolbars/EditToolbar/Hint: Wybierz, które przyciski mają być widoczne podczas edycji tiddlera. Przeciągaj by zmieniać kolejność. +Toolbars/EditToolbar/Caption: Pasek narzędzi przy edycji tiddlera +Toolbars/EditToolbar/Hint: Wybierz, które przyciski mają być widoczne na górze okna edycji tiddlera. Możesz zmienić ich kolejnośc przeciągając wiersze. Toolbars/Hint: Wybierz, które przyciski mają być widoczne. -Toolbars/PageControls/Caption: Pasek Narzędzi Strony -Toolbars/PageControls/Hint: Wybierz, które przyciski mają być widoczne w głónym pasku narzędzi. Przeciągaj by zmieniać kolejność. -Toolbars/EditorToolbar/Caption: Pasek Narzędzi edytora -Toolbars/EditorToolbar/Hint: Wybierz które przyciski mają być widoczne w pasku narzędzi edytora. Pamiętaj, że tylko niektóre z nich są wyświetlane przy róznych typach tiddlerów. Przeciągaj by zmieniać kolejność -Toolbars/ViewToolbar/Caption: Pasek Narzędzi Oglądania -Toolbars/ViewToolbar/Hint: Wybierz które przyciski są widoczne podczas oglądania tiddlera. Przeciągaj by zmieniać kolejność. +Toolbars/PageControls/Caption: Pasek narzędzi strony +Toolbars/PageControls/Hint: Wybierz, które przyciski mają być widoczne w głównym pasku narzędzi w menu bocznym. Możesz zmienić ich kolejnośc przeciągając wiersze. +Toolbars/EditorToolbar/Caption: Pasek narzędzi edytora treści +Toolbars/EditorToolbar/Hint: Wybierz które przyciski mają być widoczne w pasku narzędzi edytora treści tiddlera. Zależnie od typu edytowanego Tiddlera niektóre z nich mogą być niedostępne. Możesz zmienić ich kolejnośc przeciągając wiersze. +Toolbars/ViewToolbar/Caption: Pasek narzędzi wyświetlania +Toolbars/ViewToolbar/Hint: Wybierz które przyciski są widoczne obok tytułu podczas wyświetlania tiddlera. Możesz zmienić ich kolejnośc przeciągając wiersze. Tools/Download/Full/Caption: Pobierz całą wiki. ViewTemplateBody/Caption: Treść Wyświetlanego Tiddlera ViewTemplateBody/Hint: Ta kaskada określa szablon wyświetlania treści tiddlera (czyli jego tekstu, w przeciwieństwie do kaskady 'Widok Tiddlera'). diff --git a/languages/pl-PL/ThemeTweaks.multids b/languages/pl-PL/ThemeTweaks.multids index f3b12f8da..ab30752f9 100644 --- a/languages/pl-PL/ThemeTweaks.multids +++ b/languages/pl-PL/ThemeTweaks.multids @@ -6,9 +6,9 @@ Options: Opcje Options/SidebarLayout: Układ menu bocznego Options/SidebarLayout/Fixed-Fluid: Stałe Story River, zmienne menu boczne Options/SidebarLayout/Fluid-Fixed: Zmienne Story River, stałe menu boczne -Options/StickyTitles: Przyczep nazwy -Options/StickyTitles/Hint: Spowoduje, że nazwa tiddlera będzie "przyklejona" do górnej części okna przeglądarki -Options/CodeWrapping: Łam długie linie kodu do nowej linii +Options/StickyTitles: Przyklej tytuł i pasek narzędzi +Options/StickyTitles/Hint: Tytuł obecnego tiddlera oraz jego pasek narzędzi będzie przyklejony do góry okna przeglądarki +Options/CodeWrapping: Łam długie linie kodu Settings: Ustawienia Settings/FontFamily: Czcionka Settings/CodeFontFamily: Czcionka kodu From 6955f14c3ce41eb6ce93fb2df626a43d9e0e56c5 Mon Sep 17 00:00:00 2001 From: Maurycy Zarzycki Date: Sun, 20 Nov 2022 18:26:14 +0100 Subject: [PATCH 5/9] add a hidden config to disable Syncer logging to the console (#7049) --- core/modules/startup/startup.js | 6 +++++- .../hiddensettings/Hidden Setting SyncLogging.tid | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 editions/tw5.com/tiddlers/hiddensettings/Hidden Setting SyncLogging.tid diff --git a/core/modules/startup/startup.js b/core/modules/startup/startup.js index f681b71d1..e0990228f 100755 --- a/core/modules/startup/startup.js +++ b/core/modules/startup/startup.js @@ -121,7 +121,11 @@ exports.startup = function() { }); // Set up the syncer object if we've got a syncadaptor if($tw.syncadaptor) { - $tw.syncer = new $tw.Syncer({wiki: $tw.wiki, syncadaptor: $tw.syncadaptor}); + $tw.syncer = new $tw.Syncer({ + wiki: $tw.wiki, + syncadaptor: $tw.syncadaptor, + logging: $tw.wiki.getTiddlerText('$:/config/SyncLogging', "yes") === "yes" + }); } // Setup the saver handler $tw.saverHandler = new $tw.SaverHandler({ diff --git a/editions/tw5.com/tiddlers/hiddensettings/Hidden Setting SyncLogging.tid b/editions/tw5.com/tiddlers/hiddensettings/Hidden Setting SyncLogging.tid new file mode 100644 index 000000000..558cc2bf5 --- /dev/null +++ b/editions/tw5.com/tiddlers/hiddensettings/Hidden Setting SyncLogging.tid @@ -0,0 +1,13 @@ +created: 20190903192324700 +modified: 20190903192324700 +tags: [[Hidden Settings]] +title: Hidden Setting: Sync Logging +type: text/vnd.tiddlywiki + +Specifies whether [[Syncadaptor|https://tiddlywiki.com/dev/#Syncadaptor]] should log information to the browser's developer console or not. + +Defaults to `yes`. Set to `no` to disable logging. + +Changing needs restart to take effect. + +$:/config/SyncLogging From b8a30091eee4df58aae199b28e4df33e2969aa95 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Sun, 20 Nov 2022 18:48:10 +0100 Subject: [PATCH 6/9] add table utility classes and some docs how to use them. fix problem with control-panel basics tab shown in story river (#7039) --- core/ui/ControlPanel/Basics.tid | 5 +- ...Tables in WikiText CSS Utility Classes.tid | 81 +++++++++++++++++++ .../definitions/HTML Block Elements.tid | 9 +++ ...e Classes Captions Headers and Footers.tid | 20 +++++ .../tiddlers/wikitext/Tables in WikiText.tid | 16 +--- .../tiddlers/wikitext/Utility Classes.tid | 20 +++++ themes/tiddlywiki/vanilla/base.tid | 27 ++++++- 7 files changed, 162 insertions(+), 16 deletions(-) create mode 100644 editions/tw5.com/tiddlers/Tables in WikiText CSS Utility Classes.tid create mode 100644 editions/tw5.com/tiddlers/definitions/HTML Block Elements.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/Table Classes Captions Headers and Footers.tid create mode 100644 editions/tw5.com/tiddlers/wikitext/Utility Classes.tid diff --git a/core/ui/ControlPanel/Basics.tid b/core/ui/ControlPanel/Basics.tid index 46df7e77c..dd5580ad5 100644 --- a/core/ui/ControlPanel/Basics.tid +++ b/core/ui/ControlPanel/Basics.tid @@ -20,15 +20,16 @@ caption: {{$:/language/ControlPanel/Basics/Caption}} \end \whitespace trim +|tc-max-width tc-edit-max-width|k |<> |''<>'' | |<$link to="$:/SiteTitle"><> |<$edit-text tiddler="$:/SiteTitle" default="" tag="input"/> | |<$link to="$:/SiteSubtitle"><> |<$edit-text tiddler="$:/SiteSubtitle" default="" tag="input"/> | |<$link to="$:/status/UserName"><> |<$edit-text tiddler="$:/status/UserName" default="" tag="input"/> | |<$link to="$:/config/AnimationDuration"><> |<$edit-text tiddler="$:/config/AnimationDuration" default="" tag="input"/> | -|<$link to="$:/DefaultTiddlers"><> |<>
<$edit tag="textarea" tiddler="$:/DefaultTiddlers" class="tc-edit-texteditor"/>
//<>// | +|<$link to="$:/DefaultTiddlers"><> |<>
<$edit class="tc-edit-texteditor" tiddler="$:/DefaultTiddlers"/>
//<>// | |<$link to="$:/language/DefaultNewTiddlerTitle"><> |<$edit-text tiddler="$:/language/DefaultNewTiddlerTitle" default="" tag="input"/> | |<$link to="$:/config/NewJournal/Title"><> |<$edit-text tiddler="$:/config/NewJournal/Title" default="" tag="input"/> | -|<$link to="$:/config/NewJournal/Text"><> |<$edit tiddler="$:/config/NewJournal/Text" tag="textarea" class="tc-edit-texteditor" default=""/> | +|<$link to="$:/config/NewJournal/Text"><> |<$edit tiddler="$:/config/NewJournal/Text" class="tc-edit-texteditor" default=""/> | |<$link to="$:/config/NewTiddler/Tags"><> |<$vars currentTiddler="$:/config/NewTiddler/Tags" tagField="text">{{||$:/core/ui/EditTemplate/tags}}<$list filter="[tags[]] +[limit[1]]" variable="ignore"><$button tooltip={{$:/language/ControlPanel/Basics/RemoveTags/Hint}}><><$action-listops $tiddler=<> $field="text" $subfilter={{{ [get[tags]] }}}/><$action-setfield $tiddler=<> tags=""/> | |<$link to="$:/config/NewJournal/Tags"><> |<$vars currentTiddler="$:/config/NewJournal/Tags" tagField="text">{{||$:/core/ui/EditTemplate/tags}}<$list filter="[tags[]] +[limit[1]]" variable="ignore"><$button tooltip={{$:/language/ControlPanel/Basics/RemoveTags/Hint}}><><$action-listops $tiddler=<> $field="text" $subfilter={{{ [get[tags]] }}}/><$action-setfield $tiddler=<> tags=""/> | |<$link to="$:/config/AutoFocus"><> |{{$:/snippets/minifocusswitcher}} | diff --git a/editions/tw5.com/tiddlers/Tables in WikiText CSS Utility Classes.tid b/editions/tw5.com/tiddlers/Tables in WikiText CSS Utility Classes.tid new file mode 100644 index 000000000..14abc1c86 --- /dev/null +++ b/editions/tw5.com/tiddlers/Tables in WikiText CSS Utility Classes.tid @@ -0,0 +1,81 @@ +created: 20220817153236691 +modified: 20221010074314452 +tags: [[Tables in WikiText]] +title: Tables in WikiText CSS Utility Classes +type: text/vnd.tiddlywiki + +~WikiText tables can be styled by applying CSS classes. For basic information on wiktext tables and how to style them, see [[Tables in WikiText]]. + +{{Table Classes, Captions, Headers and Footers}} + +As seen above, the resulting table is left aligned and grows to fit the content. This is the browser default layout behaviour for tables. To get another behaviour, various CSS classes can be added into the "`k` row". + +! Utility Classes + +{{Utility Classes}} + +! Examples + +The following examples apply the style classes to tables but the "General Utility Classes" can as well be used on DIVs or other [[HTML block elements|HTML Block Elements]] + +!! Centred Table + +To center a table horizontally, use `tc-center`: + +<> + +!! Centred Table, 80% Width + +To add empty left and right margins to a table that is otherwise full-tiddler-width, you can use `tc-max-width-80` + +<> | +|<<.lorem>> |Cell4 | +|Header|Header|h +""">> + +!! Table with Maximum Width + +To expand a table to full tiddler width, use `tc-max-width` + +<> + +!! Table with First Column Minimum Width + +The following example shows a simple "form" where the first columns width is adjusted to its content by means of `tc-first-col-min-width` + +< | +|Cell3 |<$edit-text tiddler="$:/temp/test-table-input" field="text"/> | +""">> + +!! Table with Maximum Width ~TextWidgets + +Here, the previous "form" is styled further to give the [[TextWidget]]s full width by adding the class `tc-edit-max-width` + +< | +|Cell3 |<$edit-text tiddler="$:/temp/test-table-input" field="text"/> | +""">> + +!! Table with No Borders + +The following is a table with maximum width. It contains [[TextWidget]]s with maximum width. The first column is set to be minimum width. Further, all links in the first column are set to __not__ line break (wrap) regardless of window resize. + +< | +|^ [[Link to a tiddler]]
some more text|<$edit-text tiddler="$:/temp/test-table-input" field="text"/> | +""">> diff --git a/editions/tw5.com/tiddlers/definitions/HTML Block Elements.tid b/editions/tw5.com/tiddlers/definitions/HTML Block Elements.tid new file mode 100644 index 000000000..373ce9b45 --- /dev/null +++ b/editions/tw5.com/tiddlers/definitions/HTML Block Elements.tid @@ -0,0 +1,9 @@ +created: 20220818091959523 +modified: 20220818092101307 +tags: Definitions +title: HTML Block Elements +type: text/vnd.tiddlywiki + +<<< +HTML (Hypertext Markup Language) elements historically were categorized as either "block-level" elements or "inline-level" elements. Since this is a presentational characteristic it is nowadays specified by CSS in the Flow Layout. A Block-level element occupies the entire horizontal space of its parent element (container), and vertical space equal to the height of its contents, thereby creating a "block". +<<< https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements diff --git a/editions/tw5.com/tiddlers/wikitext/Table Classes Captions Headers and Footers.tid b/editions/tw5.com/tiddlers/wikitext/Table Classes Captions Headers and Footers.tid new file mode 100644 index 000000000..9e09827a2 --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/Table Classes Captions Headers and Footers.tid @@ -0,0 +1,20 @@ +created: 20220819100636227 +modified: 20220819101309072 +tags: [[Tables in WikiText]] +title: Table Classes, Captions, Headers and Footers +type: text/vnd.tiddlywiki + +Table CSS classes, captions, headers and footers can be specified as special pseudo-rows. The following example: + +* `|myclass anotherClass|k` assigns the CSS classes "myclass" and "anotherClass" to the table +* `|This is a caption |c` gives the table the caption "This is a caption" +* `|Header|Header|h` adds a header row of cells with the text "Header" +* `|Footer|Footer|f` adds a footer row of cells with the text "Footer" + +<> diff --git a/editions/tw5.com/tiddlers/wikitext/Tables in WikiText.tid b/editions/tw5.com/tiddlers/wikitext/Tables in WikiText.tid index 9c1d83ed4..c7af206d7 100644 --- a/editions/tw5.com/tiddlers/wikitext/Tables in WikiText.tid +++ b/editions/tw5.com/tiddlers/wikitext/Tables in WikiText.tid @@ -1,6 +1,6 @@ caption: Tables created: 20130914132100000 -modified: 20220513115945053 +modified: 20220819103416274 tags: WikiText title: Tables in WikiText type: text/vnd.tiddlywiki @@ -66,17 +66,7 @@ To merge a table cell with the one above, use the special cell text `~`. To merg ! Table Classes, Captions, Headers and Footers -Table CSS classes, captions, headers and footers can be specified as special pseudo-rows. The following example: +{{Table Classes, Captions, Headers and Footers}} -* assigns the CSS classes "myclass" and "anotherClass" to the table -* gives the table the caption "This is a caption" -* adds a header row of cells with the text "Header" -* adds a footer row of cells with the text "Footer" -<> +More examples can be found at: [[Tables in WikiText CSS Utility Classes]] diff --git a/editions/tw5.com/tiddlers/wikitext/Utility Classes.tid b/editions/tw5.com/tiddlers/wikitext/Utility Classes.tid new file mode 100644 index 000000000..4a291e34b --- /dev/null +++ b/editions/tw5.com/tiddlers/wikitext/Utility Classes.tid @@ -0,0 +1,20 @@ +created: 20220818093624828 +modified: 20221010074235929 +tags: WikiText +title: Utility Classes +type: text/vnd.tiddlywiki + +<<.from-version "5.2.4">> The following outlines a few predefined CSS classes intended to make it simpler to style [[HTML block-elements|HTML Block Elements]] and [[wikitext tables|Tables in WikiText CSS Utility Classes]]. + +!! General Utility Classes + +|`tc-center` |Centres a block-element to the middle of the container | +|`tc-max-width `|Expands a block-element to use the maximum width of the container | +|`tc-max-width-80`|Sets the width of a block-element to use 80% of the maximum container width. This setting is useful with the `tc-center` class | +|`tc-edit-max-width `|Expands [[TextWidget]]s to use the maximum available width. See [[ControlPanel -> Info -> Basics|$:/core/ui/ControlPanel/Basics]]| +|`tc-first-link-nowrap` |Ensures that any links in the first table column will never wrap to the next line | + +!! Table Utility Classes + +|`tc-table-no-border` |Removes the borders of a table | +|`tc-first-col-min-width` |The first column of a table will take up minimal possible width. It adapts to the content | diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 17d3ebb39..e9faee67b 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -326,7 +326,7 @@ table { } table th, table td { - padding: 0 7px 0 7px; + padding: 4px 6px 4px 6px; border-top: 1px solid <>; border-left: 1px solid <>; } @@ -357,11 +357,36 @@ Table utility classes width: 1%; } +/* +** Utility classes work well with tables but also for other containers +*/ + /* First link A element will not wrap */ .tc-first-link-nowrap:first-of-type a { white-space: nowrap; } +/* Move the table to the center of the container */ +.tc-center { + margin-left: auto; + margin-right: auto; +} + +.tc-max-width { + width: 100%; +} + +.tc-max-width-80 { + max-width: 80%; +} + +/* Allow input and textarea to look like the ControlPanel inputs */ +.tc-edit-max-width input, +.tc-edit-max-width textarea { + width: 100%; + padding: 3px; +} + /* CSV parser plugin */ From 4f7b10e0550150b5099d587b9dc3aa551d6d02eb Mon Sep 17 00:00:00 2001 From: Maurycy Zarzycki Date: Sun, 20 Nov 2022 18:51:01 +0100 Subject: [PATCH 7/9] CSV parser improvements (#7042) --- core/modules/parsers/csvparser.js | 42 +-- core/modules/utils/csv.js | 124 ++++++-- .../test/tiddlers/tests/data/csv-cases.tid | 282 ++++++++++++++++++ .../tiddlers/tests/modules/utils/test-csv.js | 33 ++ themes/tiddlywiki/vanilla/base.tid | 5 + 5 files changed, 446 insertions(+), 40 deletions(-) create mode 100644 editions/test/tiddlers/tests/data/csv-cases.tid create mode 100644 editions/test/tiddlers/tests/modules/utils/test-csv.js diff --git a/core/modules/parsers/csvparser.js b/core/modules/parsers/csvparser.js index 0e6c9f7bc..40431d0ae 100644 --- a/core/modules/parsers/csvparser.js +++ b/core/modules/parsers/csvparser.js @@ -13,6 +13,11 @@ The CSV text parser processes CSV files into a table wrapped in a scrollable wid "use strict"; var CsvParser = function(type,text,options) { + // Special handler for tab-delimited files + if (type === 'text/tab-delimited-values' && !options.separator) { + options.separator = "\t"; + } + // Table framework this.tree = [{ "type": "scrollable", "children": [{ @@ -24,30 +29,33 @@ var CsvParser = function(type,text,options) { }] }]; // Split the text into lines - var lines = text.split(/\r?\n/mg), + var lines = $tw.utils.parseCsvString(text, options), tag = "th"; + var maxColumns = 0; + $tw.utils.each(lines, function(columns) { + maxColumns = Math.max(columns.length, maxColumns); + }); + for(var line=0; line Comma -> Text", + "options": {}, + "csv": "A,B\r\n,C", + "json": [ + ["A", "B"], + ["", "C"] + ], + "jsonWithHeaders": [ + {"A": "", "B": "C"} + ] + }, + { + "name": "Edge case - single comma", + "options": {}, + "csv": ",", + "json": [ + ["", ""] + ], + "jsonWithHeaders": [] + }, + { + "@comment": "The behavior here is undefined - the only thing that matters is it should not throw an exception, the result is free to make no sense.", + "name": "Edge case - quote separator", + "options": {"separator": "\""}, + "csv": "cell-11,\"cell-12\",cell-13\r\n\"cell-21\",cell-22,cell-23\r\ncell-31,cell-32,\"cell-33\"", + "json": [ + ["cell-11,", "cell-12", ",cell-13"], + ["cell-21", "cell-22,cell-23"], + ["cell-31,cell-32,", "cell-33", ""] + ], + "jsonWithHeaders": [ + {"cell-11,": "cell-21", "cell-12": "cell-22,cell-23", ",cell-13": ""}, + {"cell-11,": "cell-31,cell-32,", "cell-12": "cell-33", ",cell-13": ""} + ] + }, + { + "@comment": "The behavior here is undefined - the only thing that matters is it should not throw an exception, the result is free to make no sense.", + "name": "Edge case - carriage return separator", + "options": {"separator": "\r"}, + "csv": "cell-11,\"cell-12\",cell-13\r\n\"cell-21\",cell-22,cell-23\r\ncell-31,cell-32,\"cell-33\"", + "json": [ + ["cell-11,\"cell-12\",cell-13"], + ["cell-21", "cell-22,cell-23"], + ["cell-31,cell-32,\"cell-33\""] + ], + "jsonWithHeaders": [ + {"cell-11,\"cell-12\",cell-13": "cell-21" }, + {"cell-11,\"cell-12\",cell-13": "cell-31,cell-32,\"cell-33\""} + ] + }, + { + "@comment": "The behavior here is undefined - the only thing that matters is it should not throw an exception, the result is free to make no sense.", + "name": "Edge case - newline separator", + "options": {"separator": "\n"}, + "csv": "cell-11,\"cell-12\",cell-13\r\n\"cell-21\",cell-22,cell-23\r\ncell-31,cell-32,\"cell-33\"", + "json": [ + ["cell-11,\"cell-12\",cell-13"], + ["cell-21", "cell-22,cell-23"], + ["cell-31,cell-32,\"cell-33\""] + ], + "jsonWithHeaders": [ + {"cell-11,\"cell-12\",cell-13": "cell-21" }, + {"cell-11,\"cell-12\",cell-13": "cell-31,cell-32,\"cell-33\""} + ] + } +] \ No newline at end of file diff --git a/editions/test/tiddlers/tests/modules/utils/test-csv.js b/editions/test/tiddlers/tests/modules/utils/test-csv.js new file mode 100644 index 000000000..b53e9b289 --- /dev/null +++ b/editions/test/tiddlers/tests/modules/utils/test-csv.js @@ -0,0 +1,33 @@ +/*\ +title: modules/utils/test-csv.js +type: application/javascript +tags: [[$:/tags/test-spec]] + +Tests the backlinks mechanism. + +\*/ +(function(){ +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +describe('CSV Parsing', function() { + var tid = $tw.wiki.getTiddler('csv-cases'); + var testCases = JSON.parse(tid.fields.text); + + $tw.utils.each(testCases, function(testCase) { + if (testCase.skip) { + return; + } + it("Test case: " + testCase.name, function() { + var parsedCsv = $tw.utils.parseCsvString(testCase.csv, testCase.options); + expect(parsedCsv).withContext("The generated CSV should match the expected one").toEqual(testCase.json); + + var parsedCsvWithHeaders = $tw.utils.parseCsvStringWithHeader(testCase.csv, testCase.options); + expect(parsedCsvWithHeaders).withContext("The generated CSV with headers should match the expected one").toEqual(testCase.jsonWithHeaders); + }); + }) + +}); + +})(); diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index e9faee67b..6ff10e040 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -395,6 +395,11 @@ CSV parser plugin white-space: nowrap; } +.tc-csv-table th, +.tc-csv-table td { + white-space: pre-line; +} + /* Tiddler frame in story river */ From 8ead7e0624c839798a57afaa8c2aa6397b1c0749 Mon Sep 17 00:00:00 2001 From: Cameron Fischer Date: Sun, 20 Nov 2022 12:54:18 -0500 Subject: [PATCH 8/9] Jasmine command (#6944) --- bin/test.sh | 1 + editions/test/tiddlywiki.info | 3 +- plugins/tiddlywiki/jasmine/command.js | 33 ++++++++++++++++ plugins/tiddlywiki/jasmine/help.tid | 24 ++++++++++++ plugins/tiddlywiki/jasmine/jasmine-plugin.js | 40 +++++++++++--------- plugins/tiddlywiki/jasmine/readme.tid | 32 +++++++++++++++- plugins/tiddlywiki/jasmine/startup.js | 37 ++++++++++++++++++ 7 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 plugins/tiddlywiki/jasmine/command.js create mode 100644 plugins/tiddlywiki/jasmine/help.tid create mode 100644 plugins/tiddlywiki/jasmine/startup.js diff --git a/bin/test.sh b/bin/test.sh index 2de66b1fd..61c7b7143 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -9,6 +9,7 @@ node ./tiddlywiki.js \ --verbose \ --version \ --rendertiddler $:/core/save/all test.html text/plain \ + --test \ || exit 1 echo To run the tests in a browser, open "editions/test/output/test.html" diff --git a/editions/test/tiddlywiki.info b/editions/test/tiddlywiki.info index c53b289ce..afb9c0514 100644 --- a/editions/test/tiddlywiki.info +++ b/editions/test/tiddlywiki.info @@ -9,6 +9,7 @@ ], "build": { "index": [ - "--rendertiddler","$:/core/save/all","test.html","text/plain"] + "--rendertiddler","$:/core/save/all","test.html","text/plain", + "--test"] } } \ No newline at end of file diff --git a/plugins/tiddlywiki/jasmine/command.js b/plugins/tiddlywiki/jasmine/command.js new file mode 100644 index 000000000..fe7e62334 --- /dev/null +++ b/plugins/tiddlywiki/jasmine/command.js @@ -0,0 +1,33 @@ +/*\ +title: $:/plugins/tiddlywiki/jasmine/command.js +type: application/javascript +module-type: command + +The command which executes jasmine on the command line for TiddlyWiki5 + +\*/ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var jasmine = require("./jasmine-plugin.js"); + +exports.info = { + name: "test", + synchronous: false, + namedParameterMode: true +}; + +var Command = function(params,commander,callback) { + this.params = params; + this.commander = commander; + this.callback = callback; +}; + +Command.prototype.execute = function() { + var specFilter = this.params.spec; + jasmine.runTests(this.callback,specFilter); +}; + +exports.Command = Command; diff --git a/plugins/tiddlywiki/jasmine/help.tid b/plugins/tiddlywiki/jasmine/help.tid new file mode 100644 index 000000000..a0580741b --- /dev/null +++ b/plugins/tiddlywiki/jasmine/help.tid @@ -0,0 +1,24 @@ +title: $:/language/Help/test +description: Run the jasmine test suite + +This runs all of the tests in tiddlers tagged with `$:/tags/test-spec`. + +``` +--test [spec=] +``` + +''spec'' - optional regular expression to run only specific suites or tests. It will be matched against the full name of every test to see whether to run it. The full name of a test is its assigned name prepended with the names of all containing suites. For instance, to run only the following test: + +``` +describe("Framework") { it("handles edgecases") { ... } } +``` + +You might use a specFilter like `"^Framework handles edgecases$"` to match the full name exactly, or more simply `"edgecases"`, though this might run other tests with "edgecases" in their name. You could also run all tests in that suite with `"^Framework"`. + +If any tests fail or are skipped, all following commands are ignored. If you have any commands which must be executed regardless of test results, execute them first. + +A common usage is to run the tests on the console after creating a Tiddlywiki file which will run the tests on the browser. + +``` +tiddlywiki --rendertiddler $:/core/save/all test.html text/plain --test +``` diff --git a/plugins/tiddlywiki/jasmine/jasmine-plugin.js b/plugins/tiddlywiki/jasmine/jasmine-plugin.js index 3377ebfbd..3ec7998a2 100644 --- a/plugins/tiddlywiki/jasmine/jasmine-plugin.js +++ b/plugins/tiddlywiki/jasmine/jasmine-plugin.js @@ -1,7 +1,7 @@ /*\ title: $:/plugins/tiddlywiki/jasmine/jasmine-plugin.js type: application/javascript -module-type: startup +module-type: library The main module of the Jasmine test plugin for TiddlyWiki5 @@ -13,19 +13,14 @@ The main module of the Jasmine test plugin for TiddlyWiki5 "use strict"; var TEST_TIDDLER_FILTER = "[all[tiddlers+shadows]type[application/javascript]tag[$:/tags/test-spec]]"; +var TESTS_DONE = false; -exports.name = "jasmine"; -// Ensure this startup module is executed in the right order. -// In Node.js, Jasmine calls `process.exit()` with a non-zero exit code if there's -// any failed tests. Because of that, we want to make sure all critical -// startup modules are run before this one. -// * The "commands" module handles the --rendertiddler command-line flag, -// which is typically given in order to export an HTML file that can be opened with -// a browser to run tests. -exports.after = $tw.node ? ["commands"] : []; +exports.testsWereRun = function() { + return TESTS_DONE; +}; /* -Startup function for running tests +function for running tests Below, paths like jasmine-core/jasmine.js refer to files in the 'jasmine-core' npm package, whose repository is https://github.com/jasmine/jasmine. @@ -34,7 +29,8 @@ repository is https://github.com/jasmine/jasmine-npm. They're all locally checked into the `./files` directory. */ -exports.startup = function() { + +exports.runTests = function(callback,specFilter) { // Set up a shared context object. var context = { console: console, @@ -63,6 +59,10 @@ exports.startup = function() { // is executed, so we use the `context` object instead. context.global = $tw.browser ? window : context; + // We set this early rather than at the end for simplicity. The browser + // and node.js environments don't end the same way. + TESTS_DONE = true; + function evalInContext(title) { var code = $tw.wiki.getTiddlerText(title,""); var _exports = {}; @@ -123,7 +123,15 @@ exports.startup = function() { path: "$:/plugins/tiddlywiki/jasmine/jasmine-core/jasmine-core" }; // 'jasmine/jasmine.js' references `process.exit`, among other properties - context.process = process; + // It will call 'exit' after it's done, which gives us an + // opportunity to resynchronize and finish any following commands. + context.process = Object.create(process); + context.process.exit = function(code) { + // If jasmine's exit code is non-zero, tests failed. Abort any + // further commands. If they're important, they could have come + // before the testing suite. + callback(code ? "Tests failed with code " + code : undefined); + }; var NodeJasmine = evalInContext("$:/plugins/tiddlywiki/jasmine/jasmine/jasmine.js"); nodeJasmineWrapper = new NodeJasmine({jasmineCore: jasmineCore}); @@ -135,13 +143,11 @@ exports.startup = function() { context = $tw.utils.extend({},jasmineInterface,context); // Iterate through all the test modules var tests = $tw.wiki.filterTiddlers(TEST_TIDDLER_FILTER); - $tw.utils.each(tests,function(title) { - evalInContext(title); - }); + $tw.utils.each(tests,evalInContext); // In a browser environment, jasmine-core/boot.js calls `execute()` for us. // In Node.js, we call it manually. if(!$tw.browser) { - nodeJasmineWrapper.execute(); + nodeJasmineWrapper.execute(null,specFilter); } }; diff --git a/plugins/tiddlywiki/jasmine/readme.tid b/plugins/tiddlywiki/jasmine/readme.tid index 3411d3cb0..878a756d3 100644 --- a/plugins/tiddlywiki/jasmine/readme.tid +++ b/plugins/tiddlywiki/jasmine/readme.tid @@ -1,5 +1,35 @@ title: $:/plugins/tiddlywiki/jasmine/readme -This plugin provides a framework for running tests in the browser and under Node.js. It is based on [[Jasmine|https://jasmine.github.io/]] test framework. +This plugin provides a framework for running tests in the browser and under Node.js. It is based on [[Jasmine|https://jasmine.github.io/]] test framework. On Tiddlywiki, it runs tests in all javascript tiddlers tagged with <>. [[Source code|https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/jasmine]] + +!! Usage on Node.js + +On the command line, type `tiddlywiki --test`. + +Alternatively, you can set up a build task for jasmine by including the following in your tiddlywiki.info file: + +``` +{ + ... + "build": { + ... + "test": ["--test"] + } +} +``` + +You could then run tests by typing `tiddlywiki --build test` or just `tiddlywiki --build`. The advantage to this is it allows you to include other commands to run as well. See `tiddlywiki --help test` for more information. + +This will run the tests and produce a test file in your output directory. + +``` + "test": [ + "--test", + "--rendertiddler","$:/core/save/all","test.html","text/plain"] +``` + +!! Usage on a browser + +Once you've constructed a Tiddlywiki file using a command like the one above, you can run the tests simply by opening it. Tests run automatically, and the results will be at the bottom of the window. diff --git a/plugins/tiddlywiki/jasmine/startup.js b/plugins/tiddlywiki/jasmine/startup.js new file mode 100644 index 000000000..46f9ef470 --- /dev/null +++ b/plugins/tiddlywiki/jasmine/startup.js @@ -0,0 +1,37 @@ +/*\ +title: $:/plugins/tiddlywiki/jasmine/startup.js +type: application/javascript +module-type: startup + +The main module of the Jasmine test plugin for TiddlyWiki5 + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: true */ +"use strict"; + +var jasmine = require("./jasmine-plugin.js"); + +exports.name = "jasmine"; + +if($tw.browser) { + // Jasmine is run automatically on the browser, so always add it here. + exports.startup = jasmine.runTests; +} else { + // However, if we're on node.js, the tests are explciitly run with the + // --test command. This didn't used to be the case, so if they're + // not, we'll issue a small notice to cue users in to the change + // BTW, this notice probably won't be needed forever. It was installed + // Sept 2022. If it's been four years, this notice can probably come out. + exports.startup = function() { + if(!jasmine.testsWereRun()) { + process.stdout.write("Jasmine: no \"--test\" command given, so skipping tests\n"); + } + } + // We make this check after the commands are run. + exports.after = ["commands"]; +} + +})(); From d32d559f935f9baaec228b7eb4e0cf9e1c3757d6 Mon Sep 17 00:00:00 2001 From: Maurycy Zarzycki Date: Mon, 21 Nov 2022 17:13:34 +0100 Subject: [PATCH 9/9] Add Timestamp to DateFormat (#7043) * add Timestamp to DateFormat * improve TIMESTAMP documentation --- core/modules/utils/utils.js | 3 +++ editions/test/tiddlers/tests/test-utils.js | 1 + .../tw5.com/tiddlers/features/DateFormat.tid | 26 ++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index bc4774fe1..743061ca7 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -354,6 +354,9 @@ exports.formatDateString = function(date,template) { var result = "", t = template, matches = [ + [/^TIMESTAMP/, function() { + return date.getTime(); + }], [/^0hh12/, function() { return $tw.utils.pad($tw.utils.getHours12(date)); }], diff --git a/editions/test/tiddlers/tests/test-utils.js b/editions/test/tiddlers/tests/test-utils.js index 5ac07f1d7..8b7630a54 100644 --- a/editions/test/tiddlers/tests/test-utils.js +++ b/editions/test/tiddlers/tests/test-utils.js @@ -78,6 +78,7 @@ describe("Utility tests", function() { expect(fds(d,"ddd hh mm ssss")).toBe("Sun 17 41 2828"); expect(fds(d,"MM0DD")).toBe("1109"); expect(fds(d,"MM0\\D\\D")).toBe("110DD"); + expect(fds(d,"TIMESTAMP")).toBe(d.getTime().toString()); const day = d.getUTCDate(); const dayStr = ("" + day).padStart(2, '0'); const hours = d.getUTCHours(); diff --git a/editions/tw5.com/tiddlers/features/DateFormat.tid b/editions/tw5.com/tiddlers/features/DateFormat.tid index ef7bcde98..db6a1f3e4 100644 --- a/editions/tw5.com/tiddlers/features/DateFormat.tid +++ b/editions/tw5.com/tiddlers/features/DateFormat.tid @@ -1,5 +1,5 @@ created: 20140418142957325 -modified: 20210912115121622 +modified: 20221121131150032 tags: Features title: DateFormat type: text/vnd.tiddlywiki @@ -46,6 +46,7 @@ The date string is processed with the following substitutions: |`am` or `pm` |Lower case AM/PM indicator | |`AM` or `PM` |Upper case AM/PM indicator | |`TZD` |Timezone offset | +|`TIMESTAMP` |<<.from-version "5.2.4">> Number of milliseconds since the [[ECMAScript epoch|https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_ecmascript_epoch_and_timestamps]], 1 January 1970. | |`\x` |Used to escape a character that would otherwise have special meaning | |`[UTC]`|Time-shift the represented date to UTC. Must be at very start of format string| @@ -59,3 +60,26 @@ The `{era:BCE||CE}` notation can specify different strings for years that are ne |`DDth MMM YYYY` |16th February 2011 | |`DDth MMM \M\M\M YYYY` |16th February MMM 2011 | |`DDth mmm YYYY 0hh:0mm:0ss` |16th Feb 2011 11:38:42 | + +!! Using `TIMESTAMP` to calculate time difference + +You can calculate the difference between two dates by doing the following: + +# Convert both dates to timestamps +# Subtract the later date from the earlier one -- if you don't know which one is earlier use the <<.olink "abs">> operator to get an absolute value after subtraction +# Divide the resulting number by the number of milliseconds in your chosen interval + +Here is an example of calculating the number of days that passed between creation and last modification of current tiddler: + +* Fields `modified` and `created` contain their respective datetimes in the format `YYYYMMDDHHMMSSmmm` so convert them to timestamps +* `86400000` is the number of milliseconds in a day (1000 * 60 * 60 * 24) + +<$macrocall $name=".example" n="0" eg="""<$let + timestamp-modified={{{ [{!!modified}format:date[TIMESTAMP]] }}} + timestamp-created={{{ [{!!created}format:date[TIMESTAMP]] }}} + difference-days={{{ [subtractdivide[86400000]floor[]] }}}> + +* ''Modified date:'' <$text text={{{ [{!!modified}format:date[YYYY-0MM-0DD]] }}}/> +* ''Created date:'' <$text text={{{ [{!!created}format:date[YYYY-0MM-0DD]] }}}/> +* ''Difference in days:'' <> days +"""/> \ No newline at end of file