Browse Source

Initial commit

master
Chris Wiegman 7 months ago
commit
b4932fafdd
Signed by: chriswiegman GPG Key ID: 2B23D7A74FDE2DF4
41 changed files with 912 additions and 0 deletions
  1. +2
    -0
      .freshrss.env.sample
  2. +3
    -0
      .gitignore
  3. +1
    -0
      .mariadb.env.sample
  4. +12
    -0
      .wallabag.env.sample
  5. +7
    -0
      .yourls.env.sample
  6. +9
    -0
      README.md
  7. BIN
     
  8. +19
    -0
      data/conf/traefik/traefik.toml
  9. +60
    -0
      data/conf/yourls/plugins/fallback-url/plugin.php
  10. +6
    -0
      data/conf/yourls/plugins/hyphens-in-urls/README.md
  11. +19
    -0
      data/conf/yourls/plugins/hyphens-in-urls/plugin.php
  12. +8
    -0
      data/conf/yourls/plugins/index.html
  13. +6
    -0
      data/conf/yourls/plugins/random-bg/README.md
  14. BIN
     
  15. BIN
     
  16. BIN
     
  17. BIN
     
  18. BIN
     
  19. BIN
     
  20. BIN
     
  21. BIN
     
  22. BIN
     
  23. +27
    -0
      data/conf/yourls/plugins/random-bg/plugin.php
  24. +20
    -0
      data/conf/yourls/plugins/random-keywords/LICENSE.md
  25. +20
    -0
      data/conf/yourls/plugins/random-keywords/README.md
  26. +42
    -0
      data/conf/yourls/plugins/random-keywords/plugin.php
  27. +7
    -0
      data/conf/yourls/plugins/random-shorturls/README.md
  28. +93
    -0
      data/conf/yourls/plugins/random-shorturls/plugin.php
  29. +6
    -0
      data/conf/yourls/plugins/sample-page/README.md
  30. +63
    -0
      data/conf/yourls/plugins/sample-page/plugin.php
  31. +6
    -0
      data/conf/yourls/plugins/sample-plugin/README.md
  32. +61
    -0
      data/conf/yourls/plugins/sample-plugin/plugin.php
  33. +6
    -0
      data/conf/yourls/plugins/sample-toolbar/README.md
  34. +79
    -0
      data/conf/yourls/plugins/sample-toolbar/css/toolbar.css
  35. BIN
     
  36. BIN
     
  37. BIN
     
  38. BIN
     
  39. +22
    -0
      data/conf/yourls/plugins/sample-toolbar/js/toolbar.js
  40. +126
    -0
      data/conf/yourls/plugins/sample-toolbar/plugin.php
  41. +182
    -0
      docker-compose.yaml

+ 2
- 0
.freshrss.env.sample View File

@ -0,0 +1,2 @@
CRON_MIN=*/10
TZ=America/New_York

+ 3
- 0
.gitignore View File

@ -0,0 +1,3 @@
volumes/
data/conf/traefik/acme.json
*.env

+ 1
- 0
.mariadb.env.sample View File

@ -0,0 +1 @@
MYSQL_ROOT_PASSWORD=

+ 12
- 0
.wallabag.env.sample View File

@ -0,0 +1,12 @@
MYSQL_ROOT_PASSWORD=
SYMFONY__ENV__DATABASE_DRIVER=pdo_mysql
SYMFONY__ENV__DATABASE_HOST=mariadb
SYMFONY__ENV__DATABASE_PORT=3306
SYMFONY__ENV__DATABASE_NAME=
SYMFONY__ENV__DATABASE_USER=
SYMFONY__ENV__SECRET=
SYMFONY__ENV__DATABASE_PASSWORD=
SYMFONY__ENV__DATABASE_CHARSET=utf8mb4
SYMFONY__ENV__FOSUSER_REGISTRATION=false
SYMFONY__ENV__FOSUSER_CONFIRMATION=false
SYMFONY__ENV__DOMAIN_NAME=https://[your site here]

+ 7
- 0
.yourls.env.sample View File

