rawfeed 0.2.4 → 0.2.5

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: cedeb842d14a644f5d8f81747b0414fac02509c4ac5f2548b82af13371ea4cfa
4
+ data.tar.gz: c1a185a440a5fe678666085b23df440702454b0b81ba832f2d98fedbee99bb8a
5
5
  SHA512:
6
- metadata.gz: 58ed203632f48facc743334dbcee401886ee70f409885f7c720eed7aa2f6342761e9a18e9e7da0f997094c5768bc5bacf1ffbecca81e049e5be63efd4c5db446
7
- data.tar.gz: da43880931fc8d59d35cb82ac9b1d557044b0f0453342f0747798ff17f43c4c26a3a2b9bbede385b4fcbbe4051527421a60264f74c3b1702015133644b289abb
6
+ metadata.gz: e20abb9a11eb223aca026c3986756254e7bdea461f132fd2540cb6752b0c53137cb7a412f5200acf94474d63a4170962ba5a12050a1d3ebdf84be80f4d0b96d0
7
+ data.tar.gz: d0626b88db3902c752f1596b1936f1746b2b0347f6ad5f253c1598c70f1dea384c58354f6a79cba6a90abab173fd5d08f3bdcdbeb8a6323c13f3d114ba4ae496
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,141 @@
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
+ self.read_yaml(File.join(base, '_layouts'), 'pub.html')
15
+
16
+ # Define o permalink correto para a página de índice
17
+ # Garante que 'pub/sub/index.html' tenha o permalink '/pub/sub/'
18
+ self.data['permalink'] = "/#{dir}/"
19
+
20
+ # Título (opcional, pode ser formatado no layout)
21
+ self.data['title'] = File.basename(dir).capitalize
22
+
23
+ # A MÁGICA: Injeta a lista de conteúdo no objeto da página
24
+ self.data['directory_contents'] = files_and_dirs
25
+ self.data['layout'] = 'pub'
26
+ end
27
+ end
28
+
29
+ # O gerador que executa o escaneamento recursivo
30
+ class DirectoryListingGenerator < Generator
31
+ safe true
32
+ priority :normal
33
+
34
+ # Diretório principal que você deseja listar
35
+ PUB_DIR = 'pub'
36
+
37
+ def generate(site)
38
+ # Pega todos os arquivos e diretórios dentro de PUB_DIR
39
+ # Exclui o PUB_DIR raiz em si.
40
+ all_paths = Dir.glob("#{PUB_DIR}/**/{" + '*' + ",.*}")
41
+
42
+ # Itera sobre cada item encontrado e agrupa por diretório pai
43
+ directory_map = {}
44
+
45
+ all_paths.each do |path|
46
+ # Ignora arquivos/diretórios que o Jekyll já processa ou ignora
47
+ next if path.start_with?('_') || path.start_with?('.')
48
+ next if File.basename(path) == 'index.html'
49
+
50
+ # Determina o diretório pai (o que vai ter o index.html gerado)
51
+ parent_dir = File.dirname(path)
52
+ parent_dir = PUB_DIR if parent_dir == '.'
53
+
54
+ # Inicializa a lista se for a primeira vez
55
+ directory_map[parent_dir] ||= []
56
+
57
+ # Determina o tipo e prepara os dados
58
+ if File.directory?(path)
59
+ # Se for um diretório, adiciona a barra final para URL
60
+ type = 'directory'
61
+ url = "/#{path}/"
62
+ size = ''
63
+ date = File.mtime(path)
64
+ # Adiciona apenas se o diretório não estiver vazio
65
+ directory_map[parent_dir] << {
66
+ 'name' => File.basename(path),
67
+ 'type' => type,
68
+ 'url' => url,
69
+ 'date' => date
70
+ } unless Dir.empty?(path)
71
+ else
72
+ # Se for um arquivo
73
+ type = 'file'
74
+ url = "/#{path}"
75
+ size = File.size(path) # Tamanho em bytes
76
+ date = File.mtime(path)
77
+
78
+ # Adiciona o item ao seu diretório pai
79
+ directory_map[parent_dir] << {
80
+ 'name' => File.basename(path),
81
+ 'type' => type,
82
+ 'url' => url,
83
+ 'size' => size,
84
+ 'date' => date
85
+ }
86
+ end
87
+ end
88
+
89
+ # Cria as páginas de listagem dinamicamente
90
+ directory_map.each do |dir_path, contents|
91
+ # Classifica por tipo (diretórios primeiro), depois por nome
92
+ sorted_contents = contents.sort_by do |item|
93
+ [item['type'] == 'file' ? 1 : 0, item['name'].downcase]
94
+ end
95
+
96
+ # Lógica para a entrada de navegação '..'
97
+ parent_url = nil
98
+ parent_name = '../'
99
+
100
+ if dir_path == PUB_DIR
101
+ # Caso especial: se estiver na raiz 'pub/', o pai é a raiz do site '/'
102
+ parent_url = '/'
103
+ else
104
+ # Para todos os outros subdiretórios (ex: pub/subpasta)
105
+ parent_dir = File.dirname(dir_path)
106
+
107
+ # Garante que 'pub' não se torne '.' e que o URL termine em barra
108
+ if parent_dir == PUB_DIR
109
+ parent_url = "/#{PUB_DIR}/"
110
+ else
111
+ parent_url = "/#{parent_dir}/"
112
+ end
113
+ end
114
+
115
+ # Adiciona a entrada de navegação para o diretório pai
116
+ sorted_contents.unshift({
117
+ 'name' => parent_name,
118
+ 'type' => 'parent',
119
+ 'url' => parent_url
120
+ })
121
+
122
+ # # Adiciona a página ".." para navegar de volta, exceto para o pub/ raiz
123
+ # unless dir_path == PUB_DIR
124
+ # parent_url = File.dirname(dir_path)
125
+ # parent_url = '/' if parent_url == '.'
126
+ # parent_url = "/#{parent_url}/" unless parent_url == '/'
127
+
128
+ # sorted_contents.unshift({
129
+ # 'name' => '../',
130
+ # 'type' => 'parent',
131
+ # 'url' => parent_url
132
+ # })
133
+ # end
134
+
135
+ # Cria a nova página e a adiciona ao site
136
+ page = DirectoryListingPage.new(site, site.source, dir_path, sorted_contents)
137
+ site.pages << page
138
+ end
139
+ end
140
+ end
141
+ 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.5"
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.5
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