Skip to content

Commit 5c9f216

Browse files
committed
add comment mode, nice feature, thx for tabokie ;)
Signed-off-by: husharp <ihusharp@gmail.com>
1 parent 95d25fe commit 5c9f216

30 files changed

+676
-2349
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ gem 'jekyll-sitemap'
1010
gem 'jekyll-feed'
1111
gem 'jekyll'
1212
gem 'webrick'
13+
gem 'nokogiri'

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ GEM
5757
rb-fsevent (~> 0.10, >= 0.10.3)
5858
rb-inotify (~> 0.9, >= 0.9.10)
5959
mercenary (0.4.0)
60+
nokogiri (1.16.8-arm64-darwin)
61+
racc (~> 1.4)
6062
pathutil (0.16.2)
6163
forwardable-extended (~> 2.6)
6264
public_suffix (5.0.1)
65+
racc (1.8.1)
6366
rb-fsevent (0.11.2)
6467
rb-inotify (0.10.1)
6568
ffi (~> 1.0)
@@ -82,6 +85,7 @@ DEPENDENCIES
8285
jekyll-feed
8386
jekyll-seo-tag
8487
jekyll-sitemap
88+
nokogiri
8589
webrick
8690

8791
BUNDLED WITH

_includes/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<footer>
22
<span class="hidden-text">
3-
<blockquote>Copyright 2023 HuSharp. Any and all opinions listed here are my own and not representative of my employers; future, past and present.</blockquote>
3+
<blockquote>Copyright 2024 HuSharp. Any and all opinions listed here are my own and not representative of my employers; future, past and present.</blockquote>
44
</span>
55
<br />
66
</footer>

_layouts/blog.html

Lines changed: 115 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,113 @@
1010
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png">
1111
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png">
1212
<link rel="manifest" href="/assets/favicon/site.webmanifest">
13+
<link rel="alternate" type="application/rss+xml" title="HuSharp's Site" href="/feed.xml" />
1314

1415
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1516
<meta name="theme-color" content="#ffffff">
1617

1718
<title>{{page.title}}</title>
18-
<style>
19-
.main {
20-
padding: 20px 10px;
21-
}
22-
23-
.hack h1 {
24-
padding-top: 0;
25-
}
2619

27-
footer.footer {
28-
border-top: 1px solid #ccc;
29-
margin-top: 80px;
30-
margin-top: 5rem;
31-
padding: 48px 0;
32-
padding: 3rem 0;
33-
}
34-
35-
img {
36-
max-width: 100%;
37-
padding: 1em;
38-
}
20+
<style>
21+
.main {
22+
padding: 20px 10px;
23+
}
24+
.hack h1 {
25+
padding-top: 0;
26+
}
27+
img {
28+
max-width: 100%;
29+
padding: 1em;
30+
}
31+
.side-content {
32+
top: 0;
33+
}
3934
</style>
35+
{% if page.side_by_side == "translation" %}
36+
<style>
37+
header {
38+
max-width: 100vw;
39+
}
40+
/*Match content-width=60rem*/
41+
footer {
42+
max-width: min(60rem, 100vw);
43+
}
44+
.container {
45+
min-width: 100rem;
46+
}
47+
/*When screen is large enough, make sure left boundary is the same as normal post.*/
48+
/*Match content-width=60rem*/
49+
@media (min-width: 62rem) {
50+
.container {
51+
margin-left: calc(50% - 30rem);
52+
max-width: 75rem;
53+
}
54+
}
55+
/*When screen is small, make sure left side is still fully visible.*/
56+
@media (max-width: 680px) {
57+
.container {
58+
max-width: calc(200vw + 25px);
59+
min-width: calc(200vw + 25px);
60+
}
61+
}
62+
.side-by-side tbody tr td {
63+
width: 50%;
64+
}
65+
.side-by-side tbody tr td:first-child {
66+
padding: 0px 40px 0px 0px;
67+
}
68+
.side-by-side tbody tr td:nth-child(2) {
69+
padding: 0px 0px 0px 20px;
70+
}
71+
</style>
72+
{% elsif page.side_by_side == "comment" %}
73+
<style>
74+
header {
75+
max-width: 100vw;
76+
}
77+
/*Match content-width=60rem*/
78+
footer {
79+
max-width: min(60rem, 100vw);
80+
}
81+
.container {
82+
min-width: 60rem;
83+
}
84+
/*When screen is large enough, make sure left boundary is the same as normal post.*/
85+
/*Match content-width=60rem*/
86+
@media (min-width: 62rem) {
87+
.container {
88+
margin-left: calc(50% - 30rem);
89+
max-width: 67rem;
90+
}
91+
}
92+
/*When screen is small, make sure left side is still fully visible.*/
93+
@media (max-width: 620px) {
94+
.container {
95+
max-width: calc(133vw);
96+
min-width: calc(133vw);
97+
}
98+
}
99+
.side-by-side tbody tr {
100+
position: relative;
101+
}
102+
.side-by-side tbody tr td:first-child {
103+
padding: 0px 20px 0px 0px;
104+
width: 85%;
105+
}
106+
.side-by-side tbody tr td:nth-child(2) {
107+
position: absolute;
108+
top: 0;
109+
width: 15%;
110+
padding: 0;
111+
font-size: 0.9rem;
112+
text-align: left;
113+
}
114+
.side-content {
115+
top: 0;
116+
width: 1;
117+
}
118+
</style>
119+
{% endif %}
40120
{% seo %}
41121
</head>
42122
<body class="snow hack">
@@ -46,15 +126,23 @@
46126
{% include navbar.html %}
47127