@ -0,0 +1,7 @@
YOURLS_DB_HOST=mariadb
YOURLS_DB_USER=
YOURLS_DB_PASS=
YOURLS_DB_NAME=
YOURLS_SITE=https://[your site here]
YOURLS_USER=
YOURLS_PASS=

+ 9
- 0
README.md View File

@ -0,0 +1,9 @@
Self Hosted Configuration
-----
A self-hosted configuration to help escape big tech.
* Wallabag
* Yourls
* FreshRSS
* NextCloud

BIN
View File


+ 19
- 0
data/conf/traefik/traefik.toml View File

@ -0,0 +1,19 @@
[log]
level = "ERROR"
[providers.docker]
exposedByDefault = false
endpoint = "tcp://dockerproxy:2375"
network = "traefik"
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web-secure]
address = ":443"
[certificatesResolvers]
[certificatesResolvers.default.acme]
email = "my@email.address"
storage = "acme.json"
[certificatesResolvers.default.acme.tlsChallenge]

+ 60
- 0
data/conf/yourls/plugins/fallback-url/plugin.php View File

@ -0,0 +1,60 @@
<?php
/*
Plugin Name: Fallback URL
Plugin URI: http://diegopeinador.com/fallback-url-yourls-plugin
Description: This plugin allows you to define a fallback URL in case there isn't a match for your short URL, so you can specify something different than $YOURLS_HOME.
Version: 1.0
Author: Diego Peinador
Author URI: http://diegopeinador.com
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
yourls_add_action( 'redirect_keyword_not_found', 'dp_fallback_url' );
function dp_fallback_url() {
// Get value from database
$fallback_url = yourls_get_option( 'fallback_url' );
yourls_redirect( $fallback_url, 302 ); //Use a temporal redirect in case there is a valid keyword in the future
}
// Register our plugin config page
yourls_add_action( 'plugins_loaded', 'dp_config_add_page' );
function dp_config_add_page() {
yourls_register_plugin_page( 'fallback_url_config', 'Fallback URL Plugin Config', 'dp_config_do_page' );
// parameters: page slug, page title, and function that will display the page itself
}
// Display config page
function dp_config_do_page() {
// Check if a form was submitted
if( isset( $_POST['fallback_url'] ) )
dp_config_update_option();
// Get value from database
$fallback_url = yourls_get_option( 'fallback_url' );
echo <<<HTML
<h2>Fallback URL Plugin Config</h2>
<p>Here you can configure the URL to redirect in case the keyword is not found in database.</p>
<form method="post">
<p><label for="fallback_url">URL to fallback to</label> <input type="text" id="fallback_url" name="fallback_url" value="$fallback_url" size="40" /></p>
<p><input type="submit" value="Update value" /></p>
</form>
HTML;
}
// Update option in database
function dp_config_update_option() {
$in = $_POST['fallback_url'];
if( $in ) {
// Validate test_option. ALWAYS validate and sanitize user input.
// Here, we want an string
$in = strval( $in);
// Update value in database
yourls_update_option( 'fallback_url', $in );
}
}

+ 6
- 0
data/conf/yourls/plugins/hyphens-in-urls/README.md View File

@ -0,0 +1,6 @@
Hyphens in URLs
===============
This is a core plugin, bundled with YOURLS.
Don't modify this plugin. Instead, copy its folder
and modify your own copy. This way, your code won't
be overwritten when you upgrade YOURLS.

+ 19
- 0
data/conf/yourls/plugins/hyphens-in-urls/plugin.php View File

@ -0,0 +1,19 @@
<?php
/*
Plugin Name: Allow Hyphens in Short URLs
Plugin URI: http://yourls.org/
Description: Allow hyphens in short URLs (like <tt>http://sho.rt/hello-world</tt>)
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
yourls_add_filter( 'get_shorturl_charset', 'ozh_hyphen_in_charset' );
function ozh_hyphen_in_charset( $in ) {
return $in.'-';
}

+ 8
- 0
data/conf/yourls/plugins/index.html View File

@ -0,0 +1,8 @@
<!-- This page hides the content of the /pages/ directory and sends to YOURLS root -->
<html>
<head>
<meta http-equiv="refresh" content="0;url=../"></head>
<body>
YOURLS has nothing for you to see here.
</body>
</html>

+ 6
- 0
data/conf/yourls/plugins/random-bg/README.md View File

@ -0,0 +1,6 @@
Random Background
=================
This is a sample plugin, for illustration purpose.
Don't modify this plugin. Instead, copy its folder
and modify your own copy. This way, your code won't
be overwritten when you upgrade YOURLS.

BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 27
- 0
data/conf/yourls/plugins/random-bg/plugin.php View File

@ -0,0 +1,27 @@
<?php
/*
Plugin Name: Random Backgrounds
Plugin URI: http://yourls.org/
Description: Pretty random background patterns
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
// Add the inline style
yourls_add_action( 'html_head', 'ozh_yourls_randombg' );
function ozh_yourls_randombg() {
$bg = glob( __DIR__.'/img/*png' );
$url = yourls_plugin_url( __DIR__ );
$rnd = yourls_plugin_url( $bg[ mt_rand( 0, count( $bg ) - 1 ) ] );
echo <<<CSS
<style type="text/css">
body {background:#e3f3ff url($rnd) repeat;}
</style>
CSS;
}

+ 20
- 0
data/conf/yourls/plugins/random-keywords/LICENSE.md View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 YOURLS
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.

+ 20
- 0
data/conf/yourls/plugins/random-keywords/README.md View File

@ -0,0 +1,20 @@
Random Keywords
===============
Plugin for [YOURLS](http://yourls.org) `1.5+`.
Description
-----------
Assign random keywords to shorturls, like bitly (ie http://sho.rt/hJudjK).
Installation
------------
1. In `/user/plugins`, create a new folder named `random-keywords`.
2. Drop these files in that directory.
3. Go to the Plugins administration page ( *eg* `http://sho.rt/admin/plugins.php` ) and activate the plugin.
4. Have fun!
License
-------
YOURLS' license, aka *"Do whatever the hell you want with it"*.
_YOURLS MIT License_

+ 42
- 0
data/conf/yourls/plugins/random-keywords/plugin.php View File

@ -0,0 +1,42 @@
<?php
/*
Plugin Name: Random Keywords
Plugin URI: http://yourls.org/
Description: Assign random keywords to shorturls, like bitly (sho.rt/hJudjK)
Version: 1.1
Author: Ozh
Author URI: http://ozh.org/
*/
/* Release History:
*
* 1.0 Initial release
* 1.1 Added: don't increment sequential keyword counter & save one SQL query
* Fixed: plugin now complies to character set defined in config.php
*/
global $ozh_random_keyword;
/*
* CONFIG: EDIT THIS
*/
/* Length of random keyword */
$ozh_random_keyword['length'] = 5;
/*
* DO NOT EDIT FARTHER
*/
// Generate a random keyword
yourls_add_filter( 'random_keyword', 'ozh_random_keyword' );
function ozh_random_keyword() {
global $ozh_random_keyword;
return yourls_rnd_string( $ozh_random_keyword['length'] );
}
// Don't increment sequential keyword tracker
yourls_add_filter( 'get_next_decimal', 'ozh_random_keyword_next_decimal' );
function ozh_random_keyword_next_decimal( $next ) {
return ( $next - 1 );
}

