From 8bb749c4a7aa8b6b527154cfffe72031eb18107a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 15 Jan 2015 22:35:29 -0700 Subject: [PATCH] updated README, add versions stub --- README.md | 31 ++++++++++++++++++++++++++++++- datamapper-ruhoh.js | 37 ++++++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a0d786f..da5dbf4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ # datamap-ruhoh -A ruhoh-compatible data mapper for desirae + +A ruhoh-compatible data mapper for [desirae](http://dear.desi) + +This mapper attempts to map both `ruhoh@1.0` (ruhoh-twitter) +and `ruhoh@2.6` (ruhoh-bootstrap-2) views onto the same object. + +As it turns out, there don't seem to be any conflicts, +but if we find out there are, we can separate into two functions. + +```bash +npm install --save desirae-datamap-ruhoh + +bower install --save desirae-datamap-ruhoh +``` + +### browser + +```javascript +Desirae.registerDataMapper('ruhoh', exports.DesiraeDatamapRuhoh); +Desirae.registerDataMapper('ruhoh@1.0', exports.DesiraeDatamapRuhoh); +Desirae.registerDataMapper('ruhoh@2.6', exports.DesiraeDatamapRuhoh); +``` + +### io.js / node.js + +```javascript +Desirae.registerDataMapper('ruhoh', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh); +Desirae.registerDataMapper('ruhoh@1.0', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh); +Desirae.registerDataMapper('ruhoh@2.6', require('desirae-datamap-ruhoh').DesiraeDatamapRuhoh); +``` diff --git a/datamapper-ruhoh.js b/datamapper-ruhoh.js index c25567e..5b05651 100644 --- a/datamapper-ruhoh.js +++ b/datamapper-ruhoh.js @@ -7,6 +7,22 @@ function map(view) { var newview + , analytics + , comments + ; + + comments = view.site.disqus_shortname && + Mustache.render(view.desi.partials.disqus, { disqus: { + shortname: view.site.disqus_shortname + , identifier: view.entity.disqus_identifier || undefined + , url: !view.entity.disqus_identifier && view.entity.disqus_url || undefined + }}) + ; + + analytics = view.site.google_analytics_tracking_id && + Mustache.render(view.desi.partials.google_analytics, { google_analytics: { + tracking_id: view.site.google_analytics_tracking_id + }}) ; newview = { @@ -46,18 +62,12 @@ , title: view.site.title } , styles: view.desi.styles.join('\n') - , assets: view.desi.styles.join('\n') // ruhoh-twitter + , assets: view.desi.styles.join('\n') // ruhoh-twitter only + , comments: comments // ruhoh-twitter only + , analytics: analytics // ruhoh-twitter only , widgets: { - comments: view.site.disqus_shortname && - Mustache.render(view.desi.partials.disqus, { disqus: { - shortname: view.site.disqus_shortname - , identifier: view.entity.disqus_identifier || undefined - , url: !view.entity.disqus_identifier && view.entity.disqus_url || undefined - }}) - , analytics: view.site.google_analytics_tracking_id && - Mustache.render(view.desi.partials.google_analytics, { google_analytics: { - tracking_id: view.site.google_analytics_tracking_id - }}) + comments: comments + , analytics: analytics , facebook_connect: view.desi.partials.facebook_connect , twitter: view.desi.partials.twitter , google_plusone: view.desi.partials.google_plusone @@ -87,5 +97,10 @@ return newview; } + // shoulda made this an object at the start... oops + map.ruhoh = map; + map['ruhoh@1.0'] = map; + map['ruhoh@2.6'] = map; + exports.DesiraeDatamapRuhoh = map.DesiraeDatamapRuhoh = map; }('undefined' !== typeof exports && exports || window));