can't resist
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
801 B

defmodule TomieWeb.ProfileView do
use TomieWeb, :view
def bookmarklet(conn) do
url = Routes.live_url(TomieWeb.Endpoint, TomieWeb.BookmarkLive.New)
user = Pow.Plug.current_user(conn)
"""
javascript:(function() {
var t;
try {
t = ((window.getSelection && window.getSelection()) || (document.getSelection && document.getSelection()) || (document.selection && document.selection.createRange && document.selection.createRange().text));
} catch (e) {
t = \"\";
};
window.location = \"#{url}?url=\" + encodeURIComponent(window.location.href) + \"&content=\" + encodeURIComponent((t == '' ? '' : '> ' + t)) + \"&name=\" + encodeURIComponent(document.title) + \"&token=#{
user.token
}\";
})();
"""
end
end