+ 7
- 0
data/conf/yourls/plugins/random-shorturls/README.md View File

@ -0,0 +1,7 @@
Random ShortURLs
================
This is a core plugin, bundled with YOURLS.
Don't modify this plugin. Instead, copy its folder
and modify your own copy. This way, your code won't
be overwritten when you upgrade YOURLS.

+ 93
- 0
data/conf/yourls/plugins/random-shorturls/plugin.php View File

@ -0,0 +1,93 @@
<?php
/*
Plugin Name: Random ShortURLs
Plugin URI: https://yourls.org/
Description: Assign random keywords to shorturls, like bitly (sho.rt/hJudjK)
Version: 1.2
Author: Ozh
Author URI: https://ozh.org/
*/
/* Release History:
*
* 1.0 Initial release
* 1.1 Added: don't increment sequential keyword counter & save one SQL query
* Fixed: plugin now complies to character set defined in config.php
* 1.2 Adopted as YOURLS core plugin under a new name
* Now configured via YOURLS options instead of editing plugin file
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
// Only register things if the old third-party plugin is not present
if( function_exists('ozh_random_keyword') ) {
yourls_add_notice( "<b>Random ShortURLs</b> plugin cannot function unless <b>Random Keywords</b> is removed first." );
} else {
// filter registration happens conditionally, to avoid conflicts
// settings action is left out here, as it allows checking settings before deleting the old plugin
yourls_add_filter( 'random_keyword', 'ozh_random_shorturl' );
yourls_add_filter( 'get_next_decimal', 'ozh_random_shorturl_next_decimal' );
}
// Generate a random keyword
function ozh_random_shorturl() {
$possible = yourls_get_shorturl_charset() ;
$str='';
while( strlen( $str ) < yourls_get_option( 'random_shorturls_length', 5 ) ) {
$str .= substr($possible, rand( 0, strlen( $possible ) - 1 ), 1 );
}
return $str;
}
// Don't increment sequential keyword tracker
function ozh_random_shorturl_next_decimal( $next ) {
return ( $next - 1 );
}
// Plugin settings page etc.
yourls_add_action( 'plugins_loaded', 'ozh_random_shorturl_add_settings' );
function ozh_random_shorturl_add_settings() {
yourls_register_plugin_page( 'random_shorturl_settings', 'Random ShortURLs Settings', 'ozh_random_shorturl_settings_page' );
}
function ozh_random_shorturl_settings_page() {
// Check if form was submitted
if( isset( $_POST['random_length'] ) ) {
// If so, verify nonce
yourls_verify_nonce( 'random_shorturl_settings' );
// and process submission if nonce is valid
ozh_random_shorturl_settings_update();
}
$random_length = yourls_get_option('random_shorturls_length');
$nonce = yourls_create_nonce( 'random_shorturl_settings' );
echo <<<HTML
<main>
<h2>Random ShortURLs Settings</h2>
<form method="post">
<input type="hidden" name="nonce" value="$nonce" />
<p>
<label>Random Keyword Length</label>
<input type="number" name="random_length" min="1" max="128" value="$random_length" />
</p>
<p><input type="submit" value="Save" class="button" /></p>
</form>
</main>
HTML;
}
function ozh_random_shorturl_settings_update() {
$random_length = $_POST['random_length'];
if( $random_length ) {
if( is_numeric( $random_length ) ) {
yourls_update_option( 'random_shorturls_length', intval( $random_length ) );
} else {
echo "Error: Length given was not a number.";
}
} else {
echo "Error: No length value given.";
}
}

+ 6
- 0
data/conf/yourls/plugins/sample-page/README.md View File

@ -0,0 +1,6 @@
Sample Page
===========
This is a sample plugin, for illustration purpose.
Don't modify this plugin. Instead, copy its folder
and modify your own copy. This way, your code won't
be overwritten when you upgrade YOURLS.

+ 63
- 0
data/conf/yourls/plugins/sample-page/plugin.php View File

@ -0,0 +1,63 @@
<?php
/*
Plugin Name: Sample Admin Page
Plugin URI: http://yourls.org/
Description: A example of a plugin administration page to save user defined option
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
// Register our plugin admin page
yourls_add_action( 'plugins_loaded', 'ozh_yourls_samplepage_add_page' );
function ozh_yourls_samplepage_add_page() {
yourls_register_plugin_page( 'sample_page', 'Sample Admin Page', 'ozh_yourls_samplepage_do_page' );
// parameters: page slug, page title, and function that will display the page itself
}
// Display admin page
function ozh_yourls_samplepage_do_page() {
// Check if a form was submitted
if( isset( $_POST['test_option'] ) ) {
// Check nonce
yourls_verify_nonce( 'sample_page' );
// Process form
ozh_yourls_samplepage_update_option();
}
// Get value from database
$test_option = yourls_get_option( 'test_option' );
// Create nonce
$nonce = yourls_create_nonce( 'sample_page' );
echo <<<HTML
<h2>Sample Plugin Administration Page</h2>
<p>This plugin stores an integer in the option database</p>
<form method="post">
<input type="hidden" name="nonce" value="$nonce" />
<p><label for="test_option">Enter an integer</label> <input type="text" id="test_option" name="test_option" value="$test_option" /></p>
<p><input type="submit" value="Update value" /></p>
</form>
HTML;
}
// Update option in database
function ozh_yourls_samplepage_update_option() {
$in = $_POST['test_option'];
if( $in ) {
// Validate test_option. ALWAYS validate and sanitize user input.
// Here, we want an integer
$in = intval( $in);
// Update value in database
yourls_update_option( 'test_option', $in );
}
}

+ 6
- 0
data/conf/yourls/plugins/sample-plugin/README.md View File

@ -0,0 +1,6 @@
Sample Plugin
=============
This is a sample plugin, for illustration purpose.
Don't modify this plugin. Instead, copy its folder
and modify your own copy. This way, your code won't
be overwritten when you upgrade YOURLS.

+ 61
- 0
data/conf/yourls/plugins/sample-plugin/plugin.php View File

@ -0,0 +1,61 @@
<?php
/*
Plugin Name: Sample Plugin
Plugin URI: http://yourls.org/
Description: Sample plugin to illustrate how actions and filters work. Read its source. Refer to the <a href="http://yourls.org/pluginapi">Plugin API documentation</a> for more details.
Version: 0.1
Author: Ozh
Author URI: http://ozh.org/
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
/* Example of an action
*
* We're going to add an entry to the menu.
*
* The menu is drawn by function yourls_html_menu() in file includes/functions-html.php.
* Right before the function outputs the closing </ul>, notice the following function call:
* yourls_do_action( 'admin_menu' );
* This function says: "hey, for your information, I've just done something called 'admin menu', thought I'd let you know..."
*
* We're going to hook into this action and add our menu entry
*/
yourls_add_action( 'admin_menu', 'ozh_sample_add_menu' );
/* This says: when YOURLS does action 'admin_menu', call function 'ozh_sample_add_menu'
*/
function ozh_sample_add_menu() {
echo '<li><a href="http://ozh.org/">Ozh</a></li>';
}
/* And that's it. Activate the plugin and notice the new menu entry.
*/
/* Example of a filter
*
* We're going to modify the <title> of pages in the admin area
*
* The <title> tag is generated by function yourls_html_head() in includes/functions-html.php
* Notice the following function call:
* $title = yourls_apply_filter( 'html_title', 'YOURLS: Your Own URL Shortener' );
* This function means: give $title the value "YOURLS: Your Own URL Shortener", unless a
* filter modifies this value.
*
* We're going to hook into this filter and modify this value.
*/
yourls_add_filter( 'html_title', 'ozh_sample_change_title' );
/* This says: when filter 'html_title' is triggered, send its value to function 'ozh_sample_change_title'
* and use what this function will return.
*/
function ozh_sample_change_title( $value ) {
$value = $value . ' -- the sample plugin is activated';
return $value; // a filter *always* has to return a value
}
/* And that's it. Activate the plugin and notice how the page title changes */

