Commit d7620888 authored by Hiren Patel's avatar Hiren Patel

Add acmpdf link for authorizer and separate utlities for extras

parent f94ec91f
require 'jekyll/scholar'
#require 'jekyll/scholar/extras/extra_utils'
require 'jekyll/scholar/extras/extras_utilities'
require 'jekyll/scholar/extras/bibliography_year'
require 'jekyll/scholar/extras/bibliography_bytype'
#require 'jekyll/scholar/extras/details_hdp'
#require 'jekyll/scholar/tags/cite_details_dep'
......@@ -3,6 +3,7 @@ module Jekyll
class BibliographyTagByType < Liquid::Tag
include Scholar::Utilities
include ScholarExtras
def initialize(tag_name, arguments, tokens)
super
......@@ -23,16 +24,6 @@ module Jekyll
end
def initialize_prefix_defaults()
@prefix_defaults = Hash[{
:article => "J",
:inproceedings => "C",
:incollection=> "BC",
:techreport => "TR",
:book => "B"
}]
end
def set_type_counts(tc)
@type_counts = tc
end
......@@ -45,19 +36,6 @@ module Jekyll
return idx_html + ref
end
def render_ref_img(item)
css_points = Hash[{
:article => "csl-point-journal-icon",
:inproceedings => "csl-point-conference-icon",
:incollection=> "csl-point-bookchapter-icon",
:techreport => "csl-point-techreport-icon",
:book => "csl-point-book-icon"
}]
s = css_points[item.type]
return s
end
def render_header(y)
ys = content_tag "h2 class=\"csl-year-header\"", y
ys = content_tag "div class=\"csl-year-icon\"", ys
......@@ -106,12 +84,17 @@ module Jekyll
reference.insert(reference.rindex('</div>'), ts.to_s)
end
end
# Check if there are ACM PDF links
# Really awkward way of insertion
reference.insert(reference.rindex('</div>'),render_acmpdf_link(entry))
# Render links if repository specified
if repository?
if repository? and not entry.field?(:acmpdflink)
if not repository_link_for(entry).nil?
puts "link is not null"
puts repository_link_for(entry)
reference << "<a class=\"pure-button\" href=\"" + repository_link_for(entry) + "\">PDF</a>"
reference << "<a class=\"pure-button-green\" href=\"" + repository_link_for(entry) + "\">PDF</a>"
end
end
......
......@@ -3,6 +3,7 @@ module Jekyll
class BibliographyTagYear < Liquid::Tag
include Scholar::Utilities
include ScholarExtras
def initialize(tag_name, arguments, tokens)
super
......@@ -40,28 +41,6 @@ module Jekyll
}]
end
def initialize_prefix_defaults()
@prefix_defaults = Hash[{
:article => "J",
:inproceedings => "C",
:incollection=> "BC",
:techreport => "TR",
:book => "B"
}]
end
def render_ref_img(item)
css_points = Hash[{
:article => "csl-point-journal-icon",
:inproceedings => "csl-point-conference-icon",
:incollection=> "csl-point-bookchapter-icon",
:techreport => "csl-point-techreport-icon",
:book => "csl-point-book-icon"
}]
s = css_points[item.type]
return s
end
def get_entries_by_type(year, type)
b = bibliography.query('@*') { |item|
......@@ -75,13 +54,6 @@ module Jekyll
# content_tag "h2", y
end
def render_index(item, ref)
si = '[' + @prefix_defaults[item.type].to_s + @type_counts[item.type].to_s + ']'
@type_counts[item.type] = @type_counts[item.type].to_i - 1
idx_html = content_tag "div class=\"csl-index\"", si
return idx_html + ref
end
def entries_year(year)
b = bibliography.query('@*') {
......@@ -118,23 +90,29 @@ module Jekyll
if entry.field?(:award)
# TODO: Awkward -- Find position to insert it. Before the last </div>
ts = content_tag "div class=\"csl-award\"", entry.award.to_s
# puts ts
# puts ts.to_s
refPos = reference.rindex('</div>')
if refPos.nil?
# puts "NILL"
else
# puts "INSERT\n"
# puts ts
reference.insert( reference.rindex('</div>'), ts.to_s )
end
end
# Render links if repository specified
if repository?
# There are multiple ways to have PDFs associated.
# Priority is suggested as below.
# 1. ACM links to PDF through authorizer
# 2. Repository links
# 3. Just web links to somewhere else.
#
# Check if there are ACM PDF links
reference.insert(reference.rindex('</div>'),render_acmpdf_link(entry))
# Render links if repository specified but not acmpdflink
if repository? and not entry.field?(:acmpdflink)
if not repository_link_for(entry).nil?
puts "link is not null"
puts repository_link_for(entry)
reference << "<a class=\"pure-button\" href=\"" + repository_link_for(entry) + "\">PDF</a>"
reference << "<a href=\"" + repository_link_for(entry) + "\">PDF</a>"
end
end
# Content tag is dependent on type of article.
......
module Jekyll
module ScholarExtras
def render_index(item, ref)
si = '[' + @prefix_defaults[item.type].to_s + @type_counts[item.type].to_s + ']'
@type_counts[item.type] = @type_counts[item.type].to_i - 1
idx_html = content_tag "div class=\"csl-index\"", si
return idx_html + ref
end
def render_ref_img(item)
css_points = Hash[{
:article => "csl-point-journal-icon",
:inproceedings => "csl-point-conference-icon",
:incollection=> "csl-point-bookchapter-icon",
:techreport => "csl-point-techreport-icon",
:book => "csl-point-book-icon"
}]
s = css_points[item.type]
return s
end
def initialize_prefix_defaults()
@prefix_defaults = Hash[{
:article => "J",
:inproceedings => "C",
:incollection=> "BC",
:techreport => "TR",
:book => "B"
}]
end
def render_acmpdf_link(entry)
pdflink =""
if entry.field?(:acmpdflink)
pdflink = "<div class=\"pure-button csl-pdf\"><a href=\"" + entry.acmpdflink.to_s + "\">PDF</a></div>"
end
return pdflink
end
end
end
module Jekyll
class ScholarExtras
VERSION = '0.1.0'.freeze
VERSION = '0.1.1'.freeze
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment