-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
13 changed files
with
459 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# OS X | ||
.DS_Store | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
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,21 @@ | ||
# The MIT License (MIT) | ||
|
||
*Copyright (c) 2015-2016 Shubhro Saha* | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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 OR COPYRIGHT HOLDERS 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. |
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 |
---|---|---|
@@ -1,2 +1,21 @@ | ||
# dickens | ||
The missing notes and highlights manager for Amazon Kindle | ||
|
||
![](img/screenshot.png) | ||
|
||
## Introduction | ||
Dickens loads notes and highlights from your Amazon Kindle, enabling you to easily save them to your computer. The simple application is more convenient than reading 'My Clippings.txt' yourself or uploading it to a web service. Unlike the Amazon Kindle web application, Dickens loads notes and highlights from content not purchased on the Amazon Store as well. | ||
|
||
This application was written with web technologies using the [Electron](http://electron.atom.io/) framework. It has been tested on Mac OS X 10.10.5 (Yosemite) with the 2014 Amazon Wifi Touchscreen Kindle. Binaries are packaged with [Max Ogden's electron-packager](https://github.com/maxogden/electron-packager). | ||
|
||
## Usage | ||
|
||
To run from source: | ||
- `npm install` | ||
- `npm start` | ||
|
||
## License | ||
|
||
Copyright (c) 2015-2016 Shubhro Saha. All rights reserved. | ||
|
||
Dickens is covered by the MIT license, a permissive free software license that lets you do anything you want with the source code, as long as you provide back attribution and "don't hold [me] liable". For the full license text see the [LICENSE.md](LICENSE.md) file. |
Large diffs are not rendered by default.
Oops, something went wrong.
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,46 @@ | ||
|
||
body { | ||
margin:100px; | ||
} | ||
|
||
.navbar { | ||
padding-top:20px; | ||
} | ||
|
||
.list-group-item, .list-group { | ||
list-style:none; | ||
} | ||
|
||
input:focus, select:focus { | ||
outline: none; | ||
border:none; | ||
} | ||
|
||
#diskList { | ||
margin-right:10px; | ||
} | ||
|
||
#titleSearch { | ||
width:100%; | ||
} | ||
|
||
#activeTitle { | ||
font-size:20px; | ||
line-height:1.6em; | ||
font-weight:300; | ||
margin-top:50px; | ||
} | ||
|
||
.note-item { | ||
font-size: 14px; | ||
line-height: 1.6em; | ||
font-weight: 300; | ||
} | ||
|
||
.note-meta { | ||
margin-left: 20px; | ||
text-transform: uppercase; | ||
font-size: 12px; | ||
font-weight: bold; | ||
color: #888; | ||
} |
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,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Dickens</title> | ||
<link href="../css/bootstrap.min.css" rel="stylesheet"></link> | ||
<link href="../css/styles.css" rel="stylesheet"></link> | ||
<script>window.$ = window.jQuery = require('../js/jquery.js');</script> | ||
<script type="text/javascript" src="../js/jquery.hideseek.min.js"></script> | ||
<script type="text/javascript" src="../js/app.js"></script> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="navbar navbar-default navbar-fixed-top"> | ||
<div class="container"> | ||
<select class="btn-sm" id="diskList"></select> | ||
<button class="btn btn-primary btn-sm" id="diskListButton">Load Titles</button> | ||
<button class="btn btn-default btn-sm" id="refreshDiskListButton">Refresh Device List</button> | ||
</div> | ||
</div> | ||
<input id="titleSearch" name="search" placeholder="Search titles" type="text" data-list="#titles" autocomplete="on" /> | ||
<div class="row"> | ||
<div class="col-lg-12"> | ||
<ul class="list-group" id="titles"></ul> | ||
<div id="activeTitle"></div> | ||
<div id="notes"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,223 @@ | ||
|
||
const remote = require('remote'); | ||
const dialog = remote.require('dialog'); | ||
const Menu = remote.Menu; | ||
const MenuItem = remote.MenuItem; | ||
const fs = require('fs'); | ||
const moment = require('moment'); | ||
|
||
/* | ||
GLOBALS, CONSTANTS, CLASSES | ||
*/ | ||
$ = window.$; | ||
titles = {}; // title_hash: Title | ||
|
||
var HIGHLIGHT_TYPE = "Highlight"; | ||
var NOTE_TYPE = "Note"; | ||
|
||
function Title(title_hash, title) { | ||
this.title_hash = title_hash; | ||
this.title = title; | ||
this.notes = []; | ||
} | ||
|
||
function Note(title, type, dt, location, content) { | ||
this.title = title; | ||
this.type = type; | ||
this.dt = dt; | ||
this.location = location; | ||
this.content = content; | ||
} | ||
|
||
/* | ||
HELPER FUNCTIONS | ||
*/ | ||
hashCode = function(str){ | ||
var hash = 0; | ||
if (str.length == 0) return hash; | ||
for (i = 0; i < str.length; i++) { | ||
char = str.charCodeAt(i); | ||
hash = ((hash<<5)-hash)+char; | ||
hash = hash & hash; // Convert to 32bit integer | ||
} | ||
return hash; | ||
} | ||
|
||
function createMenu() { | ||
var template = [{ | ||
label: "Edit", | ||
submenu: [ | ||
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" }, | ||
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" }, | ||
{ type: "separator" }, | ||
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" }, | ||
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" }, | ||
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" }, | ||
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" } | ||
]}]; | ||
|
||
if (process.platform == 'darwin') { | ||
var name = "Dickens"; | ||
template.unshift({ | ||
label: name, | ||
submenu: [ | ||
{ | ||
label: 'Hide ' + name, | ||
accelerator: 'Command+H', | ||
role: 'hide' | ||
}, | ||
{ | ||
label: 'Hide Others', | ||
accelerator: 'Command+Shift+H', | ||
role: 'hideothers' | ||
}, | ||
{ | ||
label: 'Show All', | ||
role: 'unhide' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Quit', | ||
accelerator: 'Command+Q', | ||
click: function() { app.quit(); } | ||
}, | ||
] | ||
}); | ||
} | ||
|
||
menu = Menu.buildFromTemplate(template); | ||
Menu.setApplicationMenu(menu); | ||
} | ||
|
||
function refreshDiskList() { | ||
$("#diskList").empty(); | ||
|
||
fs.readdir("/Volumes", function(err, files) { | ||
for (var i in files) { | ||
var fileName = files[i]; | ||
$("#diskList").append("<option value='/Volumes/"+fileName+"'>/Volumes/"+fileName+"</option>") | ||
} | ||
}); | ||
} | ||
|
||
function processClippings(rawClippingContent) { | ||
var noteSegments = rawClippingContent.split("=========="); | ||
|
||
for (i in noteSegments) { | ||
var noteSegmentLines = noteSegments[i].split("\n"); | ||
|
||
var offset = 0; | ||
if (noteSegmentLines[0].length == 1) { | ||
offset = 1; | ||
} | ||
|
||
try { | ||
var title = noteSegmentLines[offset + 0]; | ||
var meta = noteSegmentLines[offset + 1]; | ||
if (meta.indexOf("Your Bookmark") > -1) { | ||
continue; // don't load bookmarks | ||
} | ||
var type = NOTE_TYPE; | ||
if (meta.indexOf("Your Highlight") > -1) { | ||
type = HIGHLIGHT_TYPE; | ||
} | ||
var location = meta.slice(meta.indexOf("Location")+9, meta.indexOf("| Added")-1); | ||
var dt = moment(meta.split("Added on ")[1]); | ||
var content = noteSegmentLines.slice(offset + 2).join("<br />"); | ||
|
||
note = new Note(title, type, dt, location, content); | ||
|
||
var titleHash = hashCode(title); | ||
|
||
if (!titles[titleHash]) { | ||
titles[titleHash] = new Title(titleHash, title); | ||
} | ||
|
||
titles[titleHash].notes.push(note); | ||
} catch(err) { | ||
console.log("Note parsing warning: "+err); | ||
} | ||
} | ||
} | ||
|
||
function refreshTitleList() { | ||
$("#titles").empty(); | ||
|
||
$.each(titles, function (title_hash, title) { | ||
$("#titles").append("<li><a href='#' class='list-group-item' link-title-hash='"+title_hash+"'>"+title.title+"</a></li>") | ||
}); | ||
|
||
$("#titleSearch").prop("hidden", false); | ||
$("#titleSearch").focus(); | ||
|
||
$("#titleSearch").hideseek({ | ||
}); | ||
} | ||
|
||
function loadTitle(title_hash) { | ||
$("#titles").prop("hidden", true); | ||
$("#notes").empty(); | ||
$("#activeTitle").empty(); | ||
|
||
var activeTitle = titles[title_hash]; | ||
$("#activeTitle").append(activeTitle.title); | ||
|
||
for (i in activeTitle.notes) { | ||
var note = activeTitle.notes[i]; | ||
|
||
console.log(note); | ||
|
||
$("#notes").append( | ||
"<div class='note-item'>"+ | ||
note.content | ||
+"<div class='note-meta'>"+note.type+", Location "+note.location | ||
+"</div></div>" | ||
); | ||
} | ||
} | ||
|
||
/* | ||
MAIN | ||
*/ | ||
|
||
$(document).ready(function(){ | ||
refreshDiskList(); | ||
createMenu(); | ||
|
||
$("#titleSearch").prop("hidden", true); | ||
|
||
$("#diskListButton").on("click", function() { | ||
|
||
var filePath = $("#diskList").val()+"/documents/My Clippings.txt"; | ||
|
||
fs.readFile(filePath, function(err, data) { | ||
if (!err) { | ||
var rawClippingContent = data.toString('utf8'); | ||
processClippings(rawClippingContent); | ||
refreshTitleList(); | ||
} else { | ||
console.log(err); | ||
dialog.showErrorBox( | ||
"Invalid Device", | ||
"Clippings file could not be found or format is invalid." | ||
); | ||
} | ||
}); | ||
}); | ||
|
||
$("#titles").on("click", "li a", function(event) { | ||
var title_hash = $($(this)[0]).attr("link-title-hash"); | ||
loadTitle(title_hash); | ||
}); | ||
|
||
$("#refreshDiskListButton").on("click", function(event) { | ||
refreshDiskList(); | ||
}); | ||
|
||
$("#titleSearch").focusin(function() { | ||
$("#titles").prop("hidden", false); | ||
}); | ||
|
||
}); |
Oops, something went wrong.