Skip to content

Commit c170c91

Browse files
committed
Add Content Field Plugin
1 parent 36c6b99 commit c170c91

17 files changed

Lines changed: 88 additions & 117 deletions

‎Gemfile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
3434
# Performance-booster for watching directories on Windows
3535
gem "wdm", "~> 0.1.0" if Gem.win_platform?
3636

37+
gem "pry"
38+
3739
gem "webrick", "~> 1.7"

‎Gemfile.lock‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ GIT
2626
GEM
2727
remote: https://rubygems.org/
2828
specs:
29-
addressable (2.8.1)
29+
addressable (2.8.4)
3030
public_suffix (>= 2.0.2, < 6.0)
31+
coderay (1.1.3)
3132
colorator (1.1.0)
3233
concurrent-ruby (1.2.2)
3334
em-websocket (0.5.3)
@@ -36,9 +37,9 @@ GEM
3637
eventmachine (1.2.7)
3738
ffi (1.15.5)
3839
forwardable-extended (2.6.0)
39-
google-protobuf (3.22.0)
40+
google-protobuf (3.23.1)
4041
http_parser.rb (0.8.0)
41-
i18n (1.12.0)
42+
i18n (1.13.0)
4243
concurrent-ruby (~> 1.0)
4344
jekyll (4.3.2)
4445
addressable (~> 2.4)
@@ -73,19 +74,23 @@ GEM
7374
rb-fsevent (~> 0.10, >= 0.10.3)
7475
rb-inotify (~> 0.9, >= 0.9.10)
7576
mercenary (0.4.0)
77+
method_source (1.0.0)
7678
pathutil (0.16.2)
7779
forwardable-extended (~> 2.6)
7880
posix-spawn (0.3.15)
7981
priority_queue_cxx (0.3.6)
82+
pry (0.14.2)
83+
coderay (~> 1.1)
84+
method_source (~> 1.0)
8085
public_suffix (5.0.1)
8186
rake (13.0.6)
8287
rb-fsevent (0.11.2)
8388
rb-inotify (0.10.1)
8489
ffi (~> 1.0)
8590
rexml (3.2.5)
86-
rouge (4.1.0)
91+
rouge (4.1.1)
8792
safe_yaml (1.0.5)
88-
sass-embedded (1.58.3)
93+
sass-embedded (1.62.1)
8994
google-protobuf (~> 3.21)
9095
rake (>= 10.0.0)
9196
terminal-table (3.0.2)
@@ -105,6 +110,7 @@ DEPENDENCIES
105110
jekyll-seo-tag!
106111
jekyll-sitemap (~> 1.4.0)
107112
priority_queue_cxx (~> 0.3.4)
113+
pry
108114
tzinfo-data
109115
webrick (~> 1.7)
110116

‎_includes/calculatestars.liquid‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎_includes/content.bibtex‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
{%- assign stars = include.stars -%}
2-
{%- unless stars -%}
3-
{% include calculatestars.liquid content=include.content %}
4-
{%- endunless -%}
51
{%- if include.content.from_book -%}{%- assign book = site.content | where: "slug", include.content.from_book | where: "category", "monographs" | first -%}{%- else -%}{%- assign book = nil -%}{%- endif -%}
62
{%- assign series = site.series | find: "slug", include.content.series -%}
73
{%- assign publisher = include.content.publisher | default: book.publisher | default: series.publisher -%}{%- assign publisher = site.publishers | find: "slug", publisher | default: publisher -%}
@@ -35,6 +31,6 @@
3531
{% endif %}{% if include.content.oclc %} oclc={% raw %}{{% endraw %}{{ include.content.oclc }}},
3632
{% endif %}{% if include.content.olid %} olid={% raw %}{{% endraw %}{{ include.content.olid }}},
3733
{% endif %}{% if include.content.source_url contains "doi.org/" %} doi={% raw %}{{% endraw %}{{ include.content.source_url | split: "doi.org/" | last }}},
38-
{% endif %} ranking={% raw %}{{% endraw %}rank{{ stars }}},
34+
{% endif %} ranking={% raw %}{{% endraw %}rank{{ include.content.stars }}},
3935
url={% raw %}{{% endraw %}{% if include.content.external_url %}{{ include.content.external_url }}{% else %}{{ include.content.url | absolute_url }}{% endif %}}
4036
}

