Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
• change font to systems default font
• add warning when no services activated
• add credits in Options page
• improve extension description
• add other omnibox command keywords
  • Loading branch information
Devenet committed Sep 8, 2016
1 parent fe7c745 commit 4daa3d5
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 21 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ![SimpleShare](https://raw.githubusercontent.com/Devenet/SimpleShare/master/images/icon-19.png) Simple Share

Chrome extension to Simple Share your current tab by email, to your social networks or your Shaarli!

> Add a “Simple Share” button to share your current tab to your social networks (Facebook, Twitter), to a friend by email or to your Shaarli.
You can customize the extension to enable only services you want :)

> Use the Omnibox for directly share the page with the keyword “share”.
***

Your help is welcome to translate the extension in other languages :)
5 changes: 4 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extension_description": {
"message": "Simple share the URL of your current tab by email, to social networks or to your Shaarli!",
"message": "Simple share your current tab by email, to your social networks or your Shaarli!",
"description": "Extension description."
},
"browser_action_title": {
Expand Down Expand Up @@ -30,6 +30,9 @@
"share_unknow_command": {
"message": "Unknow command!"
},
"share_services_disabled": {
"message": "No services activated :("
},

"settings_name": {
"message": "Options",
Expand Down
5 changes: 4 additions & 1 deletion _locales/fr/messages.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extension_description": {
"message": "Partager simplement l’URL de votre page actuelle par email, sur vos réseaux sociaux ou sur votre Shaarli !",
"message": "Partager simplement votre onglet courant par email, sur vos réseaux sociaux ou sur votre Shaarli !",
"description": "Extension description"
},
"browser_action_title": {
Expand All @@ -16,6 +16,9 @@
"share_unknow_command": {
"message": "Commande inconnue !"
},
"share_services_disabled": {
"message": "Aucun service activé :("
},

"settings_services": {
"message": "Services"
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Simple Share",
"short_name": "Share",

"version": "0.0.4",
"version": "1.0.0",

"icons": {
"16": "images/icon-16.png",
Expand All @@ -29,7 +29,7 @@
},

"author": "Nicolas Devenet",
"homepage_url": "http://simpleshare.chrome.devenet.info",
"homepage_url": "https://github.com/Devenet/SimpleShare",
"options_page": "options.html",

"omnibox": { "keyword" : "share" },
Expand Down
8 changes: 8 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ <h3 id="i18n-advanced"></h3>
</p>
</form>
</div>

<div class="container credits">
<h3 class="espace-top-lg">Credits</h3>
<p>This extension was made with &hearts; by <a href="https://nicolas.devenet.info" target="_blank">Nicolas Devenet</a>. Enjoy :)
<br>Feel free to improve it on <a href="https://github.com/Devenet/SimpleShare" target="_blank">Github</a>.</p>
</div>



<script src="scripts/options.js"></script>
</body>
Expand Down
27 changes: 13 additions & 14 deletions scripts/bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ var items = { email:1, facebook:0, shaarli:0, twitter:1 };
items = !localStorage['settings.share.items'] ? items : JSON.parse(localStorage['settings.share.items']);
var suggests = [];
for (var item in items) {
if (items[item]) {
if (items[item] || item == 'facebook' || item == 'twitter' || item == 'email') {
suggests.push({ content: item, description: item + ' &#8227; ' + chrome.i18n.getMessage('share_' + item) });
}
}


chrome.omnibox.onInputChanged.addListener(function(text, suggest) {
if (items.email) {
var c = /email\s+.*/i.test(text) ? text : 'email ' + text;
var d = 'email &#8227; ' + chrome.i18n.getMessage('share_email')
+ ( text.length > 0 ? ' ' + chrome.i18n.getMessage('global_to') + ' ' + text : '');

suggests[0] = { content: c, description: d };
}
var c = /email\s+.*/i.test(text) ? text : 'email ' + text;
var d = 'email &#8227; ' + chrome.i18n.getMessage('share_email')
+ ( text.length > 0 ? ' ' + chrome.i18n.getMessage('global_to') + ' ' + text : '');
suggests[0] = { content: c, description: d };

suggest(suggests);
});

Expand Down Expand Up @@ -47,7 +45,7 @@ chrome.omnibox.onInputEntered.addListener(function(text) {
}
else { chrome.tabs.create({url: result}); }
}
else { alert(chrome.i18n.getMessage('share_unknow_command')); }
else if (result === null) {alert(chrome.i18n.getMessage('share_unknow_command')); }
});
});

