Skip to content

Commit 925cac0

Browse files
authored
Improve bib layout for thesis (alshedivat#920)
1 parent 34eb856 commit 925cac0

File tree

1 file changed

+95
-92
lines changed

1 file changed

+95
-92
lines changed

_layouts/bib.html

Lines changed: 95 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -24,108 +24,111 @@
2424

2525
<!-- Entry bib key -->
2626
<div id="{{entry.key}}" class="col-sm-8">
27-
{% if entry.type == "thesis" -%}
28-
{{reference}}
29-
{%- else %}
30-
<!-- Title -->
31-
<div class="title">{{entry.title}}</div>
32-
<!-- Author -->
33-
<div class="author">
34-
{% assign author_array_size = entry.author_array | size %}
27+
<!-- Title -->
28+
<div class="title">{{entry.title}}</div>
29+
<!-- Author -->
30+
<div class="author">
31+
{% assign author_array_size = entry.author_array | size %}
3532

36-
{% assign author_array_limit = author_array_size %}
37-
{%- if site.max_author_limit and author_array_size > site.max_author_limit %}
38-
{% assign author_array_limit = site.max_author_limit %}
39-
{% endif %}
33+
{% assign author_array_limit = author_array_size %}
34+
{%- if site.max_author_limit and author_array_size > site.max_author_limit %}
35+
{% assign author_array_limit = site.max_author_limit %}
36+
{% endif %}
4037

41-
{%- for author in entry.author_array limit: author_array_limit -%}
42-
{%- assign author_is_self = false -%}
43-
{%- assign author_last_name = author.last | remove: "¶" | remove: "&" | remove: "*" | remove: "†" | remove: "^" -%}
44-
{%- if site.scholar.last_name contains author_last_name -%}
45-
{%- if site.scholar.first_name contains author.first -%}
46-
{%- assign author_is_self = true -%}
47-
{%- endif -%}
48-
{%- endif -%}
49-
{%- assign coauthor_url = nil -%}
50-
{%- if site.data.coauthors[author_last_name] -%}
51-
{%- for coauthor in site.data.coauthors[author_last_name] -%}
52-
{%- if coauthor.firstname contains author.first -%}
53-
{%- assign coauthor_url = coauthor.url -%}
54-
{%- break -%}
55-
{%- endif -%}
56-
{%- endfor -%}
38+
{%- for author in entry.author_array limit: author_array_limit -%}
39+
{%- assign author_is_self = false -%}
40+
{%- assign author_last_name = author.last | remove: "¶" | remove: "&" | remove: "*" | remove: "†" | remove: "^" -%}
41+
{%- if site.scholar.last_name contains author_last_name -%}
42+
{%- if site.scholar.first_name contains author.first -%}
43+
{%- assign author_is_self = true -%}
5744
{%- endif -%}
58-
59-
{%- if forloop.length > 1 -%}
60-
{%- if forloop.first == false -%},&nbsp;{%- endif -%}
61-
{%- if forloop.last and author_array_limit == author_array_size -%}and&nbsp;{%- endif -%}
62-
{%- endif -%}
63-
{%- if author_is_self -%}
64-
<em>{{author.first}} {{author.last}}</em>
65-
{%- else -%}
66-
{%- if coauthor_url -%}
67-
<a href="{{coauthor_url}}">{{author.first}} {{author.last}}</a>
68-
{%- else -%}
69-
{{author.first}} {{author.last}}
45+
{%- endif -%}
46+
{%- assign coauthor_url = nil -%}
47+
{%- if site.data.coauthors[author_last_name] -%}
48+
{%- for coauthor in site.data.coauthors[author_last_name] -%}
49+
{%- if coauthor.firstname contains author.first -%}
50+
{%- assign coauthor_url = coauthor.url -%}
51+
{%- break -%}
7052
{%- endif -%}
71-
{%- endif -%}
72-
{%- endfor -%}
73-
{%- assign more_authors = author_array_size | minus: author_array_limit -%}
74-
75-
{%- assign more_authors_hide = more_authors | append: " more author" -%}
76-
{%- if more_authors > 0 -%}
77-
{%- if more_authors > 1 -%}
78-
{%- assign more_authors_hide = more_authors_hide | append: "s" -%}
79-
{%- endif -%}
80-
{%- assign more_authors_show = '' -%}
81-
{%- for author in entry.author_array offset: author_array_limit -%}
82-
{%- assign more_authors_show = more_authors_show | append: author.first | append: " " | append: author.last -%}
83-
{%- unless forloop.last -%}
84-
{%- assign more_authors_show = more_authors_show | append: ", " -%}
85-
{%- endunless -%}
8653
{%- endfor -%}
87-
, and
88-
<span
89-
class="more-authors"
90-
title="click to view {{more_authors_hide}}"
91-
onclick="
92-
var element = $(this);
93-
element.attr('title', '');
94-
var more_authors_text = element.text() == '{{more_authors_hide}}' ? '{{more_authors_show}}' : '{{more_authors_hide}}';
95-
var cursorPosition = 0;
96-
var textAdder = setInterval(function(){
97-
element.text(more_authors_text.substring(0, cursorPosition + 1));
98-
if (++cursorPosition == more_authors_text.length){
99-
clearInterval(textAdder);
100-
}
101-
}, '{{site.more_authors_animation_delay}}');
102-
"
103-
>{{more_authors_hide}}</span>
10454
{%- endif -%}
10555

106-
</div>
107-
108-
<!-- Journal/Book title and date -->
109-
{% assign proceedings = "inproceedings, incollection" | split: ','%}
110-
{% if entry.type == "article" -%}
111-
{%- capture entrytype -%}<em>{{entry.journal}}</em>{%- endcapture -%}
112-
{%- elsif proceedings contains entry.type -%}
113-
{%- capture entrytype -%}<em>In {{entry.booktitle}}</em> {%- endcapture -%}
114-
{%- else -%}
115-
{%- capture entrytype -%}{%- endcapture -%}
56+
{%- if forloop.length > 1 -%}
57+
{%- if forloop.first == false -%},&nbsp;{%- endif -%}
58+
{%- if forloop.last and author_array_limit == author_array_size -%}and&nbsp;{%- endif -%}
11659
{%- endif -%}
117-
{%- if entry.month -%}
118-
{%- capture entrymonth -%}{{ " " }}{{ entry.month | capitalize }}{%- endcapture -%}
60+
{%- if author_is_self -%}
61+
<em>{{author.first}} {{author.last}}</em>
62+
{%- else -%}
63+
{%- if coauthor_url -%}
64+
<a href="{{coauthor_url}}">{{author.first}} {{author.last}}</a>
65+
{%- else -%}
66+
{{author.first}} {{author.last}}
67+
{%- endif -%}
11968
{%- endif -%}
120-
{%- if entry.year -%}
121-
{%- capture entryyear -%}{{ " " }}{{entry.year}}{%- endcapture -%}
69+
{%- endfor -%}
70+
{%- assign more_authors = author_array_size | minus: author_array_limit -%}
71+
72+
{%- assign more_authors_hide = more_authors | append: " more author" -%}
73+
{%- if more_authors > 0 -%}
74+
{%- if more_authors > 1 -%}
75+
{%- assign more_authors_hide = more_authors_hide | append: "s" -%}
12276
{%- endif -%}
123-
{%- capture periodical -%}{{ entrytype }}{{ entrymonth }}{{ entryyear }}{%- endcapture -%}
124-
<div class="periodical">
125-
{{ periodical | strip }}
126-
</div>
127-
{%- endif %}
128-
77+
{%- assign more_authors_show = '' -%}
78+
{%- for author in entry.author_array offset: author_array_limit -%}
79+
{%- assign more_authors_show = more_authors_show | append: author.first | append: " " | append: author.last -%}
80+
{%- unless forloop.last -%}
81+
{%- assign more_authors_show = more_authors_show | append: ", " -%}
82+
{%- endunless -%}
83+
{%- endfor -%}
84+
, and
85+
<span
86+
class="more-authors"
87+
title="click to view {{more_authors_hide}}"
88+
onclick="
89+
var element = $(this);
90+
element.attr('title', '');
91+
var more_authors_text = element.text() == '{{more_authors_hide}}' ? '{{more_authors_show}}' : '{{more_authors_hide}}';
92+
var cursorPosition = 0;
93+
var textAdder = setInterval(function(){
94+
element.text(more_authors_text.substring(0, cursorPosition + 1));
95+
if (++cursorPosition == more_authors_text.length){
96+
clearInterval(textAdder);
97+
}
98+
}, '{{site.more_authors_animation_delay}}');
99+
"
100+
>{{more_authors_hide}}</span>
101+
{%- endif -%}
102+
103+
</div>
104+
105+
<!-- Journal/Book title and date -->
106+
{% assign proceedings = "inproceedings,incollection" | split: ','%}
107+
{% assign thesis = "thesis,mastersthesis,phdthesis" | split: ','%}
108+
{% if entry.type == "article" -%}
109+
{%- capture entrytype -%}<em>{{entry.journal}}</em>{%- endcapture -%}
110+
{%- elsif proceedings contains entry.type -%}
111+
{%- capture entrytype -%}<em>In {{entry.booktitle}}</em> {%- endcapture -%}
112+
{%- elsif thesis contains entry.type -%}
113+
{%- capture entrytype -%}<em>{{entry.school}}</em> {%- endcapture -%}
114+
{%- else -%}
115+
{%- capture entrytype -%}{%- endcapture -%}
116+
{%- endif -%}
117+
{%- if entry.month -%}
118+
{%- capture entrymonth -%}{{ " " }}{{ entry.month | capitalize }}{%- endcapture -%}
119+
{%- endif -%}
120+
{%- if entry.year -%}
121+
{%- capture entryyear -%}{{ " " }}{{entry.year}}{%- endcapture -%}
122+
{%- endif -%}
123+
{% assign entrytype_text = entrytype | strip_html | strip %}
124+
{%- capture periodical -%}{{ entrytype }}{%- if entrytype_text != "" and entryyear != "" -%}, {%- endif -%}{{ entrymonth }}{{ entryyear }}{%- endcapture -%}
125+
<div class="periodical">
126+
{{ periodical | strip }}
127+
</div>
128+
<div class="periodical">
129+
{{ entry.note | strip }}
130+
</div>
131+
129132
<!-- Links/Buttons -->
130133
<div class="links">
131134
{%- if entry.abstract %}

0 commit comments

Comments
 (0)