‎_includes/content_filelinks.html‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{% include content_path.liquid content=include.content %}
21
<div class="content_links">{% if page.collection == "content" %}Get it:{% endif %}
32
{% if include.content.external_url %}{% assign linkfmt = "" %}
43
{%- capture linkbody -%}<i class="fa{% if include.content.external_url contains "youtu" %}{% assign linkfmt = "YouTube (link)" %}b fa-youtube"></i> YouTube{% elsif include.content.external_url contains "//www.academia.edu/" %}c-academia"></i>cademia.edu{% assign linkfmt = "Academia.edu" %}{% else %}s fa-{% assign ext = include.content.external_url | slice: -4, 4 %}{% if ext == ".pdf" %}{% assign linkfmt = "pdf" %}file-pdf"></i> pdf{% elsif ext == ".mp3" %}{% assign linkfmt = "mp3" %}file-audio"></i> mp3{% elsif ext == ".zip" %}{% assign linkfmt = "zip" %}file-archive"></i> zip{% else %}{% if ext == ".htm" %}{% assign linkfmt = "html" %}{% elsif ext == "html" %}{% assign linkfmt = "html" %}{% endif %}{% case include.content.category %}{% when "av" %}volume-up{% when "booklets" %}book-open{% when "monographs" %}book-open{% else %}globe{% endcase %}"></i> Online{% endif %}{% endif %}{%- endcapture -%}
@@ -13,7 +12,7 @@
1312
{%- if include.content.drive_links.size > 0 -%}
1413
{%- for link in include.content.drive_links -%}
1514
{% assign linkfmt = include.content.formats[forloop.index0] %}
16-
<a class="btn" {% if include.newtab %}target="_blank" {% endif %}{% include content_link_data_attributes.html content=include.content linktype="Google Drive" linkfmt=linkfmt %} ga-event-label="drive.google.com/{{ content_path }}.{{ linkfmt }}" href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i> {{ linkfmt }}</a>
15+
<a class="btn" {% if include.newtab %}target="_blank" {% endif %}{% include content_link_data_attributes.html content=include.content linktype="Google Drive" linkfmt=linkfmt %} ga-event-label="drive.google.com/{{ include.content.content_path }}.{{ linkfmt }}" href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i> {{ linkfmt }}</a>
1716
{%- endfor -%}
1817
{%- endif -%}
1918
{% if page.source_url %}
@@ -31,7 +30,7 @@
3130
{%- unless include.content.excerpt_url -%}<details class="copyright details-reset"><summary>{%- endunless -%}
3231
{%- capture authors -%}{% include content_authors_string.html content=include.content %}{%- endcapture -%}
3332
{% assign authors = authors | strip_html | strip | cgi_escape %}
34-
<a class="btn" {% include content_link_data_attributes.html content=include.content linktype="WorldCat" linkfmt="WorldCat" %} ga-event-label="worldcat.org/{{ content_path }}" href="https://www.worldcat.org/{% if include.content.oclc %}oclc/{{ include.content.oclc }}{% else %}search?q=ti%3A{{ include.content.title | markdownify | strip_html | strip | cgi_escape }}{% if authors %}+au%3A{{ authors }}{% endif %}{% if include.content.category == 'monographs' %}&fq=x0%3Abook+%3E+ln%3Aeng{% endif %}&qt=advanced{% endif %}"><i class="fas fa-binoculars"></i> WorldCat&trade;</a>
33+
<a class="btn" {% include content_link_data_attributes.html content=include.content linktype="WorldCat" linkfmt="WorldCat" %} ga-event-label="worldcat.org/{{ include.content.content_path }}" href="https://www.worldcat.org/{% if include.content.oclc %}oclc/{{ include.content.oclc }}{% else %}search?q=ti%3A{{ include.content.title | markdownify | strip_html | strip | cgi_escape }}{% if authors %}+au%3A{{ authors }}{% endif %}{% if include.content.category == 'monographs' %}&fq=x0%3Abook+%3E+ln%3Aeng{% endif %}&qt=advanced{% endif %}"><i class="fas fa-binoculars"></i> WorldCat&trade;</a>
3534
<i class="far fa-question-circle"></i>
3635
</summary><div>
3736
<i class="far fa-copyright"></i> This fine, Copyrighted work cannot be shared {% if include.content.excerpt_url %}in its entirety{% else %}directly{% endif %}, however WorldCat&trade; can help you find a copy at a nearby library{% if include.content.category == 'monographs' %} or wherever you get books{% endif %}.

