Skip to content

Commit

Permalink
adding sharelinks for facebook, twitter, google+ and linkedin
Browse files Browse the repository at this point in the history
  • Loading branch information
mosbth committed Feb 24, 2014
1 parent c455aab commit 8735eab
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ v0.3.x (latest)
* Included new version of `style.php` to support child themes using lessphp.
* Correcting `$config['static_url']`.
* Moved `loadView()` to `src/bootstrap.php`.
* Changed formatting of CTextFilter [book] (should reengineer to remove from base).
* Changed formatting of CTextFilter [book](should reengineer to remove from base).
* Added sharelinks to linkedin, twitter, facbook, google+ for articles.


v0.3.95 (2013-10-21)
Expand Down
5 changes: 4 additions & 1 deletion site/themes/dbwebb/style/dbwebb.less
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ html.dbwebb {
}

a[href^="http://dbwebb.se"],
a[href^="http://www2.dbwebb.se"],
a[href^="http://www5.dbwebb.se"],
figure a[href^="http"] {
padding-right: 0;
background: none;
Expand All @@ -74,7 +76,8 @@ html.dbwebb {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAMCAYAAABbayygAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAZ0lEQVR4nGNgIAmknfmPjGXLL/2v3/T0P1aFyIAh7cx/49ZrWBSnnfn/8O3//2ceQDBD2pn/zz78/6/biK447cz/pSf//09bDMHozsBpIgw/fAvVhMtEGF56EotC6puIC2AoxItJAQBnweOKFBvqdQAAAABJRU5ErkJggg==') no-repeat scroll right center transparent;
}

.geshi a {
.geshi a,
.share-icons a {
padding-right: 0;
background: none;
}
Expand Down
5 changes: 5 additions & 0 deletions site/themes/dbwebb/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,9 @@ figure.center img {
figure.center figcaption {
text-align: center;
}
figure.border {
border: 1px solid #ccc;
}
#banner {
position: relative;
}
Expand Down Expand Up @@ -1879,6 +1882,8 @@ html.dbwebb a[href^="http"] {
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=") no-repeat scroll right center transparent;
}
html.dbwebb a[href^="http://dbwebb.se"],
html.dbwebb a[href^="http://www2.dbwebb.se"],
html.dbwebb a[href^="http://www5.dbwebb.se"],
html.dbwebb figure a[href^="http"] {
padding-right: 0;
background: none;
Expand Down
9 changes: 9 additions & 0 deletions themes/base/style/figure.less
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ figure.center {
text-align: center;
}
}



/** --------------------------------------------------------------
* Figure with border
*/
figure.border {
border: 1px solid #ccc;
}
15 changes: 14 additions & 1 deletion themes/base/style/links.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ a[href$=".pdf"] {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAMCAYAAABbayygAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAZ0lEQVR4nGNgIAmknfmPjGXLL/2v3/T0P1aFyIAh7cx/49ZrWBSnnfn/8O3//2ceQDBD2pn/zz78/6/biK447cz/pSf//09bDMHozsBpIgw/fAvVhMtEGF56EotC6puIC2AoxItJAQBnweOKFBvqdQAAAABJRU5ErkJggg==') no-repeat scroll right center transparent;
}

.geshi a {
.geshi a,
.share-icons a {
padding-right: 0;
background: none;
}
Expand Down Expand Up @@ -322,6 +323,18 @@ ul.icons {
padding: 0;
margin: 0;
}

a img {
opacity: 0.6;
}

a:hover img {
opacity: 0.8;
}

a:active img {
opacity: 1;
}
}

div.icons {
Expand Down
1 change: 1 addition & 0 deletions themes/base/style/lydia.less
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ body {
.clearfix();
padding: 1em;
border: 1px solid #ccc;
margin-bottom: @magicNumber;
//font-size: smaller;
}

Expand Down
49 changes: 49 additions & 0 deletions themes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,52 @@ function slogan() {
return $ly->config['theme']['data']['site-slogan'];
}



/**
* Get link to share on Facebook.
*/
function get_facebook_share_link($permalink, $text) {
$link = "http://www.facebook.com/sharer.php?u=$permalink&t=text";
return $link;
}


/**
* Get link to share on Twitter.
*/
function get_twitter_share_link($permalink, $text) {
$link = "http://twitter.com/share?text=$text&url=$permalink";
return $link;
}


/**
* Get link to share on Google+.
*/
function get_googleplus_share_link($permalink, $text) {
$link = "https://plus.google.com/share?url=$permalink";
return $link;
}


/**
* Get link to share on LinkedIn.
*/
function get_linkedin_share_link($permalink, $text) {
$link = "https://www.linkedin.com/cws/share?url=$permalink&title=$text";
return $link;
}



/**
* Get permalink to current page.
*/
function get_permalink() {
global $ly;
$link = $ly->request->GetCurrentUrl();
return $link;
}


20 changes: 19 additions & 1 deletion views/CCBlog/post.tpl.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?php if($content != null):?>

<?php
$title = esc($content['title']);
$permalink = get_permalink();
?>

<article class='ly-blog' itemscope itemtype='http://schema.org/Article'>

<header class='ly-blog-post-header'>
<h1 itemprop='name headline'><?=esc($content['title'])?></h1>
<h1 itemprop='name headline'><?=$title?></h1>
<?php
$date = $order_by_updated ? $content['updated'] : $content['created'];
$what = $order_by_updated ? t('Updated') : t('Published');
Expand All @@ -21,10 +26,23 @@
<?php if($user_is_admin || $contents->CurrentUserIsOwner()): ?>
| <a href='<?=create_url("content/edit/{$content['id']}")?>'><?=t('edit')?></a></p>
<?php endif; ?>

</footer>

<?=get_author_byline($author)?>



<footer class='share-icons'>
<ul class='icons'>
<li><h3>Dela denna artikel på </h3></li>
<li><a href='<?=get_facebook_share_link($permalink, $title)?>'><img src='/img/glyphicons/png/glyphicons_390_facebook.png' alt='facebook-icon' title='Dela på Facebook' width='24' height='24'/></a></li>
<li><a href='<?=get_twitter_share_link($permalink, $title)?>'><img src='/img/glyphicons/png/glyphicons_392_twitter.png' alt='twitter-icon' title='Dela på Twitter' width='24' height='24'/></a></li>
<li><a href='<?=get_googleplus_share_link($permalink, $title)?>'><img src='/img/glyphicons/png/glyphicons_362_google+_alt.png' alt='google+-icon' title='Dela på Google+' width='24' height='24'/></a></li>
<li><a href='<?=get_linkedin_share_link($permalink, $title)?>'><img src='/img/glyphicons/png/glyphicons_377_linked_in.png' alt='linkedin-icon' title='Dela på LinkedIn' width='24' height='24'/></a></li>
</ul>
</footer>

</article>

<?php else:?>
Expand Down

0 comments on commit 8735eab

Please sign in to comment.