Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Allow sharing current page

Roland Geider4c8970407b7d
diff --git a/wger/core/static/css/shariff.min.css b/wger/core/static/css/shariff.min.css
new file mode 100644
index 000000000..088b77f87
--- /dev/null
+++ b/wger/core/static/css/shariff.min.css
@@ -0,0 +1 @@
+@font-face{font-family:'FontAwesome';src:url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?v=4.2.0');src:url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'),url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'),url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'),url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.shariff::after,.shariff::before{content:" ";display:table}.shariff::after{clear:both}.shariff ul{padding:0;margin:0}.shariff li{height:30px;display:inline-block;margin-right:14px;overflow:hidden;width:120px}.shariff li:last-child{margin-right:0}.shariff li a{font-family:Arial,Helvetica,sans-serif;color:#fff;position:relative;display:block;padding-left:34px;padding-right:5px;font-size:12px;line-height:31px;text-decoration:none}.shariff li.shariff-button a::before{position:absolute;left:5px;font-family:FontAwesome;font-weight:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.shariff li.facebook a{padding-left:24px;background-color:#3b5998}.shariff li.facebook a:hover{background-color:#4273c8}.shariff li.facebook a::before{content:"\f09a";font-size:17px}.shariff li.facebook .share_count{color:#183a75;background-color:#99adcf}.shariff li.whatsapp a{padding-left:24px;background-color:#5cbe4a}.shariff li.whatsapp a:hover{background-color:#34af23}.shariff li.twitter a{background-color:#55acee}.shariff li.twitter a:hover{background-color:#32bbf5}.shariff li.twitter a::before{content:"\f099";font-size:24px}.shariff li.twitter .share_count{color:#0174a4;background-color:#96D4EE}.shariff li.googleplus a{background-color:#d34836}.shariff li.googleplus a:hover{background-color:#f75b44}.shariff li.googleplus a::before{content:"\f0d5";font-size:17px;top:1px}.shariff li.googleplus .share_count{color:#a31601;background-color:#eda79d}.shariff li.mail a{background-color:#999}.shariff li.mail a:hover{background-color:#a8a8a8}.shariff li.mail a::before{content:"\f0e0";font-size:18px}.shariff li.info{width:23px;height:28px;border:1px solid #ccc}.shariff li.info a{padding:0}.shariff li.info a::before{content:"\f129";font-size:16px;left:9px;color:#666}.shariff li.info a:hover{background-color:#efefef}.shariff li.info .share_text{display:block;text-indent:-9999px}.shariff li .share_count{padding:0 8px;height:28px;position:absolute;top:1px;right:1px;line-height:30px}.shariff .theme-grey .twitter a,.shariff .theme-grey .facebook a,.shariff .theme-grey .googleplus a,.shariff .theme-grey .mail a{background-color:#b0b0b0}.shariff .theme-grey .twitter .share_count,.shariff .theme-grey .facebook .share_count,.shariff .theme-grey .googleplus .share_count,.shariff .theme-grey .mail .share_count{background-color:#ccc;color:#333}.shariff .theme-grey .twitter a:hover{background-color:#55acee}.shariff .theme-grey .facebook a:hover{background-color:#3b5998}.shariff .theme-grey .googleplus a:hover{background-color:#d34836}.shariff .theme-grey .send_by_email a:hover{background-color:#999}.shariff .theme-white .shariff-button{border:1px solid #ddd}.shariff .theme-white .shariff-button a{background-color:#fff}.shariff .theme-white .shariff-button a:hover{background-color:#eee}.shariff .theme-white .shariff-button .share_count{background-color:#fff;color:#999}.shariff .theme-white .twitter a{color:#55acee}.shariff .theme-white .facebook a{color:#3b5998}.shariff .theme-white .googleplus a{color:#d34836}.shariff .theme-white .mail a{color:#999}.shariff .theme-white .info{height:30px}.shariff .orientation-vertical li{display:block;margin:5px 0}.shariff .orientation-vertical li .share_count{width:24px;text-align:right}.shariff .orientation-vertical li.facebook a{padding-left:34px}.shariff .orientation-vertical li.info{margin-left:95px}
\ No newline at end of file
diff --git a/wger/core/static/js/shariff.min.js b/wger/core/static/js/shariff.min.js
new file mode 100644
index 000000000..7c5dccc2f
--- /dev/null
+++ b/wger/core/static/js/shariff.min.js
@@ -0,0 +1,28 @@
+
+/*
+ * shariff - v1.4.5 - 02.12.2014
+ * https://github.com/heiseonline/shariff
+ * Copyright (c) 2014 Ines Pauer, Philipp Busse, Sebastian Hilbig, Erich Kramer, Deniz Sesli
+ * Licensed under the MIT <http://www.opensource.org/licenses/mit-license.php> license
+ */
+
+
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+"use strict";module.exports=function(e){var r=encodeURIComponent(e.getURL());return{popup:!0,shareText:{de:"teilen",en:"share"},name:"facebook",title:{de:"Bei Facebook teilen",en:"Share on Facebook"},shareUrl:"https://www.facebook.com/sharer/sharer.php?u="+r+e.getReferrerTrack()}};
+},{}],2:[function(require,module,exports){
+"use strict";module.exports=function(e){return{popup:!0,shareText:"+1",name:"googleplus",title:{de:"Bei Google+ teilen",en:"Share on Google+"},shareUrl:"https://plus.google.com/share?url="+e.getURL()+e.getReferrerTrack()}};
+},{}],3:[function(require,module,exports){
+"use strict";module.exports=function(e){return{popup:!1,shareText:"Info",name:"info",title:{de:"weitere Informationen",en:"more information"},shareUrl:e.getInfoUrl()}};
+},{}],4:[function(require,module,exports){
+"use strict";module.exports=function(e){return{popup:!1,shareText:"mail",name:"mail",title:{de:"Per E-Mail versenden",en:"Send by email"},shareUrl:e.getURL()+"?view=mail"}};
+},{}],5:[function(require,module,exports){
+(function (global){
+"use strict";var $=(typeof window !== "undefined" ? window.jQuery : typeof global !== "undefined" ? global.jQuery : null);module.exports=function(e){return{popup:!0,shareText:"tweet",name:"twitter",title:{de:"Bei Twitter teilen",en:"Share on Twitter"},shareUrl:"https://twitter.com/intent/tweet?text="+e.getShareText()+"&url="+e.getURL()+e.getReferrerTrack()}};
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+},{}],6:[function(require,module,exports){
+"use strict";module.exports=function(e){return{popup:!1,shareText:"WhatsApp",name:"whatsapp",title:{de:"Bei Whatsapp teilen",en:"Share on Whatsapp"},shareUrl:"whatsapp://send?text="+e.getShareText()+"%20"+e.getURL()+e.getReferrerTrack()}};
+},{}],7:[function(require,module,exports){
+(function (global){
+"use strict";var $=(typeof window !== "undefined" ? window.jQuery : typeof global !== "undefined" ? global.jQuery : null),_Shariff=function(t,e){var r=this;this.element=t,this.options=$.extend({},this.defaults,e,$(t).data());var n=[require("./services/facebook"),require("./services/googleplus"),require("./services/twitter"),require("./services/whatsapp"),require("./services/mail"),require("./services/info")];this.services=$.map(this.options.services,function(t){var e;return n.forEach(function(n){return n=n(r),n.name===t?(e=n,null):void 0}),e}),this._addButtonList(),null!==this.options.backendUrl&&this.getShares().then($.proxy(this._updateCounts,this))};_Shariff.prototype={defaults:{theme:"color",backendUrl:null,infoUrl:"http://ct.de/-2467514",lang:"de",orientation:"horizontal",referrerTrack:null,services:["twitter","facebook","googleplus","info"],url:function(){var t=global.document.location.href,e=$("link[rel=canonical]").attr("href")||this.getMeta("og:url")||"";return e.length>0&&(e.indexOf("http")<0&&(e=global.document.location.protocol+"//"+global.document.location.host+e),t=e),t}},$socialshareElement:function(){return $(this.element)},getLocalized:function(t,e){return"object"==typeof t[e]?t[e][this.options.lang]:"string"==typeof t[e]?t[e]:void 0},getMeta:function(t){var e=$('meta[name="'+t+'"],[property="'+t+'"]').attr("content");return e||""},getInfoUrl:function(){return this.options.infoUrl},getURL:function(){var t=this.options.url;return"function"==typeof t?$.proxy(t,this)():t},getReferrerTrack:function(){return this.options.referrerTrack||""},getShares:function(){return $.getJSON(this.options.backendUrl+"?url="+encodeURIComponent(this.getURL()))},_updateCounts:function(t){var e=this;$.each(t,function(t,r){r>=1e3&&(r=Math.round(r/1e3)+"k"),$(e.element).find("."+t+" a").append('<span class="share_count">'+r)})},_addButtonList:function(){var t=this,e=this.$socialshareElement(),r="theme-"+this.options.theme,n="orientation-"+this.options.orientation,i=$("<ul>").addClass(r).addClass(n);this.services.forEach(function(e){var r=$('<li class="shariff-button">').addClass(e.name),n='<span class="share_text">'+t.getLocalized(e,"shareText"),o=$("<a>").attr("href",e.shareUrl).append(n);e.popup?o.attr("rel","popup"):o.attr("target","_blank"),o.attr("title",t.getLocalized(e,"title")),r.append(o),i.append(r)}),i.on("click",'[rel="popup"]',function(t){t.preventDefault();var e=$(this).attr("href"),r=$(this).attr("title"),n="600",i="460",o="width="+n+",height="+i;global.window.open(e,r,o)}),e.append(i)},abbreviateText:function(t,e){var r=decodeURIComponent(t);if(r.length<=e)return t;var n=r.substring(0,e-1).lastIndexOf(" ");return r=encodeURIComponent(r.substring(0,n))+"…"},getShareText:function(){var t=this.getMeta("DC.title"),e=this.getMeta("DC.creator");return t.length>0&&e.length>0?t+=" - "+e:t=$("title").text(),encodeURIComponent(this.abbreviateText(t,120))}},module.exports=_Shariff,$(".shariff").each(function(){this.shariff=new _Shariff(this)});
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+},{"./services/facebook":1,"./services/googleplus":2,"./services/info":3,"./services/mail":4,"./services/twitter":5,"./services/whatsapp":6}]},{},[7]);
diff --git a/wger/core/templates/base.html b/wger/core/templates/base.html
index 32723f42d..9de43c4aa 100644
--- a/wger/core/templates/base.html
+++ b/wger/core/templates/base.html
@@ -1,5 +1,23 @@
{% extends "template.html" %}{% load i18n wger_extras django_bootstrap_breadcrumbs %}
{% block template %}
+<div class="modal fade" id="shariffModal">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title">{% trans "Share this page" %}</h4>
+ </div>
+ <div class="modal-body">
+ <div class="shariff"></div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
+ </div>
+ </div>
+ </div>
+</div>
+
+
{% if trainer_identity %}
<div class="alert alert-info" style="margin-top: 1em;">
{% blocktrans with current_user=user|format_username %}You are
@@ -10,7 +28,21 @@ browsing the site as the user "{{current_user}}", all actions are performed on h
</a>
</div>
{% endif %}
-<h2 id="page-title" class="page-header">{% block title %}{% endblock %}</h2>
+
+<button type="button"
+ class="btn btn-default btn-xs pull-right"
+ data-toggle="modal"
+ data-target="#shariffModal"
+ style="margin-top: 0.5em;">
+ <span class="glyphicon glyphicon-retweet"></span>
+ {% trans "Share" %}
+</button>
+
+
+<h2 id="page-title" class="page-header">
+ {% block title %}{% endblock %}
+</h2>
+
<div class="row">
<div class="col-sm-8" id="main-content">
{% if messages and not no_messages %}
diff --git a/wger/core/templates/mobile/template.html b/wger/core/templates/mobile/template.html
index 223c8f0e6..0915892d6 100644
--- a/wger/core/templates/mobile/template.html
+++ b/wger/core/templates/mobile/template.html
@@ -37,15 +37,16 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-custom.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager-common.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager-mobile.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/shariff.min.css' %}">
{% endcompress %}
{% compress js %}
- <script src="{% static 'js/jquery.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/bootstrap.min.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/jquery.js' %}"></script>
+ <script src="{% static 'js/jquery-ui.js' %}"></script>
+ <script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/d3.js' %}"></script>
- <script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/workout-manager-mobile.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/workout-manager.js' %}"></script>
+ <script src="{% static 'js/workout-manager-mobile.js' %}"></script>
<script src="{% static 'js/exercises.js' %}"></script>
<script src="{% static 'js/weight.js' %}"></script>
<script src="{% static 'js/nutrition.js' %}"></script>
@@ -177,6 +178,7 @@
{% endif %}
</div>
+<script src="{% static 'js/shariff.min.js' %}"></script>
<script src="https://login.persona.org/include.js" type="text/javascript"></script>
</body>
</html>
diff --git a/wger/core/templates/template.html b/wger/core/templates/template.html
index dd38f87e1..dafe9417e 100644
--- a/wger/core/templates/template.html
+++ b/wger/core/templates/template.html
@@ -35,21 +35,22 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-custom.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/datepicker3.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/shariff.min.css' %}">
{% endcompress %}
<link rel="icon" href="{% static 'images/favicon.png' %}" type="image/png">
{% compress js %}
- <script src="{% static 'js/jquery.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/d3.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/ubuntu-unity.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/bootstrap.min.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/bootstrap-datepicker/bootstrap-datepicker.min.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/exercises.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/weight.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/nutrition.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/jquery.js' %}"></script>
+ <script src="{% static 'js/jquery-ui.js' %}"></script>
+ <script src="{% static 'js/d3.js' %}"></script>
+ <script src="{% static 'js/workout-manager.js' %}"></script>
+ <script src="{% static 'js/ubuntu-unity.js' %}"></script>
+ <script src="{% static 'js/bootstrap.min.js' %}"></script>
+ <script src="{% static 'js/bootstrap-datepicker/bootstrap-datepicker.min.js' %}"></script>
+ <script src="{% static 'js/exercises.js' %}"></script>
+ <script src="{% static 'js/weight.js' %}"></script>
+ <script src="{% static 'js/nutrition.js' %}"></script>
{% endcompress %}
{% if language.short_name != 'en' %}
@@ -133,7 +134,11 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+ <button type="button"
+ class="close"
+ data-dismiss="modal"
+ aria-hidden="true"
+ style="padding-left: 0.5em;">&times;</button>
<h4 class="modal-title" id="ajax-info-title">Modal title</h4>
</div>
<div class="modal-body" id="ajax-info-content">
@@ -148,20 +153,24 @@
<div id="current-language" data-current-language="{{language.short_name}}"></div>
- {% if not user.is_authenticated or user.userprofile.is_temporary %}
+ {# #}
+ {# Guest users #}
+ {# #}
+ {# {% if not user.is_authenticated or user.userprofile.is_temporary %} #}
+ {% if user.is_authenticated and user.userprofile.is_temporary %}
<div class="alert alert-warning" role="alert" style="padding:0.6em; margin-top: 1em; text-align:center; font-size:95%;">
- {% trans "You are using a guest account, data entered will be deleted after a week."%}
- {% if not has_demo_data %}
- <a href="{% url 'core:user:demo-entries' %}" rel="nofollow" class="btn btn-success btn-xs">
- {% trans "Create some demo entries" %}
- <span class="glyphicon glyphicon-chevron-right"></span>
- </a>
- {% else %}
- <a href="{% url 'core:user:registration' %}" class="btn btn-success btn-xs">
- {% trans "Register" %}
+ {% trans "You are using a guest account, data entered will be deleted after a week." %}
+ {% if not has_demo_data %}
+ <a href="{% url 'core:user:demo-entries' %}" rel="nofollow" class="btn btn-success btn-xs">
+ {% trans "Create some demo entries" %}
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
- {% endif %}
+ {% else %}
+ <a href="{% url 'core:user:registration' %}" class="btn btn-success btn-xs">
+ {% trans "Register" %}
+ <span class="glyphicon glyphicon-chevron-right"></span>
+ </a>
+ {% endif %}
</div>
{% endif %}
{% block template %}{% endblock %}
@@ -189,5 +198,7 @@
</div>
</div>
</footer>
+
+<script src="{% static 'js/shariff.min.js' %}"></script>
</body>
</html>
diff --git a/wger/core/templates/template_features.html b/wger/core/templates/template_features.html
index 84af52343..3f60b5c58 100644
--- a/wger/core/templates/template_features.html
+++ b/wger/core/templates/template_features.html
@@ -32,21 +32,22 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap-custom.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'css/datepicker3.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/shariff.min.css' %}">
{% endcompress %}
<link rel="icon" href="{% static 'images/favicon.png' %}" type="image/png">
{% compress js %}
- <script src="{% static 'js/jquery.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/d3.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/ubuntu-unity.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/bootstrap.min.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/bootstrap-datepicker/bootstrap-datepicker.min.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/exercises.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/weight.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/nutrition.js' %}" type="text/javascript"></script>
+ <script src="{% static 'js/jquery.js' %}"></script>
+ <script src="{% static 'js/jquery-ui.js' %}"></script>
+ <script src="{% static 'js/d3.js' %}"></script>
+ <script src="{% static 'js/workout-manager.js' %}"></script>
+ <script src="{% static 'js/ubuntu-unity.js' %}"></script>
+ <script src="{% static 'js/bootstrap.min.js' %}"></script>
+ <script src="{% static 'js/bootstrap-datepicker/bootstrap-datepicker.min.js' %}"></script>
+ <script src="{% static 'js/exercises.js' %}"></script>
+ <script src="{% static 'js/weight.js' %}"></script>
+ <script src="{% static 'js/nutrition.js' %}"></script>
{% endcompress %}
<title>wger Workout Manager - {% trans "Features" %}</title>
@@ -86,5 +87,7 @@
</div>
</div>
</footer>
+
+<script src="{% static 'js/shariff.min.js' %}"></script>
</body>
</html>