OcttKB Cross-Repo Sync (HTML to Raw)

This commit is contained in:
octospacc 2023-04-29 22:45:36 +00:00
parent c28818b7a0
commit f4fbc5a9b5
25 changed files with 336 additions and 27 deletions

View File

@ -0,0 +1,6 @@
created: 20140530174219263
tags: contextPlugin
title: $:/plugins/danielo515/ContextPlugin/Caption
type: text/vnd.tiddlywiki
Context search

View File

@ -0,0 +1,3 @@
.matched{background-color:yellow}
.tw-context {/*border:1px solid;
/*word-break: break-all; word-wrap: break-word*/}

View File

@ -0,0 +1,4 @@
created: 20140529162823729
tags: $:/tags/Stylesheet contextPlugin
title: $:/plugins/danielo515/ContextPlugin/Stylesheet/results
type: text/css

View File

@ -0,0 +1,55 @@
title: $:/plugins/danielo515/ContextPlugin/readme
!Usage
After installing the plugin you will have a new tab in [[$:/AdvancedSearch]] called [[Context Search]]. If you want this functionality in other places you will have to edit the desired tiddler yourself adding the ''context widget''. For more details about using the widget see the section below.
!!Using the widget
The very basic usage of the widget is the following:
```
<$context term="lorem"/>
```
Which will render as:
<$context term="lorem"/>
The widgets will search inside the current tiddler by default. Because that you see the same content twice here. This example is not very useful. Other more meaningful would be:
```
<$list filter="[search{$:/temp/advancedsearch}sort[title]limit[250]]">
{{!!title||$:/core/ui/ListItemTemplate}}
<$context term={{$:/temp/advancedsearch}}/>
</$list>
```
That will search for tiddlers containing the text specified in [[$:/temp/advancedsearch]] and will display a link to the matching tiddlers plus a preview of the matching content. Something very similar is used in [[Context Search]]. Below you can find a complete list of parameters and their default values.
|! parameter |! description | !default |
| term | The term you want to search ||
| searchTerm | An alias for the previous one ||
| tiddler | The tiddler's name to look into | current tiddler |
| length | Number of context characters to show | 50 |
| before | Number of characters before the matched term to show | the value of the length parameter |
| after | Number of characters after the matched term to show | the value of the length parameter |
| maxMatches | maximun number of matched elements to show. Incrementing this can cause several performance issues | 10 |
| element | Node element to create. This element will contain the results of the search. If you want to style it its class is `tw-context` | `<pre>` |
| matchClass | The css class to assign to the matched terms in the results. This is used to highlight the results | matched |
!Customizing the output
There are not many ways to customize the output of this widget. You can specify ''what type of node you want to create'' to wrap the results (div,span...). The default is `<pre>`. This container is created with the class `tw-context` so you can easily apply styles to it. Something similar happens to the ''highlighted'' words. You can specify the name of the class to assign to it and also you can apply styles to that class.
A very basic example of customization could be:
# Create a tiddler, for example [[$/plugins/danielo515/context/css]]
# Paste the following text or any css rule you want: """
<pre>
.matched{background-color:yellow}
.tw-context {
border:1px solid blue;
word-break: break-all; word-wrap: break-word;}
</pre>
"""
# Tag it with `$:/tags/stylesheet`
# Save the tiddler

View File

@ -0,0 +1,8 @@
caption: Context
tags: $:/tags/SearchResults
title: $:/plugins/danielo515/ContextPlugin/visualizer
<$list filter="[!is[system]search{$:/temp/search}sort[title]limit[250]]">
{{!!title||$:/core/ui/ListItemTemplate}}
<$context term={{$:/temp/search}} />
</$list>

View File

@ -0,0 +1,136 @@
/*\\
title: $:/core/modules/widgets/danielo/context-widget.js
type: application/javascript
module-type: widget
Edit-text widget
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var contextWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
contextWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
contextWidget.prototype.render = function(parent,nextSibling) {
// Save the parent dom node
this.parentDomNode = parent;
// Compute our attributes
this.computeAttributes();
// Execute our logic
this.execute();
if(this.term && this.term.length>3){
this.createRegexp();
var matches = this.executeRegexp();
if(matches.length > 0){
this.domNode = this.document.createElement(this.element);
this.domNode.className="tw-context";
this.composeResults( matches ); //this appends to domNode
// Insert element
parent.insertBefore(this.domNode,nextSibling);
this.renderChildren(this.domNode,null);
this.domNodes.push(this.domNode);
}
}
};
/*
Compute the internal state of the widget
*/
contextWidget.prototype.execute = function() {
// Get the parameters from the attributes
this.matchedClass = this.getAttribute("matchClass","matched");
this.tiddler = this.getAttribute( "tiddler",this.getVariable("currentTiddler") );
this.term = this.getAttribute("term",this.getAttribute("searchTerm"));
this.contextLength = this.getAttribute("length",50);
this.before = this.getAttribute("before",this.contextLength);
this.after = this.getAttribute("after",this.contextLength);
this.maxMatches = this.getAttribute("maxMatches",10);
this.element = this.getAttribute("element","pre");
this.makeChildWidgets();
};
/*Create the regular expression*/
contextWidget.prototype.createRegexp = function()
{
var regString = "(\\w+[\\s\\S]{0,#before#})?(#term#)([\\s\\S]{0,#after#}\\w+)?";
var regString = regString.replace("#before#",this.before).replace("#term#", $tw.utils.escapeRegExp(this.term) ) .replace("#after#",this.after);
this.regexp = new RegExp(regString,"ig");
//console.log(regString);
};
/*
execute the regular expresion
*/
contextWidget.prototype.executeRegexp = function()
{
var text = this.wiki.getTiddlerText(this.tiddler), match,results = new Array();
while( (match = this.regexp.exec( text ) ) && (results.length < this.maxMatches) )
{ results.push(match) }
//console.log("matches",results);
return results;
};
/*
compose the results
matches : array of match objects from regular expression execute
*/
contextWidget.prototype.composeResults = function(matches){
var result=[], self=this, node = this.domNode,
dots = textNode("...\n"),
span = matchedNode( this.term );
for(var i=0; i < matches.length; i++){
processMatch( matches[i] );
}
function processMatch(match){
if( match.index !== 0) node.appendChild( dots.cloneNode(true) );
for( var i=1;i<match.length;i++ ) {//match[0] full matched text (all groups together)
if( match[i] ) {
if ( match[i].toLowerCase() == self.term.toLowerCase() )
node.appendChild( match[i] == self.term ? span.cloneNode(true) : matchedNode( match[i] ) )
else
node.appendChild( textNode( match[i]) )
}
}
if( match.index + match[0].length < match.input.length) node.appendChild( dots.cloneNode(true) );
}
function textNode(text){ return self.document.createTextNode(text) }
function matchedNode(text) {
var node = self.document.createElement("span"); node.appendChild( textNode(text) ); node.className = self.matchedClass;
return node }
};
/*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
contextWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.tiddler || changedAttributes.term || changedAttributes.length || changedAttributes.matchedClass) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers);
};
exports.context = contextWidget;
})();

View File

@ -0,0 +1,7 @@
created: 20140418153435777
creator: danielo
modified: 20140530231943517
modifier: danielo
module-type: widget
title: $:/plugins/danielo515/ContextPlugin/widgets/context.js
type: application/javascript

View File

@ -0,0 +1,32 @@
caption: {{$:/plugins/danielo515/ContextPlugin/Caption}}
created: 20140530173407542
tags: $:/tags/AdvancedSearch
title: Context Search
type: text/vnd.tiddlywiki
\define lingo-base() $:/language/Search/
<$linkcatcher to="$:/temp/advancedsearch">
<<lingo Standard/Hint>>
<div class="tw-search"><$edit-text tiddler="$:/temp/advancedsearch" type="search" tag="input"/><$reveal state="$:/temp/advancedsearch" type="nomatch" text=""> <$link to="" class="btn-invisible">{{$:/core/images/close-button}}</$link></$reveal></div>
</$linkcatcher>
<$reveal state="$:/temp/advancedsearch" type="nomatch" text="">
<div class="tw-search-results">
<<lingo Standard/Matches>>
<$list filter="[!is[system]search{$:/temp/advancedsearch}sort[title]limit[250]]">
{{!!title||$:/core/ui/ListItemTemplate}}
<$context term={{$:/temp/advancedsearch}}/>
</$list>
</div>
</$reveal>
<$reveal state="$:/temp/advancedsearch" type="match" text="">
</$reveal>

View File

@ -0,0 +1,13 @@
{
"bag": "default",
"revision": "0",
"version": "2.1.0",
"title": "$:/plugins/danielo515/ContextPlugin",
"source": "https://github.com/danielo515/TW5-contextPlugin",
"plugin-type": "plugin",
"list": "readme",
"description": "Context search - provides visual highlight of search results",
"dependents": "",
"core-version": ">=5.1.0",
"author": "Danielo Rodrigez"
}

View File

@ -1,8 +1,11 @@
created: 20230202225750547 created: 20230202225750547
creator: Octt creator: Octt
modified: 20230413072916135 modified: 20230429224405395
modifier: Octt modifier: Octt
tags: $:/i18n:en tags: $:/i18n:en
title: JSON title: JSON
<<^WikipediaFrame JSON en>> <<^WikipediaFrame JSON en>>
* [[JSON Editor Online|https://jsoneditoronline.org]] + formatter, filterer, querier - <<[ "[[Git|https://github.com/josdejong/jsoneditor]]">>
* [[JMESPath|https://jmespath.org/]] - cross-platform //query language for JSON// - <<[ "[[Git|https://github.com/jmespath]]">>

View File

@ -1,6 +1,6 @@
created: 20221110145611678 created: 20221110145611678
creator: Octt creator: Octt
modified: 20230428191647381 modified: 20230429221017331
modifier: Octt modifier: Octt
tags: Development Internet $:/i18n:en tags: Development Internet $:/i18n:en
title: JavaScript title: JavaScript
@ -10,3 +10,15 @@ title: JavaScript
<<^wikipediaframe JavaScript>> <<^wikipediaframe JavaScript>>
* [[Ecma International TC39|https://tc39.es/]] - Committee maintaining JS specifications * [[Ecma International TC39|https://tc39.es/]] - Committee maintaining JS specifications
!!! ''Resources''
* [[Which equals operator (== vs ===) should be used in JavaScript comparisons?|https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons]] ("Good and bad twins")
** [[In theory === is faster, no type conversion takes place. Practically there's no performance difference.|https://stackoverflow.com/questions/12332855/which-javascript-equality-operator-or-is-faster]]
** [[JavaScript-Equality-Table|https://dorey.github.io/JavaScript-Equality-Table/unified/]] - <<[ "[[Git|https://github.com/dorey/JavaScript-Equality-Table]]">>
!!! ''Tools''
* [[jsPerf|https://jsperf.app/]] - //online JavaScript performance benchmark// - <<[ "[[Git|https://github.com/rd13/jsperf.app]]">>
** Old source code: [[v2|https://github.com/jsperf]], [[v1|https://github.com/mathiasbynens/jsperf.com]]
* [[MeasureThat.net|https://www.measurethat.net/]] - //measure performance of JavaScript code// - <<[ "[[Git|https://github.com/thecoderok/MeasureThat.net]]">>

View File

@ -0,0 +1,20 @@
created: 20230429221135750
creator: Octt
modified: 20230429223626598
modifier: Octt
tags:
title: Newsgroup
<<^wikipediaframe Newsgroup>>
Browse newsgroup archives online:
* [[Google Groups|https://www.google.com/search?q=site%3Agroups.google.com]]
* [[Narkive|https://narkive.com/]]
* [[UsenetArchives.com|https://www.usenetarchives.com/]] - [<<RedditLink r/usenet/comments/in6u06/free_usenet_text_archive_goes_online_300_million/ Info>>]
** [[2.1 Million of the Oldest Internet Posts Are Now Online for Anyone to Read|https://www.vice.com/en/article/pky7km/usenet-archive-utzoo-online]]
Details and downloads of archives
* [[https://wiki.archiveteam.org/index.php/Usenet]]
* [[Usenet|https://archive.org/details/usenet]], [[Giganews|https://archive.org/details/giganews]] (Archive.org)

View File

@ -1,15 +1,15 @@
created: 20230221204801305 created: 20230221204801305
creator: Octt creator: Octt
modified: 20230429191254121 modified: 20230429215115349
modifier: Octt modifier: Octt
tags: tags:
title: Web/Development title: Web/Development
!!! ''Misc'' !!! ''Misc''
* [[web.dev|https://web.dev/]] - //Guidance to build modern web experiences that work on any browser// * [[web.dev|https://web.dev/]] - //Guidance to build modern web experiences that work on any browser// (?)
* [[Go Make Things|https://gomakethings.com/]] - //how to build a simpler, more resilient web// * [[Go Make Things|https://gomakethings.com/]] - //how to build a simpler, more resilient web//
** [[The Vanilla JS Toolkit|https://vanillajstoolkit.com/]] - //tools and snippets for working with JavaScript// ** [[The Vanilla JS Toolkit|https://vanillajstoolkit.com/]] - //tools and snippets for working with JavaScript// (libraries, functions, polyfills, learning)
!!! ''References'' !!! ''References''

View File

@ -1,13 +1,13 @@
created: 20221202225934313 created: 20221202225934313
creator: Octt creator: Octt
modified: 20230215210830921 modified: 20230429221407380
modifier: Octt modifier: Octt
tags: Internet $:/i18n:en tags: Internet $:/i18n:en
title: Wikipedia:en title: Wikipedia
<<MediaWiki Wikipedia en 1>> <<^wikipediaframe Wikipedia>>
It is truly one of the best places to gain general culture from. For anything that is not found on the [[OcttKB]], you should visit Wikipedia! It is truly one of the best places to gain general culture from. For anything that is not found on the [[OcttKB]], you should visit Wikipedia no doubt.
!!! ''Resources'' !!! ''Resources''

View File

@ -1,5 +1,5 @@
created: 20230429192341730 created: 20230429224536166
current-tiddler: GettingStarted current-tiddler: GettingStarted
modified: 20230429192341730 modified: 20230429224536166
title: $:/HistoryList title: $:/HistoryList
type: application/json type: application/json

View File

@ -3,4 +3,4 @@ title: $:/Import
The following tiddlers were imported: The following tiddlers were imported:
# [[$:/Styles/Main]] # [[$:/plugins/danielo515/ContextPlugin]]

View File

@ -1,7 +1,7 @@
Enabled: 1 Enabled: 0
created: 20230413083119554 created: 20230413083119554
creator: Octt creator: Octt
modified: 20230417102138503 modified: 20230429202841556
modifier: Octt modifier: Octt
tags: $:/GlobalOption tags: $:/GlobalOption
title: $:/OcttKB/Config/AiLinks.ui title: $:/OcttKB/Config/AiLinks.ui

View File

@ -1,3 +1,3 @@
created: 19700101000000000 created: 19700101000000000
modified: 20230428191937000 modified: 20230429192506000
title: $:/OcttKB/Empty title: $:/OcttKB/Empty

View File

@ -1,6 +1,6 @@
created: 20230429182908215 created: 20230429201758976
creator: Octt creator: Octt
list: list:
modified: 20230429192120468 modified: 20230429221307042
modifier: Octt modifier: Octt
title: $:/StoryList title: $:/StoryList

View File

@ -1,6 +1,6 @@
created: 20230124112022156 created: 20230124112022156
creator: Octt creator: Octt
modified: 20230413085126714 modified: 20230429202157475
modifier: Octt modifier: Octt
tags: $:/tags/ViewTemplate tags: $:/tags/ViewTemplate
title: $:/Styles/View/9-99-Hacks title: $:/Styles/View/9-99-Hacks
@ -8,6 +8,7 @@ title: $:/Styles/View/9-99-Hacks
\define AiLinks(Enabled:1) \define AiLinks(Enabled:1)
\whitespace trim \whitespace trim
<<script script=" <<script script="
try {
if ('$(Enabled)$' == 1) { if ('$(Enabled)$' == 1) {
var Query = decodeURIComponent('Please summarize the following article into concise key bullet points: ${URL}. Write the points as objective, generalized declarations that stand by themselves. Do not write them as to explain what the author thinks subjectively. Do not leave any point as unclear: each point must not lead the reader to asking any %22why%22; questions. Avoid boilerplate and repetitions.'); var Query = decodeURIComponent('Please summarize the following article into concise key bullet points: ${URL}. Write the points as objective, generalized declarations that stand by themselves. Do not write them as to explain what the author thinks subjectively. Do not leave any point as unclear: each point must not lead the reader to asking any %22why%22; questions. Avoid boilerplate and repetitions.');
@ -23,6 +24,8 @@ if ('$(Enabled)$' == 1) {
}); });
}); });
}; };
} catch(e) { ErrAtLine(e); };
">> ">>
\end \end

View File

@ -0,0 +1,7 @@
created: 20230429202159808
creator: Octt
modified: 20230429202200401
modifier: Octt
title: $:/state/folded/$:/Styles/View/9-99-Hacks
show

View File

@ -1,7 +1,7 @@
created: 20220920140732083 created: 20220920140732083
creator: Octt creator: Octt
modified: 20230429183022361 modified: 20230429221154956
modifier: Octt modifier: Octt
title: $:/state/showeditpreview title: $:/state/showeditpreview
no yes

View File

@ -1,7 +1,7 @@
created: 20220920090405977 created: 20220920090405977
creator: Octt creator: Octt
modified: 20230429191411290 modified: 20230429202855018
modifier: Octt modifier: Octt
title: $:/state/tab-1749438307 title: $:/state/tab-1749438307
$:/core/ui/ControlPanel/Info $:/core/ui/ControlPanel/Plugins

View File

@ -1,7 +1,7 @@
created: 20220920092307479 created: 20220920092307479
creator: Octt creator: Octt
modified: 20230429191920084 modified: 20230429202204521
modifier: Octt modifier: Octt
title: $:/state/tab/sidebar--595412856 title: $:/state/tab/sidebar--595412856
$:/core/ui/SideBar/More $:/core/ui/SideBar/Recent

View File

@ -1,3 +1,3 @@
title: $:/status/RequireReloadDueToPluginChange title: $:/status/RequireReloadDueToPluginChange
no yes