newport 1.0.6 → 1.0.7

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: e111cd4c09644217b541f2a4a54ff5be9b20f2fad5ce8819a821a0cb77f2a657
4
- data.tar.gz: '0862e9f1354dc4ac499c2a00f548fbe60f507a4cf25f5fd265e05f333fac8a52'
3
+ metadata.gz: ff47fb76e4cf88c9843d48f1b435d2fd0ce938bef6ce7f74db9ffa26ca05173a
4
+ data.tar.gz: a8e78af5182b81b2cd27d8b39bca804940a873f1084c68ec47a88e12a3c6c4c2
5
5
  SHA512:
6
- metadata.gz: f6f8f1d31101f91d3bc1c25f7b82d243fabe4b2ff761df354333d283db88f7c439e1f9b8ec1c16e30385c80b6c1c92fa779a13703934e69b096b51b8f0626a34
7
- data.tar.gz: 531cee4fbafa6b18c405d520fc658b4530e5024473545725250226de4f8be966180e971aeb32a6788b59a8f5548c8f85cb9daa645b4c14ba79c30db414b4502b
6
+ metadata.gz: fd4c6743ef16d99548496ef16e7acefe08a97bc2566ed6e0cde29b0e64e5a789a290acf6b87601e0470ab6851c889430735694da937310a42cdcca0174356a1f
7
+ data.tar.gz: 637c43e5b8cbff4ddca8001d37b634f1b5577f1dbed2cf25cdae70af0b61fd304779efa8df06bdede63563de93b9547fa204397323b2c599245f0345e7e0a40b
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Newport
4
- VERSION = '1.0.6'
4
+ VERSION = '1.0.7'
5
5
  end
@@ -5,3 +5,4 @@ plugins:
5
5
  - darkmode
6
6
  - permalink
7
7
  - pagination
8
+ - changefont
@@ -1,5 +1,4 @@
1
1
  <nav>
2
- <!-- <a href="/">home</a> &middot;
3
- <a href="/feed.xml">feed</a> &middot; -->
4
2
  <div id="darkmode"></div>
3
+ <div id="changefont"></div>
5
4
  </nav>
@@ -14,7 +14,7 @@ img{max-width: 100%;}
14
14
  h1 a,h1 a:active,h1 a:visited{color:var(--h1-color)}
15
15
  .title{float:left;padding-top:0.5rem}
16
16
  section{margin-top:2rem}
17
- #darkmode{display:inline}
17
+ #darkmode,#changefont{display:inline}
18
18
  .expander-arrow, .more-arrow, .more-arrow:active, .more-arrow:visited { color: var(--text-color); fill: var(--text-color) }
19
19
  footer {border-top: 1px var(--footer-border-color) solid;min-height: 80px;padding-top: 10px;padding-bottom:15px}
20
20
  .main {min-height: calc(100% - 40px)}
@@ -35,67 +35,3 @@ code{background:var(--code-background-color);padding-left:2px;padding-right:2px}
35
35
  --footer-border-color: #555;
36
36
  --h1-color: #ddd;
37
37
  }