Expand All @@ -57,26 +55,27 @@ function buildShareURL(method, url, title) {
switch(method) {
case 'shaarli':
if (!localStorage['settings.shaarli.url']) {
var share_msg = document.getElementById('share-msg');
share_msg.innerHTML = '<p>' + chrome.i18n.getMessage('share_shaarli_missing_url') + ' &#8227; <a href="'
+ chrome.extension.getURL('options.html')
+ '" target="_blank">' + chrome.i18n.getMessage('settings_name') + '</a></p>';
break;
alert(chrome.i18n.getMessage('share_shaarli_missing_url'));
return false;
}
result = localStorage['settings.shaarli.url'] + '/?post=' + encodeURI(url)
+ '&title=' + encodeURI(title);
break;

case 'email':
case 'mail':
case 'courriel':
result = 'mailto:?' + 'subject=' + encodeURI(title) + '&body=' + encodeURI(url);
break;

case 'twitter':
case 'twr':
result = 'https://twitter.com/intent/tweet' + '?text=' + encodeURI(title)
+ '&url=' + encodeURI(url);
break;

case 'facebook':
case 'fb':
result = 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURI(url)
+ '&t=' + encodeURI(title);
break;
Expand Down
21 changes: 19 additions & 2 deletions scripts/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for (var i=0, l=links.length; i<l; i++) {
else { chrome.tabs.create({url: result}); }
}
});

return true;
});
}
Expand All @@ -40,13 +40,24 @@ for (var i=0, l=links.length; i<l; i++) {
}
}

// everything is disabled
if (count_services(items) === 0) {
document.querySelector(".i18n-share").style.display = 'none';
document.getElementById('services_disabled').innerHTML = chrome.i18n.getMessage('share_services_disabled')
+ '<br><a href="' + chrome.extension.getURL('options.html') + '" target="_blank">'
+ chrome.i18n.getMessage('settings_name') + '</a>';
}
else {
document.getElementById('services_disabled').style.display = 'none';
}

function buildShareURL(method, url, title) {
var result = null;
switch(method) {
case 'shaarli':
if (!localStorage['settings.shaarli.url']) {
var share_msg = document.getElementById('share-msg');
share_msg.innerHTML = '<p>' + chrome.i18n.getMessage('share_shaarli_missing_url') + ' &#8227; <a href="'
share_msg.innerHTML = '<p class="espace-top-xs">' + chrome.i18n.getMessage('share_shaarli_missing_url') + ' &#8227; <a href="'
+ chrome.extension.getURL('options.html')
+ '" target="_blank">' + chrome.i18n.getMessage('settings_name') + '</a></p>';
break;
Expand All @@ -70,4 +81,10 @@ function buildShareURL(method, url, title) {
break;
}
return result;
}

function count_services(items) {
total = 0;
for (var property in items) { total += items[property]; }
return total;
}
2 changes: 2 additions & 0 deletions share.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<li><a class="bg-sh" href="#shaarli"></a></li>
<li><a class="bg-tw" href="#twitter"></a></li>
</ul>

<p class="txt-center" id="services_disabled"></p>

<!--<p class="txt-center"><a href="options.html"></a></p>-->
<div id="share-msg"></div>
Expand Down
6 changes: 5 additions & 1 deletion styles/global.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
body { width: 200px; }
body {
width: 200px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
ul {
padding: 0;
margin: 0;
Expand Down Expand Up @@ -36,6 +39,7 @@ input:focus, input:active {

.espace-top { margin-top: 20px; }
.espace-top-lg { margin-top: 40px; }
.espace-top-xs { margin-top: 5px; }

.bg-fb { background-color: #3b5998; }
.bg-fb:hover { background-color: #6d84b4; }
Expand Down
6 changes: 6 additions & 0 deletions styles/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ h3 {
margin: 20px 0 10px;
border-bottom: 4px solid #efefef;
padding-bottom: 5px;
}

.credits { color: #888; }
.credits h3 {
border-bottom: 2px solid #efefef;
font-weight: normal;
}

0 comments on commit 4daa3d5

Please sign in to comment.