Moving to a templated publication list.

pull/1/head
Oliver Kennedy 2016-10-23 20:43:42 -04:00
parent e70985b837
commit 8d656d4630
8 changed files with 58 additions and 51 deletions

View File

@ -228,4 +228,12 @@ module LabMetadata
end
end
@@publication_erb = File.open("lib/publication.erb"){ |f| ERB.new(f.readlines.join) }
def LabMetadata.render_pub(pub)
b = binding()
b.local_variable_set(:pub, pub)
@@publication_erb.result(b)
end
end

28
lib/publication.erb Normal file
View File

@ -0,0 +1,28 @@
<%
bibtexdiv = "bibtex-#{LabMetadata.shortname_for(pub).gsub(/:/,"")}"
links = [
"<a onclick=\"$('##{bibtexdiv}').toggle();\">bibtex</a>"
];
links += pub.fetch("urls", []).
to_a.
map {|r,url| "<a href=\"#{url}\">#{r}</a>"}
%>
<li>
<div class="title"><%= pub["title"] %>
<span class="paper_links">[ <%= links.join(" | ") %> ]</span>
</div>
<div class="authors"><%= pub["authors"].map { |author| LabMetadata::link_for author }.join(", ") %></div>
<div class="metadata"><span class="venue"><%= pub["venue"] %> <%= pub["year"] %></span>
<%
type = LabMetadata.complete_venue(pub)["type"]
case type
when nil, "conference", "journal" then "ignore"
when "techreport" then %>(Tech Report)<%
else %>(<%= type.capitalize %>)<%
end
%></div>
<pre class-"well" id="<%=bibtexdiv%>" style="display:none; margin-left: auto; margin-right: auto; max-width: 600px; font-size: 8pt;"><%= LabMetadata.bibtex_for pub %></pre>
</li>

View File

@ -6,26 +6,11 @@ title: Publications
<div class="paper_list">
<% $db["publications"].map { |pub| [pub["year"].to_i, pub] }.reduce.each do |year, pubs| %>
<h2><%= year %></h2>
<ul><% pubs.each do |pub| %>
<% bibtexdiv = "bibtex-#{LabMetadata.shortname_for(pub).gsub(/:/,"")}" %>
<% if pub.fetch("visible", true) %>
<li>
<div class="title"><%= pub["title"] %></div>
<div class="authors"><%= pub["authors"].map { |author| LabMetadata::link_for author }.join(", ") %></div>
<div class="metadata"><span class="venue"><%= pub["venue"] %></span>
<%
links = [
"<a onclick=\"$('##{bibtexdiv}').toggle();\">bibtex</a>"
];
links += pub.fetch("urls", []).
to_a.
map {|r,url| "<a href=\"#{url}\">#{r}</a>"}
%>
( <%= links.join(" | ") %> )</span></div>
<pre class-"well" id="<%=bibtexdiv%>" style="display:none; margin-left: auto; margin-right: auto; max-width: 600px; font-size: 8pt;"><%= LabMetadata.bibtex_for pub %></pre>
</li>
<ul><% pubs.each do |pub|
if pub.fetch("visible", true) %>
<%= LabMetadata.render_pub pub %>
<% end %>
<% end %></ul>
<% end %>
</ul>
<% end %>
</div>

View File

@ -25,11 +25,10 @@ title: ASTral
<h2>Publications</h2>
<ul>
<ul class="paper_list">
<% $db["publications"].
where { |pub| pub.fetch("projects", []).include? "astral" }.
each do |pub| %>
<li><b><%=pub["title"]%></b><br/> <i><%=pub["venue"]%></i>
<% if pub.has_key? "urls" %>( <span class="resources"><%= pub["urls"].map { |r, url| "<a href=\"#{url}\">#{r}</a>"}.join(" | ") %></span> )<%end%></li>
<% end %>
<%= LabMetadata.render_pub(pub) %>
<% end %>
</ul>

View File

@ -21,13 +21,12 @@ datasets:
<h2>Publications</h2>
<ul>
<ul class="paper_list">
<% $db["publications"].
where { |pub| pub.fetch("projects", []).include? "insider-threats" }.
each do |pub| %>
<li><b><%=pub["title"]%></b><br/> <i><%=pub["venue"]%></i>
<% if pub.has_key? "urls" %>( <span class="resources"><%= pub["urls"].map { |r, url| "<a href=\"#{url}\">#{r}</a>"}.join(" | ") %></span> )<%end%></li>
<% end %>
<%= LabMetadata.render_pub(pub) %>
<% end %>
</ul>
<hr />

View File

@ -78,16 +78,13 @@ libraryDependencies += "info.mimirdb" %% "mimir" % "0.1-SNAPSHOT"
<hr/>
<h1>Publications</h1>
<ul><%
$db["publications"].
where { |pub| pub.fetch("projects", []).include? "mimir" }.
each do |pub|
%>
<div class="pub"><strong><%=pub["title"]%></strong>&nbsp;&nbsp;&nbsp;<i><%=pub["venue"]%></i><% if pub.has_key? "urls" %>
&nbsp;&nbsp;&nbsp;( <span class="resources"><%= pub["urls"].map { |r, url| "<a href=\"#{url}\">#{r}</a>"}.join(" | ") %></span> )
<% end %></div>
<% end %>
</ul>
<div class="paper_list">
<% $db["publications"].
where { |pub| pub.fetch("projects", []).include? "mimir" }.
each do |pub| %>
<%= LabMetadata.render_pub(pub) %>
<% end %>
</div>
<hr/>

View File

@ -22,13 +22,12 @@ title: PocketData
<h2>Publications</h2>
<ul>
<ul class="paper_list">
<% $db["publications"].
where { |pub| pub.fetch("projects", []).include? "pocketdata" }.
each do |pub| %>
<li><b><%=pub["title"]%></b><br/> <i><%=pub["venue"]%></i>
<% if pub.has_key? "urls" %>( <span class="resources"><%= pub["urls"].map { |r, url| "<a href=\"#{url}\">#{r}</a>"}.join(" | ") %></span> )<%end%></li>
<% end %>
<%= LabMetadata.render_pub(pub) %>
<% end %>
</ul>
<h2>Resources</h2>

View File

@ -16,15 +16,7 @@
<h2>Publications</h2>
<div class="paper_list">
<% LabMetadata::publications_for(name).each do |pub| %>
<li><div class="title"><%= pub["title"] %></div>
<div class="authors"><%= pub["authors"].map { |author| LabMetadata::link_for author }.join(", ") %></div>
<div class="metadata"><span class="venue"><%= pub["venue"] %><% unless pub["track"].nil? %>-<%=pub["track"]%><%end%></span>
<% if pub.has_key? "urls" %>
( <span class="resources"><%= pub["urls"].map { |r, url| "<a href=\"#{url}\">#{r}</a>"}.join(" | ") %></span> )</div>
<% end %>
</li>
<% end %>
<% LabMetadata::publications_for(name).each { |pub| %> <%= LabMetadata.render_pub(pub) %> <% } %>
</div>
</div>