+ 6
- 0
data/conf/yourls/plugins/sample-toolbar/README.md View File

@ -0,0 +1,6 @@
Sample Toolbar
==============
This is a sample plugin, for illustration purpose.
Don't modify this plugin. Instead, copy its folder
and modify your own copy. This way, your code won't
be overwritten when you upgrade YOURLS.

+ 79
- 0
data/conf/yourls/plugins/sample-toolbar/css/toolbar.css View File

@ -0,0 +1,79 @@
body {
margin:0;
overflow:hidden;
background-color:#fff;
font-size:12px;
font-family: Verdana, Arial;
padding:35px 0 0;
}
#yourls-frame {
width: 100%;
height:100%;
z-index: 1;
}
#yourls-bar {
font-family: Verdana, Arial;
font-size: 12px;
position:absolute;
top:0;
height:35px;
width:100%;
background:#e3f3ff url(../img/toolbar_bg.png) repeat-x bottom center;
color:#2A85B3;
-moz-box-shadow: 0 1px 5px rgba(0,0,0,0.5);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
z-index: 900000;
}
#yourls-bar a {
text-decoration:none;
color:#2A85B3;
}
#yourls-bar a:hover {
text-decoration:underline;
}
#yourls-about, #yourls-topsy, #yourls-delicious, #yourls-selfclose {
margin-left:10px;
float:left;
display:block;
top:5px;
position:relative;
}
#yourls-about a {
background:transparent url(../img/favicon.gif) center left no-repeat;
padding-left:20px;
color:inherit;
font-weight:bold;
}
#yourls-topsy {
width:300px;
}
#yourls-selfclose {
float:right;
margin-right:10px;
}
#yourls-once {
display:block;
text-indent:-9999px;
background:transparent url(../img/close_button.gif) center center no-repeat;
width:20px;
height:20px;
float:left;
}
#yourls-always {
display:none;
text-indent:-9999px;
background:transparent url(../img/close_button_red.gif) center center no-repeat;
width:20px;
height:20px;
float:left;
}

BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 22
- 0
data/conf/yourls/plugins/sample-toolbar/js/toolbar.js View File

@ -0,0 +1,22 @@
// If javascript is enabled, display the button
document.getElementById('yourls-always').style.display = 'block';
// When button clicked, store a cookie that says the user doesn't want a toolbar
document.getElementById('yourls-always').onclick = yourls_cookie_no_toolbar_please;
function yourls_cookie_no_toolbar_please() {
var exdate=new Date();
exdate.setDate( exdate.getDate()+365 ); // store 365 days
document.cookie = "yourls_no_toolbar=1;expires="+exdate.toUTCString() ;
}
// Get the number of delicious bookmarks
function yourls_get_books(json) {
if( json.length ) {
var books = json[0].total_posts.toString();
if( books ) {
document.getElementById('yourls-delicious-link').innerHTML = ' <b>'+books+'</b> bookmarks';
}
}
}

+ 126
- 0
data/conf/yourls/plugins/sample-toolbar/plugin.php View File

@ -0,0 +1,126 @@
<?php
/*
Plugin Name: YOURLS Toolbar
Plugin URI: http://yourls.org/
Description: Add a social toolbar to your redirected short URLs. Fork this plugin if you want to make your own toolbar.
Version: 1.0
Author: Ozh
Author URI: http://ozh.org/
Disclaimer: Toolbars ruin the user experience. Be warned.
*/
// No direct call
if( !defined( 'YOURLS_ABSPATH' ) ) die();
global $ozh_toolbar;
$ozh_toolbar['do'] = false;
$ozh_toolbar['keyword'] = '';
// When a redirection to a shorturl is about to happen, register variables
yourls_add_action( 'redirect_shorturl', 'ozh_toolbar_add' );
function ozh_toolbar_add( $args ) {
global $ozh_toolbar;
$ozh_toolbar['do'] = true;
$ozh_toolbar['keyword'] = $args[1];
}
// On redirection, check if this is a toolbar and draw it if needed
yourls_add_action( 'pre_redirect', 'ozh_toolbar_do' );
function ozh_toolbar_do( $args ) {
global $ozh_toolbar;
// Does this redirection need a toolbar?
if( !$ozh_toolbar['do'] )
return;
// Do we have a cookie stating the user doesn't want a toolbar?
if( isset( $_COOKIE['yourls_no_toolbar'] ) && $_COOKIE['yourls_no_toolbar'] == 1 )
return;
// Get URL and page title
$url = $args[0];
$pagetitle = yourls_get_keyword_title( $ozh_toolbar['keyword'] );
// Update title if it hasn't been stored yet
if( $pagetitle == '' ) {
$pagetitle = yourls_get_remote_title( $url );
yourls_edit_link_title( $ozh_toolbar['keyword'], $pagetitle );
}
$_pagetitle = htmlentities( yourls_get_remote_title( $url ) );
$www = YOURLS_SITE;
$ver = YOURLS_VERSION;
$md5 = md5( $url );
$sql = yourls_get_num_queries();
// When was the link created (in days)
$diff = abs( time() - strtotime( yourls_get_keyword_timestamp( $ozh_toolbar['keyword'] ) ) );
$days = floor( $diff / (60*60*24) );
if( $days == 0 ) {
$created = 'today';
} else {
$created = $days . ' ' . yourls_n( 'day', 'days', $days ) . ' ago';
}
// How many hits on the page
$hits = 1 + yourls_get_keyword_clicks( $ozh_toolbar['keyword'] );
$hits = $hits . ' ' . yourls_n( 'view', 'views', $hits );
// Plugin URL (no URL is hardcoded)
$pluginurl = YOURLS_PLUGINURL . '/'.yourls_plugin_basename( __DIR__ );
// All set. Draw the toolbar itself.
echo <<<PAGE
<html>
<head>
<title>$pagetitle &mdash; YOURLS</title>
<link rel="icon" type="image/gif" href="$www/images/favicon.gif" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE-9"/>
<meta name="generator" content="YOURLS v$ver" />
<meta name="ROBOTS" content="NOINDEX, FOLLOW" />
<link rel="stylesheet" href="$pluginurl/css/toolbar.css" type="text/css" media="all" />
</head>
<body>
<div id="yourls-bar">
<div id="yourls-about">
Short link powered by <a href="http://yourls.org/">YOURLS</a> and created $created. $hits.
<!-- $sql queries -->
</div>
<div id="yourls-delicious">
<img src="http://static.delicious.com/img/delicious.small.gif" height="10" width="10" alt="Delicious" />
<a id="yourls-delicious-link" title="Bookmark on delicious" href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"> Bookmark on Delicious</a>
</div>
<script type="text/javascript" id="topsy_global_settings">
var topsy_theme = "light-blue";
var topsy_nick = " ";
var topsy_style = "small";
var topsy_order = "count,retweet,badge";
</script>
<div id="yourls-topsy" class="topsy_widget_data">
<!--{
"url": "$www/{$ozh_toolbar['keyword']}",
"title": "$_pagetitle",
}-->
</div>
<div id="yourls-selfclose">
<a id="yourls-once" href="$url" title="Close this toolbar">close</a>
<a id="yourls-always" href="$url" title="Never show me this toolbar again">close</a>
</div>
</div>
<iframe id="yourls-frame" frameborder="0" noresize="noresize" src="$url" name="yourlsFrame"></iframe>
<script type="text/javascript" src="$pluginurl/js/toolbar.js"></script>
<script type="text/javascript" src="http://cdn.topsy.com/topsy.js?init=topsyWidgetCreator"></script>
<script type="text/javascript" src="http://feeds.delicious.com/v2/json/urlinfo/$md5?callback=yourls_get_books"></script>
</body>
</html>
PAGE;
// Don't forget to die, to interrupt the flow of normal events (ie redirecting to long URL)
die();
}

+ 182
- 0
docker-compose.yaml View File

@ -0,0 +1,182 @@
version: "3"
networks:
default:
driver: bridge
traefik:
internal: true
services:
watchtower:
command: --label-enable --cleanup --interval 300
image: containrrr/watchtower
labels:
- "com.centurylinklabs.watchtower.enable=true"
network_mode: none
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
dockerproxy:
depends_on:
- watchtower
environment:
CONTAINERS: 1
image: tecnativa/docker-socket-proxy
labels:
- "com.centurylinklabs.watchtower.enable=true"
networks:
- traefik
ports:
- 2375
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
traefik:
depends_on:
- dockerproxy
- watchtower
image: traefik:2.1
labels:
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
- traefik
ports:
- 80:80
- 443:443
restart: always
volumes:
- ./data/conf/traefik/acme.json:/acme.json
- ./data/conf/traefik/traefik.toml:/traefik.toml
- ./data/volumes/traefik/tmp:/tmp
mariadb:
depends_on:
- watchtower
env_file: .mariadb.env
image: mariadb:10
labels:
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
ports:
- 3306:3306
restart: always
volumes:
- ./data/volumes/mariadb:/var/lib/mysql
redis:
depends_on:
- watchtower
image: redis:5
labels:
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
restart: always
volumes:
- ./data/volumes/redis:/data
freshrss:
depends_on:
- mariadb
- traefik
- watchtower
env_file: .freshrss.env
image: freshrss/freshrss
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.freshrss-https.redirectscheme.scheme=https"
- "traefik.http.routers.freshrss-http.entrypoints=web"
- "traefik.http.routers.freshrss-http.rule=Host(`my.freshrss.url`)"
- "traefik.http.routers.freshrss-http.middlewares=freshrss-https@docker"
- "traefik.http.routers.freshrss.entrypoints=web-secure"
- "traefik.http.routers.freshrss.rule=Host(`my.freshrss.url`)"
- "traefik.http.routers.freshrss.tls=true"
- "traefik.http.routers.freshrss.tls.certresolver=default"
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
restart: always
volumes:
- ./data/volumes/freshrss:/var/www/FreshRSS/data
nextcloud:
depends_on:
- mariadb
- redis
- traefik
- watchtower
image: nextcloud:18
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.nextcloud-caldav.redirectregex.permanent=true"
- "traefik.http.middlewares.nextcloud-caldav.redirectregex.regex=^https://(.*)/.well-known/(card|cal)dav"
- "traefik.http.middlewares.nextcloud-caldav.redirectregex.replacement=https://$${1}/remote.php/dav/"
- "traefik.http.middlewares.nextcloud-https.redirectscheme.scheme=https"
- "traefik.http.routers.nextcloud-http.entrypoints=web"
- "traefik.http.routers.nextcloud-http.rule=Host(`my.nextcloud.url`)"
- "traefik.http.routers.nextcloud-http.middlewares=nextcloud-https@docker"
- "traefik.http.routers.nextcloud.entrypoints=web-secure"
- "traefik.http.routers.nextcloud.rule=Host(`my.nextcloud.url`)"
- "traefik.http.routers.nextcloud.middlewares=nextcloud-caldav@docker"
- "traefik.http.routers.nextcloud.tls=true"
- "traefik.http.routers.nextcloud.tls.certresolver=default"
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
restart: always
volumes:
- ./data/volumes/nextcloud/html:/var/www/html
wallabag:
depends_on:
- mariadb
- redis
- traefik
- watchtower
env_file: .wallabag.env
image: wallabag/wallabag:2.3.8
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.wallabag-https.redirectscheme.scheme=https"
- "traefik.http.routers.wallabag-http.entrypoints=web"
- "traefik.http.routers.wallabag-http.rule=Host(`my.wallabag.url`)"
- "traefik.http.routers.wallabag-http.middlewares=wallabag-https@docker"
- "traefik.http.routers.wallabag.entrypoints=web-secure"
- "traefik.http.routers.wallabag.rule=Host(`my.wallabag.url`)"
- "traefik.http.routers.wallabag.tls=true"
- "traefik.http.routers.wallabag.tls.certresolver=default"
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
restart: always
volumes:
- ./data/volumes/wallabag/images:/var/www/wallabag/web/assets/images
- ./data/volumes/wallabag/data:/var/www/wallabag/data
yourls:
depends_on:
- mariadb
- traefik
- watchtower
env_file: .yourls.env
image: yourls:1.7
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.yourls-https.redirectscheme.scheme=https"
- "traefik.http.routers.yourls-http.entrypoints=web"
- "traefik.http.routers.yourls-http.rule=Host(`my.yourls.url`)"
- "traefik.http.routers.yourls-http.middlewares=yourls-https@docker"
- "traefik.http.routers.yourls.entrypoints=web-secure"
- "traefik.http.routers.yourls.rule=Host(`my.yourls.url`)"
- "traefik.http.routers.yourls.tls=true"
- "traefik.http.routers.yourls.tls.certresolver=default"
- "com.centurylinklabs.watchtower.enable=true"
networks:
- default
restart: always
volumes:
- ./data/conf/yourls/plugins:/var/www/html/user/plugins
- ./data/volumes/yourls/html:/var/www/html