jekyll-theme-open-course 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c44228f16269009a36ed91cb93d45493edda39485bce1bcb768a07a22945fb2
4
- data.tar.gz: 74ee9d5d5fe34e59b200b6d865c764faa1c55cea6b2f940661ecc8ee7cf566f5
3
+ metadata.gz: 7b09a6cad886465d099731b73e29af902f0090bd7dd2ea5fa205605db2985d79
4
+ data.tar.gz: 78eebd7ecb8fcad3138444969f987b3bff2ceeb402114e502bbc523a4c1f860e
5
5
  SHA512:
6
- metadata.gz: 7aebe324212b4fc8513f218d6298c05a8ea3f0a67f8941a58af242d81aa5169803668f0749d7bd254c6ac18e3828a4e91ccd227f24bbc297c8425046b126c48a
7
- data.tar.gz: 29acc9e346bd4d78206878b98394d63b7474c12c1302f2d38da50559bc1e67d2cf02d5092e808db984df4e88863eda618285c53c8d50ac2aea2638b41463a637
6
+ metadata.gz: b70ff525e5feffc9c4717a1756af5ab92a21fdb095a8f425ecb18e822391a2e8a0345a84d9917c578f8fe249ea99c00516434542f467a43be458e3d970ba98ea
7
+ data.tar.gz: '0795071f2df2501ed8799f2420ca96223aaaa8319ce7c97f86369cd6977a437fe8536d9b97bc12721317636fcdd9a1a01ca7e821d52f97217fa3a52a8d82ed92'
@@ -4,13 +4,21 @@ layout: default
4
4
  {% assign util = site.data.utility %}
5
5
  {% assign projects = site.projects %}
6
6
 
7
+ {% assign week_count = site.data.calendar | size %}
8
+ {% assign final_week = week_count | minus: 1 %}
9
+
10
+ {% assign today = "today" | date: "%s" %}
11
+ {% assign last_expiry = site.data.calendar[final_week].expires | date: "%s" %}
12
+
7
13
  {% assign current = true %}
14
+ {% if today > last_expiry %}
15
+ {% assign current = false %}
16
+ {% endif %}
8
17
 
9
18
  {% for entry in site.data.calendar %}
10
19
  {% assign week_int = forloop.index | times: 1 %}
11
20
  {% capture week_num %}{% if week_int < 10 %}0{% endif %}{{ week_int }}{% endcapture %}
12
21
  {% assign week = site.weeks[forloop.index0] %}
13
- {% assign today = "today" | date: "%s" %}
14
22
  {% assign expiry = entry.expires | date: "%s" %}
15
23
 
16
24
  <!-- past dates? -->
@@ -66,7 +74,12 @@ layout: default
66
74
  <aside class="assigned">
67
75
  <header>
68
76
  <h3>Assigned Work</h3>
69
- <small>Due {{ entry.expires | date: "%A, %B %-e" }}</small>
77
+ {% if entry.due_date %}
78
+ {% assign due_date = entry.due_date %}
79
+ {% else %}
80
+ {% assign due_date = entry.expires %}
81
+ {% endif %}
82
+ <small>Due {{ due_date | date: "%A, %B %-e" }}</small>
70
83
  </header>
71
84
  {% if week.readings %}
72
85
  <section class="readings">
@@ -25,73 +25,111 @@ if ('serviceWorker' in navigator) {
25
25
  }
26
26
  }
27
27
 