38
-
39
- /* The switch - the box around the slider */
40
- .switch {
41
- position: relative;
42
- display: inline-block;
43
- width: 30px;
44
- height: 17px;
45
- }
46
-
47
- /* Hide default HTML checkbox */
48
- .switch input {
49
- opacity: 0;
50
- width: 0;
51
- height: 0;
52
- }
53
-
54
- /* The slider */
55
- .slider {
56
- position: absolute;
57
- cursor: pointer;
58
- top: 0;
59
- left: 0;
60
- right: 0;
61
- bottom: 0;
62
- background-color: #ccc;
63
- -webkit-transition: .4s;
64
- transition: .4s;
65
- }
66
-
67
- .slider:before {
68
- position: absolute;
69
- content: "";
70
- height: 13px;
71
- width: 13px;
72
- left: 2px;
73
- bottom: 2px;
74
- background-color: white;
75
- -webkit-transition: .4s;
76
- transition: .4s;
77
- color: #000;
78
- }
79
-
80
- input:checked + .slider {
81
- background-color: #333;
82
- }
83
-
84
- input:focus + .slider {
85
- box-shadow: 0 0 1px #333;
86
- }
87
-
88
- input:checked + .slider:before {
89
- -webkit-transform: translateX(13px);
90
- -ms-transform: translateX(13px);
91
- transform: translateX(13px);
92
- }
93
-
94
- /* Rounded sliders */
95
- .slider.round {
96
- border-radius: 17px;
97
- }
98
-
99
- .slider.round:before {
100
- border-radius: 50%;
101
- }
@@ -0,0 +1,83 @@
1
+ function setFontFromCookies() {
2
+ var fontSize = Cookies.get('font-size');
3
+ if (fontSize == undefined) {
4
+ var fontSize = 0.9;
5
+ }
6
+
7
+ var fontFamily = Cookies.get('font-family');
8
+ if (fontFamily == undefined) {
9
+ var fontFamily = 'monospace';
10
+ }
11
+
12
+ if (fontFamily == 'monospace') {
13
+ var lineHeight = Number(fontSize) + 0.4;
14
+ } else {
15
+ var lineHeight = Number(fontSize) + 1;
16
+ }
17
+
18
+ console.log(fontFamily);
19
+ console.log(fontSize + 'rem');
20
+ console.log(lineHeight + 'rem');
21
+
22
+ let body = document.getElementsByClassName("posts")[0];
23
+ body.style.fontSize = fontSize + 'rem';
24
+ body.style.fontFamily = fontFamily;
25
+ body.style.lineHeight = lineHeight + 'rem';
26
+ }
27
+
28
+ function showDropDown() {
29
+ document.getElementById("dropdown").classList.toggle("show");
30
+ }
31
+
32
+ function setFontSize(size) {
33
+ switch (size) {
34
+ case 'small':
35
+ Cookies.set('font-size', 0.8);
36
+ setFontFromCookies();
37
+ break;
38
+ case 'medium':
39
+ Cookies.set('font-size', 0.9);
40
+ setFontFromCookies();
41
+ break;
42
+ case 'large':
43
+ Cookies.set('font-size', 1.0);
44
+ setFontFromCookies();
45
+ break;
46
+ }
47
+ }
48
+
49
+ function setFont(font) {
50
+ switch (font) {
51
+ case 'mono':
52
+ Cookies.set('font-family', 'monospace');
53
+ setFontFromCookies();
54
+ break;
55
+ case 'sans':
56
+ Cookies.set('font-family', 'sans-serif');
57
+ setFontFromCookies();
58
+ break;
59
+ }
60
+ }
61
+
62
+ // Close the dropdown menu if the user clicks outside of it
63
+ window.onclick = function (event) {
64
+ if (!event.target.matches('.dropbtn')) {
65
+ var dropdowns = document.getElementsByClassName("dropdown-content");
66
+ var i;
67
+ for (i = 0; i < dropdowns.length; i++) {
68
+ var openDropdown = dropdowns[i];
69
+ if (openDropdown.classList.contains('show')) {
70
+ openDropdown.classList.remove('show');
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ setFontFromCookies();
77
+ document.getElementById("changefont").innerHTML = '<div class="dropdown"><button onclick="showDropDown()" class="dropbtn">&#9776;</button><div id="dropdown" class="dropdown-content"><span>Font Size<br /><button onclick="setFontSize(\x27small\x27)" class="font-size-small">A</button><button onclick="setFontSize(\x27medium\x27)" class="font-size-medium">A</button><button onclick="setFontSize(\x27large\x27)" class="font-size-large">A</button></span><span>Font<br /><button onclick="setFont(\x27mono\x27)" class="font-mono">mono</button><button onclick="setFont(\x27sans\x27)" class="font-sans">sans-serif</button></span></div></div>';
78
+ var css = '.font-size-small{font-size:.9rem;border:none;background:#ddd;cursor:pointer}.font-size-medium{font-size:1rem;border:none;background:#ddd;cursor:pointer}.font-size-large{font-size:1.1rem;border:none;background:#ddd;cursor:pointer}.font-mono{font-family:monospace;border:none;cursor:pointer}.font-sans{font-family:sans-serif;border:none;cursor:pointer}.dropbtn{padding:0;font-size:16px;border:none;cursor:pointer;background:0 0;color:var(--text-color)}.dropdown{position:relative;display:inline-block}.dropdown-content{text-align:center;display:none;position:absolute;background-color:#eee;min-width:180px;z-index:1;margin-left:-160px}.dropdown-content span{color:#000;padding:12px 16px;text-decoration:none;display:block}.show{display:block}';
79
+ var head = document.getElementsByTagName('head')[0];
80
+ var s = document.createElement('style');
81
+ s.setAttribute('type', 'text/css');
82
+ s.appendChild(document.createTextNode(css));
83
+ head.appendChild(s);
@@ -1,13 +1,13 @@
1
1
  // Place an empty div with the id darkmode where you want to toggle to appear in your html
2
2
  // ie. <div id="darkmode"></div>
3
3
 
4
- (function() {
4
+ (function () {
5
5
 
6
6
  function showDark() {
7
7
  document.documentElement.setAttribute("data-theme", "dark");
8
8
  Cookies.set('appearance', 'dark');
9
9
  }
10
-
10
+
11
11
  function showLight() {
12
12
  document.documentElement.setAttribute("data-theme", "light");
13
13
  Cookies.set('appearance', 'light');
@@ -24,7 +24,7 @@
24
24
  showLight();
25
25
  }
26
26
 
27
- document.getElementById("darkmode-checkbox").onchange = function(){
27
+ document.getElementById("darkmode-checkbox").onchange = function () {
28
28
  if (document.getElementById('darkmode-checkbox').checked) {
29
29
  showDark();
30
30
  } else {
@@ -33,3 +33,10 @@
33
33
  };
34
34
 
35
35
  })();
36
+
37
+ var css = ' .switch {position: relative;display: inline-block;width: 30px;height: 17px;}.switch input {opacity: 0;width: 0;height: 0;}.slider {position: absolute;cursor: pointer;top: 0;left: 0;right: 0;bottom: 0;background-color: #ccc;-webkit-transition: .4s;transition: .4s;}.slider:before {position: absolute;content: "";height: 13px;width: 13px;left: 2px;bottom: 2px;background-color: white;-webkit-transition: .4s;transition: .4s;color: #000;}input:checked + .slider {background-color: #333;}input:focus + .slider {box-shadow: 0 0 1px #333;}input:checked + .slider:before {-webkit-transform: translateX(13px);-ms-transform: translateX(13px);transform: translateX(13px);}.slider.round {border-radius: 17px;}.slider.round:before {border-radius: 50%;}';
38
+ var head = document.getElementsByTagName('head')[0];
39
+ var s = document.createElement('style');
40
+ s.setAttribute('type', 'text/css');
41
+ s.appendChild(document.createTextNode(css));
42
+ head.appendChild(s);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Fisher
@@ -90,6 +90,7 @@ files:
90
90
  - lib/site_template/layouts/main.html
91
91
  - lib/site_template/layouts/nav.html
92
92
  - lib/site_template/layouts/style.css
93
+ - lib/site_template/plugins/changefont.js
93
94
  - lib/site_template/plugins/darkmode.js
94
95
  - lib/site_template/plugins/expander.js
95
96
  - lib/site_template/plugins/pagination.js