ds300 / jetzt

Speed reader extension for chrome
Other
485 stars 124 forks source link

Using latest code in bookmarklet #142

Closed orschiro closed 8 years ago

orschiro commented 10 years ago

Hi there,

I modified the original bookmarklet to point to the source files in the repo in order to use the recent pull merge.

Original bookmarklet code:

javascript: (function() {var addStyle = function(url) {var style = document.createElement('link');style.rel = 'stylesheet';style.type = 'text/css';style.href = url;document.head.appendChild(style);};var addScript = function(url,cb) {var script = document.createElement('script');script.src = url;if(cb) {script.onload = cb;}document.body.appendChild(script);};if (typeof window.jetzt === 'undefined') {var cb = function() {window.jetzt.select();};addStyle('https://ds300.github.io/jetzt/jetzt.css');addScript('https://ds300.github.io/jetzt/jetzt-solid.min.js',cb);} else {window.jetzt.select();}})();

I modified it to this to make sure that it fetches the latest content:

javascript: (function() {var addStyle = function(url) {var style = document.createElement('link');style.rel = 'stylesheet';style.type = 'text/css';style.href = url;document.head.appendChild(style);};var addScript = function(url,cb) {var script = document.createElement('script');script.src = url;if(cb) {script.onload = cb;}document.body.appendChild(script);};if (typeof window.jetzt === 'undefined') {var cb = function() {window.jetzt.select();};addStyle('https://raw.githubusercontent.com/ds300/jetzt/master/jetzt.css');addScript('https://raw.githubusercontent.com/ds300/jetzt/master/jetzt-solid.min.js',cb);} else {window.jetzt.select();}})();

However, the behaviour of the bookmarklet is still not the same as if I clone the repo and use the extension approach instead.

Can anyone please explain to me why that is?

h0ru5 commented 10 years ago

Thats because the script you referenced is concatenated and minified by the grunt toolchain (sort of a make for javascript) on the developers machine - if he calls grunt. Actually, the build product (jetzt-solid.min.js) should not be checked in git. Like now, one would need to run grunt before each commit, so it is up-to-date with the sources.

Cleaner would be building on a build server (e.g. travis or cloudbees, which offer auto-hooking in github) that rebuilds after each commit and that can update the gh-pages branch (und thus https://ds300.github.io/jetzt/jetzt-solid.min.js).

orschiro commented 10 years ago

@h0ru5

Interesting. Thanks. So the required source for the bookmarklet always needs to pushed to a separate gh-pages to make it working?

There is no other way around this?

h0ru5 commented 10 years ago

the gh-pages branch is actually what is served from github.io, where the bookmarklet looks for the jetzt-solid.min.js

the essence of my post above is:

so if you refer to the solid.min.js from master (as you bdo above), you still need to "recompile" it whenever one of the source file changes

orschiro commented 10 years ago

@h0ru5

Thanks, now I got it!

peteruithoven commented 8 years ago

So this isn't an issue right?

orschiro commented 8 years ago

Dear @peteruithoven,

Indeed, no longer an issue.

Thanks for closing!

~Robert