rawfeed 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8511f7129df556936ff6d30d8603ae79a2a83cdcb2be2482fe325cf67efc875f
4
- data.tar.gz: 4bfec0dee20997adc15158230a331ac79a1626ae59c367df03455bc74710d306
3
+ metadata.gz: e38efdd724f19c9a50f8d3097ae15dff4b3ed6e68d80c504b60c0b866c76d302
4
+ data.tar.gz: 5c5229845ab2838d7f725787ae7aa11dd2dbff9e9b502b60b9748087886ac4eb
5
5
  SHA512:
6
- metadata.gz: 58ed203632f48facc743334dbcee401886ee70f409885f7c720eed7aa2f6342761e9a18e9e7da0f997094c5768bc5bacf1ffbecca81e049e5be63efd4c5db446
7
- data.tar.gz: da43880931fc8d59d35cb82ac9b1d557044b0f0453342f0747798ff17f43c4c26a3a2b9bbede385b4fcbbe4051527421a60264f74c3b1702015133644b289abb
6
+ metadata.gz: 9f99a59a9a195d3662436fbc21d5b74e2f67e7f836b3bd696b9d6c7f74f82b279beafea3b23b836b03eb59a9e4c0fa1c6f7c548d71d9408afcdbb8d325a45bd4
7
+ data.tar.gz: 66d1a48918578fa02cf82baabad25d9b5cc9314bb1e2fd6b59110cbb938d8c746511728f08f959b1bd15de02a1d7d8878e4d57b93a4d6dfcd5865877387e0461
data/_data/options.yml CHANGED
@@ -151,6 +151,9 @@ header:
151
151
  pixels:
152
152
  emoji: "📷"
153
153
  title: "pixels"
154
+ pub:
155
+ emoji: "📂"
156
+ title: "pub"
154
157
 
155
158
  # section: [home]
156
159
  home:
@@ -257,6 +260,11 @@ contact:
257
260
  fail: "Verification failed. Please reload the page and try again."
258
261
  error: "An error occurred while sending the message. Please try again."
259
262
 
263
+ # section: [pub]
264
+ pub:
265
+ path:
266
+ title: "Index of"
267
+
260
268
  # section: [footer]
261
269
  footer:
262
270
  top_button:
@@ -5,6 +5,7 @@
5
5
  {%- assign pixels_url = "/pixels/" | relative_url -%}
6
6
  {%- assign search_url = "/blog/?search=open" | relative_url -%}
7
7
  {%- assign tags_url = "/blog/tags/" | relative_url -%}
8
+ {%- assign pub_url = "/pub/" | relative_url -%}
8
9
  {%- assign feed_url = "/feed.xml" | relative_url -%}
9
10
  {%- assign head_ = site.data.options.head -%}
10
11
  {%- assign site_title = site.data.options.title -%}
@@ -18,6 +19,7 @@
18
19
  {%- assign contact_ = site.data.options.contact -%}
19
20
  {%- assign footer_ = site.data.options.footer -%}
20
21
  {%- assign socials_ = site.data.options.socials -%}
22
+ {%- assign pub_ = site.data.options.pub -%}
21
23
  {%- assign datelang_ = site.data.options.datelang -%}
22
24
  {%- assign maintenance_ = site.data.options.maintenance -%}
23
25
  {%- assign reading_time_ = site.data.options.reading_time -%}
@@ -151,6 +151,10 @@
151
151
  {%- endif -%}
152
152
  {%- endfor -%}
153
153
  {%- endif -%}
154
+ {%- assign files_in_pub = site.static_files | where_exp: "item", "item.path contains pub_url" -%}
155
+ {%- if files_in_pub.size > 0 -%}
156
+ <div class="menu-wrap-link">{{ header_.menu.pub.emoji | with_class: "spacer" }}<a href="{{ pub_url }}">{{ header_.menu.pub.title }}</a></div>
157
+ {%- endif -%}
154
158
  </div>
155
159
  {%- endif -%}
156
160
  {%- endif -%}
