GithubHelp home page GithubHelp logo

boot-bookmarklet's People

Contributors

daveyarwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

borkdude

boot-bookmarklet's Issues

Bookmarklet is not draggable

After running the command boot build with a configuration like so:

(set-env! :dependencies '[[adzerk/boot-bookmarklet "0.2.0" :scope "test"]])
(require '[adzerk.boot-bookmarklet :refer (bookmarklet external-bookmarklet)])


(deftask build
	[]
	(comp
		(speak)
		(bookmarklet :ids #{"hello"})
		(target)))

I get the output

Writing main.cljs.edn...
Compiling ClojureScript...
WARNING: No ClojureScript in project dependencies but ClojureScript was found in classpath. Adding direct dependency is adviced.
• main.js
Writing bookmarklets.html...
Writing target dir(s)...

Then running open target/bookmarklets.html will open it in a browser that will look like so. Clicking this will produce the expected result, But I can't drag the link. The URL of the <a> tag is:

javascript:%20var%20CLOSURE_UNCOMPILED_DEFINES%20%3D%20null%3B%0Aif%28typeof%20goog%20%3D%3D%20%22undefined%22%29%20document.write%28%27%3Cscript%20src%3D%22main.out%2Fgoog%2Fbase.js%22%3E%3C%2Fscript%3E%27%29%3B%0Adocument.write%28%27%3Cscript%20src%3D%22main.out%2Fcljs_deps.js%22%3E%3C%2Fscript%3E%27%29%3B%0Adocument.write%28%27%3Cscript%3Eif%20%28typeof%20goog%20%21%3D%20%22undefined%22%29%20%7B%20goog.require%28%22boot.cljs.main647%22%29%3B%20%7D%20else%20%7B%20console.warn%28%22ClojureScript%20could%20not%20load%20%3Amain%2C%20did%20you%20forget%20to%20specify%20%3Aasset-path%3F%22%29%3B%20%7D%3B%3C%2Fscript%3E%27%29%3B%0A

That URL would be the following Javascript:

 var CLOSURE_UNCOMPILED_DEFINES = null;
if(typeof goog == "undefined") document.write('<script src="main.out/goog/base.js"></script>');
document.write('<script src="main.out/cljs_deps.js"></script>');
document.write('<script>if (typeof goog != "undefined") { goog.require("boot.cljs.main647"); } else { console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?"); };</script>');

It looks like it's trying to load a local file, which does not seem right for a bookmarklet. It's also impossible to drag the URL.

You can view all the files here.

Add an option to easily generate a bookmarklet that sources a hosted JS file

URL-encoded JS compiled from CLJS can easily exceed the 2000-character limit in URLs, making the bookmarklet unusable. A lot of bookmarklets (even vanilla JS ones) just source an external JS file that is hosted somewhere.

It might be nice to add a task option (or perhaps a separate task) to auto-generate a bookmarklet that does this. Maybe you could even compose this with another task that would upload the compiled JS to somewhere like S3 or Dropbox.

The simplest thing would be just a task that takes any number of script URLs and generates a bookmarklet that sources them. It could be as simple as splicing each URL into this (source):

javascript: (function () { 
    var jsCode = document.createElement('script'); 
    jsCode.setAttribute('src', 'http://path/to/external/file.js');                  
  document.body.appendChild(jsCode); 
 }());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.