28
- function themeSwitcher() {
29
- // Exit fast if no CSS properties support
30
- if (!('supports' in CSS && CSS.supports("(--foo: bar)"))) {
31
- return;
32
- }
33
-
34
- var header = document.querySelector('#header h1');
35
- var toggle = document.createElement('a');
36
- var html = document.querySelector('html');
37
- // Icons from https://remixicon.com/
38
- var icons = {
39
- light: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>',
40
- dark: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z"/></svg>'
41
- }
28
+ // Load up the theme switcher if @supports & custom properties available
29
+ if ('supports' in CSS && CSS.supports("(--foo: bar)")) {
42
30
 
43
- var dark_mode = false;
44
- var modes = ['light','dark'];
31
+ function ThemeSwitch() {
32
+ var html = document.querySelector('html');
33
+ var icons = {
34
+ light: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>',
35
+ dark: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z"/></svg>',
36
+ system: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm0-2V4a8 8 0 1 0 0 16z"/></svg>'
37
+ // system: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 1l9.5 5.5v11L12 23l-9.5-5.5v-11L12 1zm0 2.311L4.5 7.653v8.694l7.5 4.342 7.5-4.342V7.653L12 3.311zM12 16a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm0-2a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></svg>'
38
+ }
39
+ var mode = 'system';
40
+ var modes = ['dark','light'];
41
+ var button = document.createElement('a');
45
42
 
46
- if ('matchMedia' in window) {
47
- dark_mode = window.matchMedia('(prefers-color-scheme: dark)').matches;
48
- if (dark_mode) {
49
- modes.reverse(); // ['dark','light']
43
+ var cleanupOldPreferences = function() {
44
+ // Clean up earlier `modes` item
45
+ if (storageAvailable('localStorage')) {
46
+ localStorage.removeItem('modes');
47
+ }
50
48
  }
51
- }
52
49
 
53
- if (storageAvailable('localStorage')) {
54
- if (!localStorage.getItem('modes')) {
55
- localStorage.setItem('modes',modes.join(','));
56
- } else {
57
- modes = localStorage.getItem('modes').split(',');
50
+ var loadPreference = function() {
51
+ // read from local storage
52
+ if (storageAvailable('localStorage')) {
53
+ if (localStorage.getItem('mode')) {
54
+ mode = localStorage.getItem('mode');
55
+ } else {
56
+ mode = 'system';
57
+ }
58
+ }
58
59
  }
59
- }
60
60
 
61
- html.classList.add(modes[0]);
61
+ var setModeOrder = function() {
62
+ // reverse the modes if dark mode is preferred,
63
+ // or if dark is set in preferences
64
+ if ('matchMedia' in window) {
65
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches && (mode !== 'light')) {
66
+ modes.reverse(); // ['light','dark']
67
+ }
68
+ }
69
+ // system gets tacked onto the end as the last option, always
70
+ modes.push('system');
71
+ }
62
72
 
63
- toggle.id = 'theme-toggle';
64
- toggle.href = '#null';
65
- toggle.title = 'Switch to ' + modes[1] + ' theme';
66
- toggle.innerHTML = icons[modes[1]];
67
- header.appendChild(toggle);
73
+ var storePreference = function() {
74
+ // store current mode (default or selected) in local storage
75
+ if (storageAvailable('localStorage')) {
76
+ localStorage.setItem('mode', mode);
77
+ }
78
+ }
68
79
 
69
- toggle.addEventListener('click', function(e) {
70
- e.preventDefault();
71
- html.classList.replace(modes[0],modes[1]);
72
- modes.reverse();
73
- if (storageAvailable('localStorage')) {
74
- localStorage.setItem('modes',modes.join(','));
80
+ var setHTMLClass = function() {
81
+ html.classList.replace(mode,modes[0]);
75
82
  }
76
- toggle.title = 'Switch to ' + modes[1] + ' theme';
77
- toggle.innerHTML = icons[modes[1]];
78
- });
79
83
 
80
- function storageAvailable(type) {
81
- try {
82
- var storage = window[type];
83
- var x = '__storage_test__';
84
- storage.setItem(x, x);
85
- storage.removeItem(x);
86
- return true;
84
+ var cycleModes = function() {
85
+ mode = modes.shift(); // grab the current mode from the front of the array...
86
+ modes.push(mode); // ...and push it to the end of the array
87
87
  }
88
- catch(e) {
89
- return false;
88
+
89
+ this.switcherButton = function() {
90
+ button.id = 'theme-button';
91
+ button.href = '#null';
92
+ button.title = 'Switch to ' + modes[0] + ' theme';
93
+ button.innerHTML = icons[modes[0]];
94
+ button.addEventListener('click', function(e) {
95
+ e.preventDefault();
96
+ // fix the class list on <html>
97
+ setHTMLClass();
98
+ cycleModes();
99
+ storePreference();
100
+ button.title = 'Switch to ' + modes[0] + ' theme';
101
+ button.innerHTML = icons[modes[0]];
102
+ });
103
+ return button;
90
104
  }
105
+
106
+ // Do things on construction
107
+ cleanupOldPreferences();
108
+ loadPreference();
109
+ setModeOrder();
110
+ html.classList.add(mode);
91
111
  }
112
+
113
+ var ts = new ThemeSwitch();
114
+ var ts_li = document.createElement('li');
115
+ ts_li.id = 'nav-thm';
116
+ ts_li.appendChild(ts.switcherButton());
117
+ document.querySelector('#quick-nav .nav').appendChild(ts_li);
92
118
  }
93
119
 
94
- themeSwitcher();
120
+
121
+ function storageAvailable(type) {
122
+ try {
123
+ var storage = window[type];
124
+ var x = '__storage_test__';
125
+ storage.setItem(x, x);
126
+ storage.removeItem(x);
127
+ return true;
128
+ }
129
+ catch(e) {
130
+ return false;
131
+ }
132
+ }
95
133
 
96
134
  // Move the nav to the header when there is room
97
135
  // Responsive detection
@@ -107,34 +145,47 @@ function responsiveFeature(feature) {
107
145
  }
108
146
 
109
147
  function ToggledNav() {
110
- this.nav = document.querySelector('#full-nav .nav');
111
- this.quick_nav = document.querySelector('#quick-nav .nav');
112
- this.full_nav = document.querySelector('#full-nav');
113
- this.nav_nav;
114
- this.nav_items = [];
148
+ var nav = document.querySelector('#full-nav .nav');
149
+ var quick_nav = document.querySelector('#quick-nav .nav');
150
+ var full_nav = document.querySelector('#full-nav');
151
+ var thm_btn = document.querySelector('#theme-button')
152
+ var nav_thm;
153
+ var nav_nav;
154
+ var nav_items = [];
115
155
  this.toggle = function() {
116
156
  if (responsiveFeature('navbar') && !html.classList.contains('navbar')) {
117
- while (this.nav.firstChild) {
118
- if (this.nav.firstChild.tagName) {
119
- this.nav_items.push(this.nav.removeChild(this.nav.firstChild));
157
+ if (thm_btn) {
158
+ nav_thm = quick_nav.removeChild(document.getElementById('nav-thm'));
159
+ }
160
+ while (nav.firstChild) {
161
+ if (nav.firstChild.tagName) {
162
+ nav_items.push(nav.removeChild(nav.firstChild));
120
163
  } else {
121
- this.nav.removeChild(this.nav.firstChild); // remove text nodes
164
+ nav.removeChild(nav.firstChild); // remove text nodes
122
165
  }
123
166
  }
124
- for (var i = 0; i < this.nav_items.length; i++) {
125
- this.quick_nav.appendChild(this.nav_items[i]);
167
+ for (var i = 0; i < nav_items.length; i++) {
168
+ quick_nav.appendChild(nav_items[i]);
126
169
  }
127
- this.nav_nav = this.quick_nav.removeChild(document.getElementById('nav-nav'));
170
+ if (thm_btn) {
171
+ quick_nav.appendChild(nav_thm);
172
+ }
173
+ nav_nav = quick_nav.removeChild(document.getElementById('nav-nav'));
128
174
  html.classList.add('navbar');
129
- this.full_nav.classList.add('hidden');
175
+ full_nav.classList.add('hidden');
130
176
  }
131
177
  if (!responsiveFeature('navbar') && html.classList.contains('navbar')) {
132
- console.log('nav-nav node name:', this.nav_nav.nodeName);
133
- this.quick_nav.appendChild(this.nav_nav);
134
- for (var i = 0; i < this.nav_items.length; i++) {
135
- this.nav.appendChild(this.nav_items[i]);
178
+ if (thm_btn) {
179
+ nav_thm = quick_nav.removeChild(document.getElementById('nav-thm'));
180
+ }
181
+ quick_nav.appendChild(nav_nav);
182
+ for (var i = 0; i < nav_items.length; i++) {
183
+ nav.appendChild(nav_items[i]);
184
+ }
185
+ if (thm_btn) {
186
+ quick_nav.appendChild(nav_thm);
136
187
  }
137
- this.full_nav.classList.remove('hidden');
188
+ full_nav.classList.remove('hidden');
138
189
  html.classList.remove('navbar');
139
190
  }
140
191
  }
@@ -149,7 +200,7 @@ window.addEventListener('resize', function() {
149
200
 
150
201
 
151
202
  // Capture and replicate the current week at the top of the calendar
152
- if (document.querySelector('#calendar')) {
203
+ if ((document.querySelector('#calendar')) && (document.querySelector('#this-week'))) {
153
204
  var this_week = document.querySelector('#this-week').closest('article'); // grab this week's <article>
154
205
  var current_week = this_week.cloneNode(true); // make a copy of it,
155
206
  this_week.querySelector('#this-week').id = ''; // remove the original #this-week id
@@ -204,6 +255,8 @@ if ('fetch' in window) {
204
255
  data = data[0]; // only need most recent commit
205
256
  // Lowercase commit message's first word to run in `...to XYZ` copy:
206
257
  commit.message = data.commit.message.charAt(0).toLowerCase() + data.commit.message.slice(1);
258
+ // Grab only the first line of a multiline message
259
+ commit.message = commit.message.split("\n\n")[0];
207
260
  commit.url = data.html_url;
208
261
  commit.stamp = data.commit.author.date;
209
262
  commit.date = new Date(commit.stamp);
@@ -3,7 +3,7 @@ module JTOpenCourse
3
3
  require 'erb'
4
4
  require 'date'
5
5
 
6
- VERSION = "1.1.0"
6
+ VERSION = "1.2.1"
7
7
 
8
8
  SPELLED_NUMS = %w(
9
9
  Zero One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-open-course
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Stolley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.0.3
128
+ rubygems_version: 3.1.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: A Jekyll theme for accessible course sites.