data/_layouts/pub.html ADDED
@@ -0,0 +1,51 @@
1
+ {%- include layout/data.liquid -%}
2
+
3
+ {%- if maintenance_.enable != true -%}
4
+ {% assign current_path = page.permalink | default: '/' %}
5
+
6
+ <!DOCTYPE html>
7
+ <html id="top" lang="{{ default_.lang | default: 'en-US' }}" data-theme="light">
8
+ <!-- head -->
9
+ {%- include layout/head.html -%}
10
+ <!-- head -->
11
+ <body style="font-family: {{ default_.font.style }} !important;">
12
+ <div class="container-fluid">
13
+ <div class="row">
14
+ <main class="col-sm pub">
15
+ <h1 class="pub-path">{{ pub_.path.title | default: 'Index of' }} {{ current_path }}</h1>
16
+ <hr>
17
+ {% for item in page.directory_contents %}
18
+ <div class="row pub-line">
19
+ <div class="col-sm">
20
+ {% if item.type == 'directory' %}
21
+ <a href="{{ item.url }}">{{ item.name }}/</a>
22
+ {% elsif item.type == 'parent' %}
23
+ <a href="{{ item.url }}">{{ item.name }}</a>
24
+ {% else %}
25
+ <a href="{{ item.url }}">{{ item.name }}</a>
26
+ {% endif %}
27
+ </div>
28
+
29
+ <div class="col-sm">
30
+ {% if item.date %}
31
+ <span class="date">{{ item.date | date: "%Y-%m-%d %H:%M" }}</span>
32
+ {% endif %}
33
+ </div>
34
+
35
+ <div class="col-sm">
36
+ {% if item.type == 'file' %}
37
+ <span class="size">{{ item.size | divided_by: 1024.0 | round: 2 }} KB</span>
38
+ {% endif %}
39
+ </div>
40
+ </div>
41
+ {% endfor %}
42
+ <hr>
43
+ </main>
44
+ </div>
45
+ </div>
46
+ {%- include layout/footer.html -%}
47
+ </body>
48
+ </html>
49
+ {%- else -%}
50
+ {%- include layout/maintenance.html -%}
51
+ {%- endif -%}
@@ -11,3 +11,4 @@
11
11
  @use "licenses";
12
12
  @use "pixels";
13
13
  @use "pixel";
