-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9e48a1e
Showing
8 changed files
with
792 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Bookmark Tools | ||
|
||
**bookmarks_scrubber** scrubs out (Firefox JSON) bookmark entries (URLs & folders) with titles that begin with **--** (double dashes). This also makes it easier to visually see them in the Bookmarks Organizers. | ||
|
||
**bookmarks_jstree** will generate the data for the wonderful [jstree](https://www.jstree.com/) of my (Firefox JSON) bookmarks. | ||
|
||
## Quick Start | ||
|
||
**Backup** your (Firefox) bookmarks to JSON file. | ||
* Menu | ||
* Bookmarks | ||
* Show All Bookmarks (CTRL+Shift+O) | ||
* Import and Backup | ||
* Backup... | ||
* Save <bookmarks-yyyy-mm-dd.json> file | ||
|
||
**Scrub** the bookmarks: | ||
```sh | ||
python bookmarks_scrubber.py -s -i bookmarks-yyyy-mm-dd.json -o bookmarks-scrubbed.json | ||
``` | ||
|
||
**Generate** the jstree data json file: | ||
```sh | ||
python bookmarks_jstree.py -i bookmarks-scrubbed.json -o jstree-data.json | ||
``` | ||
|
||
OR -- Pipe the scripts together: | ||
```sh | ||
cat bookmarks-yyyy-mm-dd.json | python bookmarks_scrubber.py -s | python bookmarks_jstree.py > jstree-data.json | ||
``` | ||
|
||
Upload the **jstree-data.json** and **bookmarks_jstree.{php,html}** files up to your webserver. | ||
|
||
#### PHP vs HTML | ||
|
||
These two files are essentially the same. The PHP version will inline the jstree data while the HTML version will fetch it separately. Use whichever version suits your need. | ||
|
||
## Docs | ||
|
||
``` | ||
Usage: | ||
./bookmarks_jstree.py [options] | ||
Options are: | ||
-h, --help | ||
This usage message. | ||
-i filename, --input=filename | ||
Read JSON data from [ filename ] or else, read data from [ stdin ]. | ||
-o filename, --output=filename | ||
Output results to [ filename ] or else, output to [ stdout ]. | ||
Special Note: Titles that start with *** (triple stars) will be displayed in BOLD. | ||
``` | ||
|
||
``` | ||
Usage: | ||
./bookmarks_scrubber.py [options] | ||
Options are: | ||
-h, --help | ||
This usage message. | ||
-i filename, --input=filename | ||
Read JSON data from [ filename ] or else, read data from [ stdin ]. | ||
-o filename, --output=filename | ||
Output results to [ filename ] or else, output to [ stdout ]. | ||
-r title, --root=title | ||
Start root at [title] folder. Note: first match only! | ||
No multiple match warnings will be given. | ||
-s, --scrub | ||
Scrub JSON entries with titles that start with -- (double dashes). | ||
-t title, --scrubtitles=title | ||
Additional FOLDERS (titles) to scrub out. | ||
This can be stacked: --scrubtitle=title1 --scrubtitle=title2 etc. | ||
(Scrubbing individual URLs is left as an exercise.) | ||
``` | ||
|
||
### Example | ||
|
||
Take a look at the following bookmark library example. | ||
|
||
![bookmark library example](http://imgur.com/PzNkZVH.png) | ||
|
||
![bookmark library example](https://github.com/nickshin/bookmark_tools/raw/master/img/example_library.png) | ||
|
||
By just glancing, you will be able to quickly tell which folders and files will be ~~scrubbed out~~ -- as well as which ones will be displayed in **bold**. | ||
|
||
After running the commands shown in the [quick start](#quick-start) section, here is the result of this example. | ||
|
||
![bookmarks online](http://imgur.com/Ek5Yo62.png) | ||
|
||
![bookmarks online](https://github.com/nickshin/bookmark_tools/raw/master/img/example_live.png) | ||
|
||
## Live Demo | ||
|
||
View my latest [bookmarks online](http://nickshin.com/bookmarks.php). | ||
|
||
## Donate | ||
|
||
[![Donate to author](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ETBVU24F5JDC6) | ||
|
||
## License | ||
|
||
[Unlicense](http://unlicense.org/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>My Bookmarks</title> | ||
<link rel="stylesheet" href="//static.jstree.com/3.3.3/assets/bootstrap/css/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="//static.jstree.com/3.3.3/assets/dist/themes/default/style.min.css" /> | ||
<link rel="stylesheet" href="//static.jstree.com/3.3.3/assets/docs.css" /> | ||
|
||
<style> | ||
.demo { | ||
background:white; | ||
border:3px solid gray; | ||
float: left; | ||
width: 200px | ||
} | ||
</style> | ||
|
||
</head> | ||
<body style="height:90%"> | ||
|
||
<h2>My Bookmarks</h2> | ||
<div id="jt_everything" style="display:none"></div> | ||
<div id="leftside"> | ||
<div id="jt_folders" class="demo" style="position:absolute; left:20px; height:75vh"> | ||
<span style="margin-top:36px; display:block; text-align:center;">Loading...</span> | ||
</div> | ||
</div> | ||
<div id="rightside"> | ||
<div class="demo" style="position:absolute; left:250px; height:75vh; width:70%"> | ||
<div id="breadcrumb"></div> | ||
<div id="content" style=" font-family:Verdana !important; font-size:12px !important; "> | ||
This page was created using the wonderful <a href="http://jstree.com/">jsTree</a> library. | ||
<p> | ||
You can find it at <a href="https://jstree.com/">http://jstree.com/</a>. | ||
<p> | ||
Enjoy! ^_^ | ||
<p> | ||
<hr> | ||
<p> | ||
Just in case anyone is interested in knowing how to streamline their JSON bookmarks | ||
to be used with the jsTree library, please visit my | ||
<a href="http://www.estss.com/opensource/bkmkscrub/">Bookmark Scrubber</a> project. | ||
(and of course, view source) | ||
</div> | ||
</div> | ||
</div> | ||
<div id="bottom" class="demo" style="position:absolute; left:250px; bottom:5px; width:70%; height:55px"> | ||
These are the bookmarks from <a href="/">Nick Shin</a>. I hope you may find something interesting while you are here.<br> | ||
</div> | ||
|
||
<script src="ext/jquery/3.1.1/jquery.min.js"></script> | ||
<script src="ext/jstree/3.3.3/jstree.min.js"></script> | ||
<script> | ||
var $jt_everything = null; | ||
var $jt_folders = null; | ||
var $breadcrumb = $("#breadcrumb"); | ||
var $content = null; | ||
// ---------------------------------------- | ||
$.getJSON( "jstree-data.json", function( jstree_data ) { | ||
// ---------------------------------------- | ||
$("#jt_everything").jstree( | ||
{"core":{"data": jstree_data }, | ||
"types":{ | ||
"file":{"icon":"glyphicon glyphicon-leaf"}, | ||
"line":{"icon":"none"} | ||
}, | ||
"plugins":["themes","types"] | ||
}).on("ready.jstree", function() { | ||
$jt_everything = $.jstree.reference("#jt_everything"); | ||
}); | ||
// ---------------------------------------- | ||
function reset_content(data) { | ||
if ( $content ) | ||
$content.destroy(); | ||
$("#content").jstree({"core":{"data": | ||
data | ||
}}).on("ready.jstree", function() { | ||
$content = $.jstree.reference("#content"); | ||
$content.open_all(); | ||
}).on("changed.jstree", function( e, data ) { | ||
var href = data.node.a_attr.href; | ||
if ( href == '#' ) { // folder | ||
$jt_folders.open_node(("" + data.selected).replace(/_\d+$/,"")); | ||
$jt_folders.deselect_all(); | ||
$jt_folders.select_node(data.selected); | ||
} else { // link | ||
window.open(href, "window_" + data.selected); | ||
} | ||
}); | ||
} | ||
// ---------------------------------------- | ||
var folders = []; | ||
jstree_data.forEach(function(e) { | ||
if ( e.type == "folder" ) | ||
folders.push(e); | ||
}); | ||
$("#jt_folders").jstree({"core":{"data": folders}}) | ||
.on("ready.jstree", function() { | ||
$jt_folders = $.jstree.reference("#jt_folders"); | ||
$jt_folders.open_all(); | ||
}).on("changed.jstree", function( e, data ) { | ||
if ( ! data.selected.length ) | ||
return; // deselect_all | ||
// .................... | ||
$breadcrumb.html('<h3>' + $jt_folders.get_path(data.selected, ' -> ') + '</h3><p>' ); | ||
// .................... | ||
var j = $jt_everything.get_json(data.selected); | ||
j.children.forEach(function(e) { | ||
e.children.length = 0; | ||
}); | ||
reset_content(j.children); | ||
}); | ||
// ---------------------------------------- | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>My Bookmarks</title> | ||
<link rel="stylesheet" href="//static.jstree.com/3.3.3/assets/bootstrap/css/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="//static.jstree.com/3.3.3/assets/dist/themes/default/style.min.css" /> | ||
<link rel="stylesheet" href="//static.jstree.com/3.3.3/assets/docs.css" /> | ||
|
||
<style> | ||
.demo { | ||
background:white; | ||
border:3px solid gray; | ||
float: left; | ||
width: 200px | ||
} | ||
</style> | ||
</head> | ||
<body style="height:90%"> | ||
|
||
<h2>My Bookmarks</h2> | ||
<div id="jt_everything" style="display:none"></div> | ||
<div id="leftside"> | ||
<div id="jt_folders" class="demo" style="position:absolute; left:20px; height:75vh"> | ||
<span style="margin-top:36px; display:block; text-align:center;">Loading...</span> | ||
</div> | ||
</div> | ||
<div id="rightside"> | ||
<div class="demo" style="position:absolute; left:250px; height:75vh; width:70%"> | ||
<div id="breadcrumb"></div> | ||
<div id="content" style=" font-family:Verdana !important; font-size:12px !important; "> | ||
This page was created using the wonderful <a href="http://jstree.com/">jsTree</a> library. | ||
<p> | ||
You can find it at <a href="https://jstree.com/">http://jstree.com/</a>. | ||
<p> | ||
Enjoy! ^_^ | ||
<p> | ||
<hr> | ||
<p> | ||
Just in case anyone is interested in knowing how to streamline their JSON bookmarks | ||
to be used with the jsTree library, please visit my | ||
<a href="http://www.estss.com/opensource/bkmkscrub/">Bookmark Scrubber</a> project. | ||
(and of course, view source) | ||
</div> | ||
</div> | ||
</div> | ||
<div id="bottom" class="demo" style="position:absolute; left:250px; bottom:5px; width:70%; height:55px"> | ||
These are the bookmarks from <a href="/">Nick Shin</a>. I hope you may find something interesting while you are here.<br> | ||
Bookmarks last updated at: | ||
<?php | ||
echo date( "F d, Y", filemtime( "jstree-data.json" ) ); | ||
?> | ||
</div> | ||
|
||
<script src="ext/jquery/3.1.1/jquery.min.js"></script> | ||
<script src="ext/jstree/3.3.3/jstree.min.js"></script> | ||
<script> | ||
var $jt_everything = null; | ||
var $jt_folders = null; | ||
var $breadcrumb = $("#breadcrumb"); | ||
var $content = null; | ||
// ---------------------------------------- | ||
var jstree_data = <? include("jstree-data.json"); ?>; | ||
// ---------------------------------------- | ||
$("#jt_everything").jstree( | ||
{"core":{"data": jstree_data }, | ||
"types":{ | ||
"file":{"icon":"glyphicon glyphicon-leaf"}, | ||
"line":{"icon":"none"} | ||
}, | ||
"plugins":["themes","types"] | ||
}).on("ready.jstree", function() { | ||
$jt_everything = $.jstree.reference("#jt_everything"); | ||
}); | ||
// ---------------------------------------- | ||
function reset_content(data) { | ||
if ( $content ) | ||
$content.destroy(); | ||
$("#content").jstree({"core":{"data": | ||
data | ||
}}).on("ready.jstree", function() { | ||
$content = $.jstree.reference("#content"); | ||
$content.open_all(); | ||
}).on("changed.jstree", function( e, data ) { | ||
var href = data.node.a_attr.href; | ||
if ( href == '#' ) { // folder | ||
$jt_folders.open_node(("" + data.selected).replace(/_\d+$/,"")); | ||
$jt_folders.deselect_all(); | ||
$jt_folders.select_node(data.selected); | ||
} else { // link | ||
window.open(href, "window_" + data.selected); | ||
} | ||
}); | ||
} | ||
// ---------------------------------------- | ||
var folders = []; | ||
jstree_data.forEach(function(e) { | ||
if ( e.type == "folder" ) | ||
folders.push(e); | ||
}); | ||
$("#jt_folders").jstree({"core":{"data": folders}}) | ||
.on("ready.jstree", function() { | ||
$jt_folders = $.jstree.reference("#jt_folders"); | ||
$jt_folders.open_all(); | ||
}).on("changed.jstree", function( e, data ) { | ||
if ( ! data.selected.length ) | ||
return; // deselect_all | ||
// .................... | ||
$breadcrumb.html('<h3>' + $jt_folders.get_path(data.selected, ' -> ') + '</h3><p>' ); | ||
// .................... | ||
var j = $jt_everything.get_json(data.selected); | ||
j.children.forEach(function(e) { | ||
e.children.length = 0; | ||
}); | ||
reset_content(j.children); | ||
}); | ||
// ---------------------------------------- | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.