-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit
- Loading branch information
0 parents
commit d12a6df
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Michael Winkler | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
yourls-shaarli | ||
============== | ||
|
||
About | ||
------------ | ||
|
||
yourls-shaarli is a plugin for [YOURLS](http://yourls.org/). The plugin adds a new share link into the Quick Share box (available for each URL shown in the Yourls admin area). | ||
The added link allows the sharing of the URL to a [Shaarli](https://github.com/shaarli/Shaarli) installation. | ||
|
||
Obviously, you need a valid Yourls installation and a valid Shaarli installation. | ||
|
||
This plugin has been tested on Yourls: | ||
* [1.7](https://github.com/YOURLS/YOURLS/releases/tag/1.7) | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
1. Unzip the plugin. You get a "yourls-shaarli" folder | ||
2. Upload this folder into the user/plugins folder of your Yourls installation | ||
3. Edit your config.php file (located at user/config.php in your Yourls installation) | ||
4. Define the URL of your Shaarli installation by inserting the following line at the end of your config.php file. Adapt the URL "https://my-shaarli.com" to your Shaarli installation's URL (No trailing slash !!!), and save changes to config.php | ||
|
||
``` | ||
define('SHAARLI_URL', 'https://my-shaarli.com'); | ||
``` | ||
|
||
Finally, activate the plugin in the admin area | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
Plugin Name: Share to Shaarli | ||
Plugin URI: https://github.com/miwasp/yourls-shaarli | ||
Description: Add <a href="https://github.com/sebsauvage/Shaarli/">Shaarli</a> to the list of Quick Share destinations | ||
Version: 1.0 | ||
Author: Michael Winkler | ||
Author URI: https://github.com/miwasp | ||
**/ | ||
|
||
// No direct call | ||
if( !defined( 'YOURLS_ABSPATH' ) ) die(); | ||
|
||
yourls_add_action( 'share_links', 'jr_yourls_shaarli' ); | ||
|
||
function jr_yourls_shaarli( $args ) { | ||
list( $longurl, $shorturl, $title, $text ) = $args; | ||
$longurl = rawurlencode( $longurl ); | ||
if ( defined('SHAARLI_URL') ) { | ||
$shaarli_url = SHAARLI_URL; | ||
// Plugin URL (no URL is hardcoded) | ||
$pluginurl = YOURLS_PLUGINURL . '/'.yourls_plugin_basename( dirname(__FILE__) ); | ||
$icon = $pluginurl.'/shaarli.png'; | ||
echo <<<SHAARLI | ||
<style type="text/css"> | ||
#share_shaarli{background: transparent url("$icon") left center no-repeat;} | ||
</style> | ||
<a id="share_shaarli" | ||
href="$shaarli_url/index.php?post=$longurl&title=$title&source=bookmarklet" | ||
title="Share to Shaarli" | ||
onclick="yourls_share_on_shaarli();return false;">Shaarli | ||
</a> | ||
<script type="text/javascript"> | ||
// Send to Shaarli open window | ||
function yourls_share_on_shaarli() { | ||
var url = $('#share_shaarli').attr('href'); | ||
window.open(url, 'shaarli', 'toolbar=no,width=800,height=600'); | ||
return false; | ||
} | ||
// Dynamically update shaarli link | ||
// when user clicks on the "Share" Action icon, event $('#tweet_body').keypress() is fired, so we'll add to this | ||
$('#tweet_body').keypress(function(){ | ||
var title = encodeURIComponent( $('#titlelink').val() ); | ||
var url = encodeURIComponent( $('#copylink').val() ); | ||
var shaarli = '$shaarli_url/index.php?post='+url+'&title='+title+'&source=bookmarklet'; | ||
$('#share_shaarli').attr('href', shaarli); | ||
}); | ||
</script> | ||
SHAARLI; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.