14
+ @use "pub";
@@ -0,0 +1,18 @@
1
+ .pub {
2
+ font-size: 13px;
3
+ color: var(--text-color);
4
+ a {
5
+ color: var(--primary-color);
6
+ }
7
+ &-path {
8
+ font-size: 32px;
9
+ font-family: 'Times New Roman', Times, serif;
10
+ padding: 15px 0px;
11
+ font-weight: bold !important;
12
+ }
13
+ &-line {
14
+ @media (max-width: 575px) {
15
+ margin-bottom: 15px !important;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,144 @@
1
+ # pub.rb
2
+
3
+ module Jekyll
4
+ # Define a página que será gerada dinamicamente para cada diretório
5
+ class DirectoryListingPage < Page
6
+ def initialize(site, base, dir, files_and_dirs)
7
+ @site = site
8
+ @base = base
9
+ @dir = dir
10
+ @name = 'index.html'
11
+ @layout_name = 'pub.html'
12
+
13
+ self.process(@name)
14
+ theme_layouts = File.join(site.theme.root, "_layouts")
15
+ self.read_yaml(theme_layouts, "pub.html")
16
+ # # Note: This is for _plugins/
17
+ # self.read_yaml(File.join(base, '_layouts'), 'pub.html')
18
+
19
+ # Define o permalink correto para a página de índice
20
+ # Garante que 'pub/sub/index.html' tenha o permalink '/pub/sub/'
21
+ self.data['permalink'] = "/#{dir}/"
22
+
23
+ # Título (opcional, pode ser formatado no layout)
24
+ self.data['title'] = File.basename(dir).capitalize
25
+
26
+ # A MÁGICA: Injeta a lista de conteúdo no objeto da página
27
+ self.data['directory_contents'] = files_and_dirs
28
+ self.data['layout'] = 'pub'
29
+ end
30
+ end
31
+
32
+ # O gerador que executa o escaneamento recursivo
33
+ class DirectoryListingGenerator < Generator
34
+ safe true
35
+ priority :normal
36
+
37
+ # Diretório principal que você deseja listar
38
+ PUB_DIR = 'pub'
39
+
40
+ def generate(site)
41
+ # Pega todos os arquivos e diretórios dentro de PUB_DIR
42
+ # Exclui o PUB_DIR raiz em si.
43
+ all_paths = Dir.glob("#{PUB_DIR}/**/{" + '*' + ",.*}")
44
+
45
+ # Itera sobre cada item encontrado e agrupa por diretório pai
46
+ directory_map = {}
47
+
48
+ all_paths.each do |path|
49
+ # Ignora arquivos/diretórios que o Jekyll já processa ou ignora
50
+ next if path.start_with?('_') || path.start_with?('.')
51
+ next if File.basename(path) == 'index.html'
52
+
53
+ # Determina o diretório pai (o que vai ter o index.html gerado)
54
+ parent_dir = File.dirname(path)
55
+ parent_dir = PUB_DIR if parent_dir == '.'
56
+
57
+ # Inicializa a lista se for a primeira vez
58
+ directory_map[parent_dir] ||= []
59
+
60
+ # Determina o tipo e prepara os dados
61
+ if File.directory?(path)
62
+ # Se for um diretório, adiciona a barra final para URL
63
+ type = 'directory'
64
+ url = "/#{path}/"
65
+ size = ''
66
+ date = File.mtime(path)
67
+ # Adiciona apenas se o diretório não estiver vazio
68
+ directory_map[parent_dir] << {
69
+ 'name' => File.basename(path),
70
+ 'type' => type,
71
+ 'url' => url,
72
+ 'date' => date
73
+ } unless Dir.empty?(path)
74
+ else
75
+ # Se for um arquivo
76
+ type = 'file'
77
+ url = "/#{path}"
78
+ size = File.size(path) # Tamanho em bytes
79
+ date = File.mtime(path)
80
+
81
+ # Adiciona o item ao seu diretório pai
82
+ directory_map[parent_dir] << {
83
+ 'name' => File.basename(path),
84
+ 'type' => type,
85
+ 'url' => url,
86
+ 'size' => size,
87
+ 'date' => date
88
+ }
89
+ end
90
+ end
91
+
92
+ # Cria as páginas de listagem dinamicamente
93
+ directory_map.each do |dir_path, contents|
94
+ # Classifica por tipo (diretórios primeiro), depois por nome
95
+ sorted_contents = contents.sort_by do |item|
96
+ [item['type'] == 'file' ? 1 : 0, item['name'].downcase]
97
+ end
98
+
99
+ # Lógica para a entrada de navegação '..'
100
+ parent_url = nil
101
+ parent_name = '../'
102
+
103
+ if dir_path == PUB_DIR
104
+ # Caso especial: se estiver na raiz 'pub/', o pai é a raiz do site '/'
105
+ parent_url = '/'
106
+ else
107
+ # Para todos os outros subdiretórios (ex: pub/subpasta)
108
+ parent_dir = File.dirname(dir_path)
109
+
110
+ # Garante que 'pub' não se torne '.' e que o URL termine em barra
111
+ if parent_dir == PUB_DIR
112
+ parent_url = "/#{PUB_DIR}/"
113
+ else
114
+ parent_url = "/#{parent_dir}/"
115
+ end
116
+ end
117
+
118
+ # Adiciona a entrada de navegação para o diretório pai
119
+ sorted_contents.unshift({
120
+ 'name' => parent_name,
121
+ 'type' => 'parent',
122
+ 'url' => parent_url
123
+ })
124
+
125
+ # # Adiciona a página ".." para navegar de volta, exceto para o pub/ raiz
126
+ # unless dir_path == PUB_DIR
127
+ # parent_url = File.dirname(dir_path)
128
+ # parent_url = '/' if parent_url == '.'
129
+ # parent_url = "/#{parent_url}/" unless parent_url == '/'
130
+
131
+ # sorted_contents.unshift({
132
+ # 'name' => '../',
133
+ # 'type' => 'parent',
134
+ # 'url' => parent_url
135
+ # })
136
+ # end
137
+
138
+ # Cria a nova página e a adiciona ao site
139
+ page = DirectoryListingPage.new(site, site.source, dir_path, sorted_contents)
140
+ site.pages << page
141
+ end
142
+ end
143
+ end
144
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rawfeed
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.6"
5
5
  end
data/lib/rawfeed.rb CHANGED
@@ -12,5 +12,6 @@ require_relative "rawfeed/author"
12
12
  require "rawfeed/datelang"
13
13
  require "rawfeed/reading_time"
14
14
  require "rawfeed/with_class"
15
+ require "rawfeed/pub"
15
16
  # require "rawfeed/csp_filters"
16
17
  # require "rawfeed/typescript_liquid"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rawfeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - William C. Canin
@@ -166,6 +166,7 @@ files:
166
166
  - _layouts/pixel.html
167
167
  - _layouts/pixels.html
168
168
  - _layouts/post.html
169
+ - _layouts/pub.html
169
170
  - _layouts/resume.html
170
171
  - _layouts/tag.html
171
172
  - _layouts/tag_posts.html
@@ -198,6 +199,7 @@ files:
198
199
  - _sass/layouts/_pixel.scss
199
200
  - _sass/layouts/_pixels.scss
200
201
  - _sass/layouts/_post.scss
202
+ - _sass/layouts/_pub.scss
201
203
  - _sass/layouts/_resume.scss
202
204
  - _sass/layouts/_tag-posts.scss
203
205
  - _sass/layouts/_tag.scss
@@ -295,6 +297,7 @@ files:
295
297
  - lib/rawfeed/page.rb
296
298
  - lib/rawfeed/pixel.rb
297
299
  - lib/rawfeed/post.rb
300
+ - lib/rawfeed/pub.rb
298
301
  - lib/rawfeed/reading_time.rb
299
302
  - lib/rawfeed/resume.rb
300
303
  - lib/rawfeed/typescript_liquid.rb