Browse Source

add task to generate minified bookmarklet

master
Wesley Kerfoot 4 years ago
parent
commit
84c54f715b
  1. 1
      .gitignore
  2. 8
      README.md
  3. 1
      minified_bookmarklet.js
  4. 5
      twit2blog.nimble

1
.gitignore

@ -1,3 +1,4 @@
.envrc
twit2blog
twit2blog.db
bookmarklet.min.js

8
README.md

@ -1,6 +1,6 @@
### Twit2Blog
A simple tool to help make it easier to generate readable tweets you can browse.
A simple tool to help make it easier to archive readable tweets you can browse. No external server or proprietary SaaS solution needed.
### Building
`nimble build` is all you'll need at this point.
@ -9,11 +9,11 @@ A simple tool to help make it easier to generate readable tweets you can browse.
Requires `TWITTER_CONSUMER_KEY` and `TWITTER_CONSUMER_SECRET`, both of which you can only get if you have a registered developer account and an application created for twitter.
1. Start the server
1. Compile the server with `nimble build` and then start the server like so.
```
./twit2blog
```
2. Install the bookmarklet
2. Install the bookmarklet (run `nimble bookmark` to generate it and then create a bookmark in your browser with it as the location)
3. Go to a twitter thread, click the bookmarklet, it will open up a new page where your thread will eventually be.
3. Go to a twitter thread, click the bookmarklet, it will open up a new page where your thread will eventually be. Wait a bit and come back to your beautifully archived thread!

1
minified_bookmarklet.js

@ -1 +0,0 @@
javascript:(function(){function getLastXPath(xpexp){var iterator=document.evaluate(xpexp,document,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var result=iterator.iterateNext();var lastEl=result;while(result!=null){result=iterator.iterateNext();if(result==null){break}lastEl=result}return lastEl}function getLastTweet(){var author=window.location.pathname.split("/")[1];var xp="//a[contains(@href, '"+author+"/status')]";return getLastXPath(xp).pathname}function queueTweet(){var lastTweet=getLastTweet();var url="http://localhost:8080/thread"+lastTweet;window.open(url,"_blank")}queueTweet()})();

5
twit2blog.nimble

@ -12,3 +12,8 @@ bin = @["twit2blog"]
requires "nim >= 1.0.9"
requires "https://github.com/dom96/jester"
requires "https://github.com/pragmagic/karax"
task bookmark, "Builds the minified bookmarklet":
"bookmarklet.min.js".rmFile
"echo -n 'javascript:' > ./bookmarklet.min.js".exec
"uglifyjs bookmarklet.js >> ./bookmarklet.min.js".exec

Loading…
Cancel
Save