48128
<div class="snowframe">
49-
{% unless page.override_title %}
50-
<h1>{{page.title}}</h1>
51-
{% endunless %}
52-
{% if page.category %}
53129
{% assign date = page.date | split: ' ' %}
54-
{% assign prefix = date[0] %}
55-
<p class="hidden-text"># {{page.category}}, {{ prefix }}</p>
130+
{% assign subtitle = '<p class="hidden-text"># ' | append: page.category | append: ', ' | append: date[0] | append: '</p>' %}
131+
132+
{% unless page.hide_title_in_page %}
133+
<h1>{{page.title}}</h1>
134+
{% if page.category %}
135+
{{ subtitle }}
136+
{% assign subtitle = '' %}
137+
{% endif %}
138+
{% endunless %}
139+
140+
{% if page.side_by_side %}
141+
{{ content | side_by_side_with_subtitle: page.side_by_side, subtitle }}
142+
{% else %}
143+
{{ content }}
56144
{% endif %}
57-
{{content}}
145+
58146
{% if page.childs and page.childs.size > 0 %}
59147
<hr></hr>
60148
<ul>

_layouts/catalog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h1>{{page.title}}</h1>
8181
</ul>
8282
<ul id="showOnChecked" style="display: none;">
8383
{% assign categoryGrouped = site.posts | group_by: 'category' %}
84-
{% assign categorySorted = categoryGrouped | sort: 'name' %}
84+
{% assign categorySorted = categoryGrouped | sort: 'title' %}
8585
{% for category in categorySorted %}
8686
{% unless forloop.first %}
8787
<br />

_plugins/side-by-side.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
require 'nokogiri'
2+
3+
module Jekyll
4+
module SideBySideFilter
5+
def side_by_side_with_subtitle(input, mode, subtitle)
6+
@doc = Nokogiri::HTML::DocumentFragment.parse(input)
7+
@elements = []
8+
@doc.children.each do |node|
9+
@elements.push(node.to_s)
10+
end
11+
@result = '<table class="side-by-side"><tbody>'
12+
if mode == 'translation'
13+
@elements.select { |e| !e.strip.empty? }.each_slice(2).to_a.each do |e|
14+
@result << %(<tr><td>#{e[0]}</td><td>#{e[1]}</td></tr>)
15+
if !subtitle.strip.empty? and e[0].include? '<h1'
16+
@result << %(<tr><td>#{subtitle}</td><td></td></tr>)
17+
end
18+
end
19+
elsif mode == 'comment'
20+
@comments = ''
21+
@opened = false
22+
@elements.select { |e| !e.strip.empty? }.each do |e|
23+
if e.slice! '[NOTE] '
24+
@comments << e
25+
else
26+
if @opened
27+
@result << %(<td>#{@comments}</td></tr>)
28+
@comments = ''
29+
end
30+
if e.include? '<h1'
31+
@result << %(<tr><td>#{e}#{subtitle}</td>)
32+
else
33+
@result << %(<tr><td>#{e}</td>)
34+
end
35+
@opened = true
36+
end
37+
end
38+
end
39+
@result << '</table></tbody>'
40+
return @result
41+
end
42+
end
43+
end
44+
45+
Liquid::Template.register_filter(Jekyll::SideBySideFilter)

0 commit comments

Comments
 (0)