‎_includes/content_link_data_attributes.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{%- assign c = include.content -%}
2-
{%- include content_path.liquid content=c -%}
32
{%- assign value = c.base_value -%}
43
{%- if c.status == "featured" -%}{%- assign value = value | times: site.data.ga.featured_value_multiplier -%}{%- endif -%}
54
{%- if include.linktype == "Preview" -%}{%- assign value = value | times: 0.5 -%}{%- endif -%}
65
{%- if include.linktype == "WorldCat" -%}{%- assign value = 0.15 -%}{%- endif -%}
7-
data-content-title="{{ c.title | smartify | markdownify | strip_html | strip }}" ga-event-value="{{ value }}" data-content-path="{{ content_path }}" data-content-link-ext="{{ include.linkfmt | default: include.linktype }}" data-content-category="{{ c.category }}" data-content-subcat="{{ c.subcat }}" data-content-course="{{ c.course | default: 'archive' }}" data-content-authors="{{ c.authors | join: ", " | default: c.reader | default: c.translator }}"
6+
data-content-title="{{ c.title | smartify | markdownify | strip_html | strip }}" ga-event-value="{{ value }}" data-content-path="{{ c.content_path }}" data-content-link-ext="{{ include.linkfmt | default: include.linktype }}" data-content-category="{{ c.category }}" data-content-subcat="{{ c.subcat }}" data-content-course="{{ c.course | default: 'archive' }}" data-content-authors="{{ c.authors | join: ", " | default: c.reader | default: c.translator }}"
87
{%- comment -%}
98
Only the common, data attributes are added here.
109
The specific HREFs, etc are added in-situ

‎_includes/content_path.liquid‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎_includes/content_size.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{% if include.content.pages or include.content.minutes %}{% unless include.content.pages contains "," %}<span class="content_size">{% if include.content.pages contains "--" %}{% assign ps = include.content.pages | split: "--" %}{{ 1 | plus: ps[1] | minus: ps[0] }} pages{% elsif include.content.minutes %}{% if include.content.minutes < 70 %}{{ include.content.minutes }} min{% else %}{{ include.content.minutes | divided_by: 60 }}h {{ include.content.minutes | modulo: 60 }}m{% endif %}{% else %}{{ include.content.pages }} page{% if include.content.pages != 1 %}s{% endif %}{% endif %}</span>{% endunless %}{% endif %}
1+
{% if include.content.pages_count or include.content.minutes %}{% unless include.content.pages contains "," %}<span class="content_size">{% if include.content.minutes %}{% if include.content.minutes < 70 %}{{ include.content.minutes }} min{% else %}{{ include.content.minutes | divided_by: 60 }}h {{ include.content.minutes | modulo: 60 }}m{% endif %}{% else %}{{ include.content.page_count }} page{% if include.content.page_count != 1 %}s{% endif %}{% endif %}</span>{% endunless %}{% endif %}
22

