Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

require GimmeAsset from it's own file; make addthis_pubid a config op…

…tion and don't include add this JS if it's not set
  • Loading branch information...
commit f90928eecda698366b4aea79abd3cde49bd68b47 1 parent 1a78710
@funkatron authored
View
4 index.php
@@ -2,11 +2,13 @@
require('vendors/Mustache.php');
require('vendors/Router.php');
require('templates/templates.php');
+require('libs/GimmeAsset.php');
require('libs/GimmeMe.php');
// config
$config = array();
-$config['gb_username'] = 'funkatron';
+$config['gb_username'] = 'funkatron'; // fill in your gimme bar username
+$config['gb_addthis_pubid'] = 'ra-4e9a50eb30ab82ff'; // fill in your addthis pubid
$config['gb_collection'] = null; // not supported ATM
$config['gb_cache_ttl'] = 15*60; // 15 minutes
$config['templates'] = $templates; // array, comes from templates/templates.php
View
5 libs/GimmeMe.php
@@ -10,6 +10,7 @@ class GimmeMe {
protected $gb_username = 'funkatron';
protected $gb_collection = null;
protected $gb_cache_ttl = 900; // 15m default
+ protected $gb_addthis_pubid = null; // default
public function __construct($opts=array()) {
$this->opts = $opts;
@@ -17,6 +18,7 @@ public function __construct($opts=array()) {
$this->gb_username = isset($opts['gb_username']) ? $opts['gb_username'] : null;
$this->gb_collection = isset($opts['gb_collection']) ? $opts['gb_collection'] : null;
$this->gb_cache_ttl = isset($opts['gb_cache_ttl']) ? $opts['gb_cache_ttl'] : null;
+ $this->gb_addthis_pubid = isset($opts['gb_addthis_pubid']) ? $opts['gb_addthis_pubid'] : null;
}
public function go() {
@@ -47,6 +49,9 @@ protected function getAssets(array $opts=null) {
$json = file_get_contents($url);
$assets = json_decode($json);
$assets->username = $this->gb_username;
+ if (!empty($this->gb_addthis_pubid)) {
+ $assets->addthis_pubid = $this->gb_addthis_pubid;
+ }
apc_store($ck, $assets, $this->gb_cache_ttl);
unset($json);
View
4 main.css
@@ -117,4 +117,6 @@ h3.record-meta {
.record-description {
font-style: italic;
-}
+}
+
+
View
13 templates/templates.php
@@ -1,5 +1,5 @@
<?php
-// templates
+// a bunch of mustache templates
$templates = array();
$templates['page'] = <<< EOF
<html>
@@ -28,19 +28,22 @@
</div><!-- #container -->
+{{#addthis_pubid}}
<!-- AddThis Button BEGIN -->
-<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e9a50eb30ab82ff"></script>
+<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid={{addthis_pubid}}"></script>
<!-- AddThis Button END -->
+{{/addthis_pubid}}
</body>
</html>
EOF;
$templates['partials']['record'] = <<< EOF
<li class="record">
- <a name="media_hash"></a>
+ <a name="asset-{{id}}"></a>
<h2 class="record-title"><a href="{{short_url}}">{{title}}</a></h2>
<h3 class="record-meta">
- {{nice_date}} &mdash; <a href="{{source}}" class="record-source">source</a> &mdash; <a href="{{short_url}}" class="permalink">#</a>
+ {{nice_date}} &mdash; <a href="{{source}}" class="record-source">source</a>
+ &mdash; <a href="#asset-{{id}}" class="permalink">#</a>
</h3>
<div class="record-content">
@@ -57,7 +60,7 @@
</div>
{{#description}}
- <div class="record-description">{{description}}</div>
+ <div class="record-description">{{{formatted_description}}}</div>
{{/description}}
<div id="share-{{id}}" class="addthis_toolbox addthis_default_style"
Please sign in to comment.
Something went wrong with that request. Please try again.