Permalink
Browse files

ICanHaz.js templating handles all biblio printing

  • Loading branch information...
1 parent 01f3270 commit f180698c366ea0b79d1391cb4cfd1918547ad5b0 @jasonpriem jasonpriem committed May 22, 2012
View
31 totalimpactwebapp/static/js/total-impact-ui.js
@@ -79,37 +79,24 @@ addIdsToEditPane = function(returnedIds){
}
+
function renderItemBiblio(biblio, url) {
var html = ""
- if (typeof biblio.author == "object") {
- var authors = biblio.author.join(",");
- }
- else {
- var authors = "";
+
+ biblio.url = url;
+ biblio.title = biblio.title || "no title";
+ if (biblio.create_date) {
+ biblio.year = biblio.create_date.slice(0,4)
}
- var title = (biblio.title) ? biblio.title : "no title";
- var repo = (biblio.repository) ? biblio.repository : "";
+ var templateName = "biblio_" + biblio.genre
+ html = ich[templateName](biblio, true)
- if (biblio.genre == "dataset") {
- html += "<span class='author'>"+authors+"</span>";
- html += "<span class='year'>"+biblio.year+"</span>";
- if (url){
- html += "<a class='url title' href='"+url+"'>"+title+"</a>"
- }
- html += "<span class='repo'>"+repo+"</span>"
- }
- else if (biblio.genre == "article") {
- html = "article not implemented"
- }
- else {
- html = "other stuff not implemented"
- }
+
return html
}
function renderItem(item){
- console.log(item.aliases.doi)
console.log(item.biblio.genre)
console.log(item)
View
7 totalimpactwebapp/static/report.css
@@ -254,10 +254,15 @@ div.biblio {
margin:0;
padding:0;
color:#222;
+ font-size: 14px;
+}
+
+div.biblio h5 {
+ display: inline;
+ font-size:1em;
}
div.biblio span.year {
- margin-right: 8px;
color:#aaa;
}
View
1 totalimpactwebapp/templates/base.html
@@ -24,6 +24,7 @@
<script type="text/javascript" src="/static/js/jquery.tooltip.js"></script>
<script type="text/javascript" src="/static/js/jquery.zclip.js"></script>
<script type="text/javascript" src="/static/js/jquery.color.js"></script>
+ <script type="text/javascript" src="/static/js/icanhaz.min.js"></script>
<script type="text/javascript" src="/static/js/total-impact-ui.js"></script>
<script type="text/javascript">
// google analytics code
View
49 totalimpactwebapp/templates/collection.html
@@ -37,5 +37,54 @@ <h2 class="updating"><img src="../static/img/ajax-loader-rev.gif" alt="spinning
</div>
<p class="something-missing">More detail on <a href="./about/#whichmetrics">available metrics</a>. Missing some artifacts or metrics? See <a href="./about/#limitations">current limitations.</a> </p>
</div>
+ {% raw %}
+ <div id="templates">
+ <!-- These templates are for rendering items with javascript using
+ Mustache -->
+ <script id="title" class="partial" type="text/html">
+ <h5>
+ {{#url}}
+ <a class="url title" href="{{ url }}">{{ title }}</a>
+ {{/url}}
+ {{^url}}
+ {{ title }}
+ {{/url}}
+ </h5>
+ </script>
+
+ <script id="biblio_dataset" type="text/html">
+ {{#year}}
+ <span class="year">{{ year }}</span>
+ {{/year}}
+ {{>title}}
+ <span class="repo">{{ repository }}</span>
+ </script>
+ <script id="biblio_article" type="text/html">
+ <span class="authors">{{ authors }}</span>
+ {{#year}}
+ <span class="year">{{ year }}</span>
+ {{/year}}
+ {{>title}}
+ <span class="repo">{{ journal }}</span>
+ </script>
+ <script id="biblio_webpage" type="text/html">
+ {{>title}}
+ </script>
+ <script id="biblio_slides" type="text/html">
+ {{>title}}
+ <span class="repo">Slideshare</span>
+ </script>
+ <script id="biblio_software" type="text/html">
+ <span class="year">{{ year }}</span>
+ {{>title}}
+ <span class="descr">{{ description }}</span>
+ <span class="repo">GitHub</span>
+ </script>
+ <script id="biblio_unknown" type="text/html">
+ {{>title}}
+ </script>
+
+ </div>
+ {% endraw %}
{% endblock %}

0 comments on commit f180698

Please sign in to comment.