Quick Share Bookmarklet
Remember bookmarklets? Circa 2001. Those were the days. I still like them especially for grabbing things from a page you are on so that you may more quickly share that page on your own site.
Wouldn't it be great to be able to quickly share any web page you are on to your Flarum? Or, at least get some basic information quickly over to your Flarum which you can then expand upon?
If you answered yes to the above questions, then today is your lucky day because I am going to share the code with you!
But, wait! First read the following two points as they are very important:
- This is as-is, no support provided code. If it doesn't work for you, or doesn't work in certain situations, you'll need to adjust it yourself. If you come up with a very crucial adjustment I encourage you to keep the spirit of gifting alive and share your modified version here.
- This requires the fabulous Direct Links extension. Install that first.
Create the bookmarklet
After Direct Links is installed, create a bookmark in your browser and make the bookmark's URL the following (change "YOURWEBSITE.com" to your Flarum's home page - this is right towards the beginning of the code):
javascript:(function(){var newURI='https://YOURWEBSITE.com/composer?content='+encodeURIComponent(decodeURIComponent(window.getSelection()))+' source: '+encodeURIComponent(decodeURIComponent(window.location.href))+'&title='+encodeURIComponent(document.title.replace('%20',' ')); window.location.href=newURI;})();
Final steps after all of the above is complete
- Log into your Flarum.
- Next, go to a web page, maybe an interesting blog article and highlight/select the text you want to share.
- Finally, with the text still highlighted, click your new bookmark (bookmarklet).
You will be directed to your Flarum and the composer box will appear. In most cases, your Flarum composer box will now magically have that other web page's title in the title field, and then in the content area you will have the text you highlighted, plus the page's URL. Add a line break, more context, formatting, and post!