‎_includes/content_title.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{% assign c = include.content %}{% assign category = c.path | split: '/' %}{% assign category = category[1] %}
22
{% include_cached content_icon.html category=category subcat=c.subcat %}
3-
{% include content_path.liquid content=c %}
43
<span id="{{ c.slug }}">{% if c.external_url %}<a target="_blank" {% include content_link_data_attributes.html content=c linktype="Main External URL" linkfmt="" %} href="{{ c.external_url }}"{% for nrh in site.data.content.noreferrerhosts %}{% if c.external_url contains nrh %} rel="noreferrer"{% break %}{% endif %}{% endfor %}>{% endif %}{{ c.title | markdownify | remove: '<p>' | remove: '</p>' }}{% if c.authors.size > 0 or c.reader %} – {% include content_authors_string.html content=c %}{% endif %}{% if c.external_url %}</a>{% endif %}</span>
54
{% if c.drive_links %}<span>
65
{%- for link in c.file_links -%}
@@ -9,5 +8,5 @@
98
{%- endfor -%}
109
{%- for link in c.drive_links -%}
1110
{%- assign linkfmt = c.formats[forloop.index0] -%}
12-
<span class="inline_drive_link"> (<a target="_blank" ga-event-label="drive.google.com/{{ content_path }}.{{ linkfmt }}" {% include content_link_data_attributes.html content=c linktype="Google Drive" linkfmt=linkfmt %} href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i>.{{ linkfmt }}</a>)</span>
11+
<span class="inline_drive_link"> (<a target="_blank" ga-event-label="drive.google.com/{{ c.content_path }}.{{ linkfmt }}" {% include content_link_data_attributes.html content=c linktype="Google Drive" linkfmt=linkfmt %} href="{{ link }}"><i class="fa{% if link contains "drive.google.com" %}b fa-google-drive{% elsif link contains "play.google.com" %}b fa-google-play{% else %}s fa-globe{% endif %}"></i>.{{ linkfmt }}</a>)</span>
1312
{%- endfor -%}</span>{%- endif -%}

‎_includes/featured_content_list.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
{% unless include.keep_rejects %}
33
{% assign sorted = sorted | where_exp: "c", "c.status != 'rejected'" %}
44
{% endunless %}
5-
{% assign sorted = sorted | sort: "slug" | reverse | sort: "minutes", "first" | reverse %}
5+
{% assign sorted = sorted | sort: "slug" | reverse | sort: "minutes", "first" | sort: "page_count", "first" | reverse %}
66
<div class="featured_content_list"><ul>
77
{% for c in sorted %}
88
<li>
99
{% if c.olid %}<div class="ol-cover"><a href="{{ c.url }}">{{ c.title | markdownify | strip_html }}<img src="https://covers.openlibrary.org/b/olid/{{ c.olid }}-L.jpg" alt="{{ c.title }}"></a></div>{% else %}
1010
<div class="content_title">{% capture foo %}{% include simple_content_title.html content=c %}{% endcapture %}{{ foo | strip_newlines }}</div>{% endif %}
11-
<div class="star_label">{% include calculatestars.liquid content=c %}{% unless stars == 3 %}<span class="RatingLabel-{{ stars }}">{% include starlabel.html stars=stars %}</span>{% endunless %}</div>
11+
<div class="star_label">{% unless c.stars == 3 %}<span class="RatingLabel-{{ c.stars }}">{% include starlabel.html stars=c.stars %}</span>{% endunless %}</div>
1212
{% unless c.olid %}{% assign supex = false %}{% if c.external_url contains 'youtu' %}{% unless c.external_url contains "list" %}
1313
<a href="{{ c.url }}"><img src="https://img.youtube.com/vi/{{ c.external_url | ytid }}/0.jpg" alt="{{ c.title }} Video Thumbnail"></a>{% assign supex = true %}{% endunless %}{% endif %}
1414
{% unless supex %}<div class="content_desc">{{ c.excerpt }}</div>{% endunless %}

0 commit comments

Comments
 (0)