jekyll-obsidian 1.1.2 → 1.1.8

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: d080f763648a7d4d15eb6b5b65d41dc7e22c4f4030366fd7f11ab75a52b421ab
4
- data.tar.gz: 4ef6b231668c6442cd2d36d7c595fe507f9a029ecd7767fe2997e6231416bb22
3
+ metadata.gz: 6db0db65249ec7386744cede3b75cba76663d178bd6c9ecba259c4c8dc1af477
4
+ data.tar.gz: 2c8fae8a7e9ec6c63c484417edc691a7090fd4ceca682ab643911430f024d24a
5
5
  SHA512:
6
- metadata.gz: fc15afa41dec63f364dba5b3657ec499c8fbc95425964a71a781cad7305f4dfbe0d05923d0e42d94caf92e6127229933ca9cdd9290983351172a60c1fea2df41
7
- data.tar.gz: '084533f538cb36977c5e4c24bc0bf988a9c736031a862d6c8a2829c5d88784e08506328d984b26279dddebbd89bcaabb98d6bb1fe3467533f37409f0cc03f920'
6
+ metadata.gz: 9a4cd05ebb9921e622e1a5ca0c45d54e2a6d8e62f8d7f8eda9e8f5d2b0e18224e8a941177281b6e1facb98fc4af1ecfe23938315be7d5dac92742a05bf94fddb
7
+ data.tar.gz: 27223fc85608f08520f5f92b3ef9f6046424bd48cec8cdf47f485821a9790c3f51dac5c16b5e86899f8626d659e2bcf119a0b2e34f314bd00e73eb7dddba2d1d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.8] - 2025-01-09
4
+ - Strings of file links in File Search are formatted similar to native app
5
+
6
+ ## [1.1.3] - 2025-01-09
7
+ - Fixed embeds with consecutive trailing periods
8
+
3
9
  ## [1.1.2] - 2024-09-13
4
10
  - Fixed duplicate linked mentions
5
11
  - Added text color to linked mention
data/README.md CHANGED
@@ -63,7 +63,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
63
63
  ```
64
64
  6. Run `bundle install` or `bundle update jekyll-obsidian`, if you already installed it
65
65
 
66
- 7. Run `bundle exec jekyll build` to generate the necessary `.css` and `.json` files, and convert all your `.md` notes to `.mdnote`.
66
+ 7. Run `bundle exec jekyll build` to generate the necessary `.css` and `.json` files, and convert all your `.md` notes to `.mdj`.
67
67
 
68
68
  8. Run `bundle exec jekyll serve`, you should now see your Obsidian page at your given permalink
69
69
 
@@ -25,8 +25,8 @@
25
25
  }
26
26
 
27
27
  @media (min-width:1281px) {
28
- min-width: 0;
29
- max-width: 30%;
28
+ min-width: 40%;
29
+ max-width: 80%;
30
30
  }
31
31
  }
32
32
 
@@ -172,9 +172,8 @@
172
172
  #media-modal {
173
173
  width: max-content;
174
174
  height: max-content;
175
- min-width: max-content;
176
- max-width: 80% !important;
177
- max-height: 80% !important;
175
+ max-width: 84%;
176
+ max-height: 84%;
178
177
 
179
178
  #media {
180
179
 
@@ -93,7 +93,7 @@
93
93
  if (index === filePathArr.length - 1) {
94
94
  btn.textContent = extractFilenameFromPath(path);
95
95
  btn.addEventListener('click', () => {
96
- if (filePath.endsWith('.mdnote'))
96
+ if (filePath.endsWith('.mdj'))
97
97
  FILEREAD.scrollTop = 0;
98
98
  else if (filePath.endsWith('.canvas'))
99
99
  resetCanvasPosition();
@@ -146,7 +146,6 @@
146
146
 
147
147
  function generateCallouts(calloutsArr, cleanedHTML) {
148
148
  calloutsArr.forEach(callout => {
149
- // Extract the callout type including square brackets, removing "> " part
150
149
  const calloutType = callout.slice(2).trim().toLowerCase();
151
150
  console.log("calloutType: " + calloutType);
152
151
  let svgString = '';
@@ -211,9 +210,9 @@
211
210
  const embedsParsed = JSON.parse(embeds.replace(/"/g, '"'));
212
211
  embedsArr.forEach(embed => {
213
212
  const fileNameMatch = embed.match(/\[\[(.*?)\]\]/);
214
- console.log("fileNameMatch: " + fileNameMatch);
215
213
  if (fileNameMatch) {
216
214
  const fileName = extractFilenameFromPath(fileNameMatch[1]);
215
+ console.log("fileNameMatch: " + fileNameMatch + " embed " + embed);
217
216
  for (let key in embedsParsed) {
218
217
  const embedFileName = extractFilenameFromPath(key);
219
218
  if (embedFileName.replace("/:|", "'") === fileName) {
@@ -316,7 +315,7 @@
316
315
  function dispatchFileSelectEvt(filePath, heading) {
317
316
  const EXPLORER = OBSIDIAN.querySelector('#explorer');
318
317
  const detail = { filePath };
319
- if (filePath.endsWith('.mdnote')) {
318
+ if (filePath.endsWith('.mdj')) {
320
319
  if (heading) detail.heading = heading;
321
320
  const event = new CustomEvent('obsidian_noteSelect', { detail });
322
321
  document.dispatchEvent(event);
@@ -20,8 +20,9 @@
20
20
  ×
21
21
  </button>
22
22
  <p><a href="https://github.com/khiemgluong/jekyll-obsidian" target="_blank">jekyll-obsidian</a></p>
23
- <p>View <a href="https://obsidian.md/" target="_blank">Obsidian</a> vaults, on your <a
24
- href="https://jekyllrb.com/" target="_blank">Jekyll</a> website.</p>
23
+ <p>View <a href="https://obsidian.md/" target="_blank">Obsidian</a>
24
+ vaults, on your <a href="https://jekyllrb.com/" target="_blank">Jekyll</a>
25
+ website.</p>
25
26
 
26
27
  <span>Color scheme</span>
27
28
  <select id="color-scheme">
@@ -203,21 +204,25 @@
203
204
  <script>
204
205
  function generateSearchModalFilepaths(vaultFiles, ul) {
205
206
  vaultFiles.forEach(child => {
206
- if (child.type === 'dir') {
207
+ if (child.type === 'dir')
207
208
  generateSearchModalFilepaths(child.children, ul);
208
- }
209
209
  if (child.type === 'file') {
210
210
  const li = document.createElement('li');
211
211
  const button = document.createElement('button');
212
212
  const decodedString = he.decode(child.path);
213
- // if (decodedString.endsWith('.mdnote')) {
214
- // button.textContent = decodedString.slice(0, -4);
215
- // } else
216
- button.textContent = decodedString;
213
+
214
+ switch (getFileType(child.path)) {
215
+ case "note":
216
+ button.textContent = decodedString.replace(/\.[^/.]+$/, "");
217
+ break;
218
+ default:
219
+ button.textContent = decodedString;
220
+ break;
221
+ }
222
+ button.textContent = button.textContent.slice(1);
217
223
  button.addEventListener('click', () => {
218
- const searchModal = MODALS.querySelector('#search-modal');
219
224
  dispatchFileSelectEvt(decodedString);
220
- searchModal.hidePopover();
225
+ MODALS.querySelector('#search-modal').hidePopover();
221
226
  });
222
227
  li.appendChild(button); ul.appendChild(li);
223
228
  }
@@ -79,7 +79,7 @@
79
79
  for (const parsedFilePath in backlinks_parsed) {
80
80
  const entry = backlinks_parsed[parsedFilePath];
81
81
  entry.backlink_paths.forEach(path => {
82
- if (path === filePath && parsedFilePath.endsWith('.mdnote')) {
82
+ if (path === filePath && parsedFilePath.endsWith('.mdj')) {
83
83
  linked_mentions.push(parsedFilePath.replace("/:|", "'"));
84
84
  }
85
85
  });
@@ -157,9 +157,8 @@
157
157
  let homepage = '{{ site.obsidian_homepage | escape }}';
158
158
  if (homepage) {
159
159
  if (homepage.endsWith('.md'))
160
- homepage = homepage.replace('.md', '.mdnote');
161
-
162
- if (homepage.endsWith('.mdnote')) {
160
+ homepage = homepage.replace('.md', '.mdj');
161
+ if (homepage.endsWith('.mdj')) {
163
162
  switchPage(homepage);
164
163
  loadNote(homepage);
165
164
  console.log("note loaded: " + homepage);
@@ -1,22 +1,28 @@
1
1
  <body>
2
2
  <div id="top-container">
3
3
  <button id="homepage" onclick="loadHomepage()">
4
- <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
4
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
5
+ width="24" height="24" fill="none"
5
6
  viewBox="0 0 24 24">
6
- <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
7
+ <path stroke="currentColor" stroke-linecap="round"
8
+ stroke-linejoin="round" stroke-width="1.5"
7
9
  d="m4 12 8-8 8 8M6 10.5V19a1 1 0 0 0 1 1h3v-3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3h3a1 1 0 0 0 1-1v-8.5" />
8
10
  </svg>
9
11
  </button>
10
- <button id="search" onclick="dispatchModalSelectEvt('search')" popovertarget="search-modal">
11
- <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="none"
12
+ <button id="search" onclick="dispatchModalSelectEvt('search')"
13
+ popovertarget="search-modal">
14
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
15
+ width="22" height="22" fill="none"
12
16
  viewBox="0 0 24 24">
13
- <path stroke="currentColor" stroke-linecap="round" stroke-width="2"
17
+ <path stroke="currentColor" stroke-linecap="round"
18
+ stroke-width="2"
14
19
  d="m21 21-3.5-3.5M17 10a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z" />
15
20
  </svg>
16
21
 
17
22
  </button>
18
23
  <button id="tags" onclick="dispatchModalSelectEvt('tags')">
19
- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16">
24
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"
25
+ fill="currentColor" viewBox="0 0 16 16">
20
26
  <path
21
27
  d="M3 2v4.586l7 7L14.586 9l-7-7zM2 2a1 1 0 0 1 1-1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 2 6.586z" />
22
28
  <path
@@ -25,10 +31,13 @@
25
31
  </button>
26
32
  </div>
27
33
  <div id="bottom-container">
28
- <button id="info" onclick="dispatchModalSelectEvt('info')" popovertarget="info-modal">
29
- <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
34
+ <button id="info" onclick="dispatchModalSelectEvt('info')"
35
+ popovertarget="info-modal">
36
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
37
+ width="24" height="24" fill="none"
30
38
  viewBox="0 0 24 24">
31
- <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
39
+ <path stroke="currentColor" stroke-linecap="round"
40
+ stroke-linejoin="round" stroke-width="2"
32
41
  d="M10 11h2v5m-2 0h4m-2.592-8.5h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
33
42
  </svg>
34
43
  </button>
@@ -40,8 +49,9 @@
40
49
  let homepage = '{{ site.obsidian_homepage | escape }}';
41
50
  if (homepage) {
42
51
  if (homepage.endsWith('.md'))
43
- homepage = homepage.replace('.md', '.mdnote');
44
- if (homepage.endsWith('.mdnote')) {
52
+ homepage = homepage.replace('.md', '.mdj');
53
+ if (homepage.endsWith('.mdj'))
54
+ {
45
55
  switchPage(homepage);
46
56
  loadNote(homepage);
47
57
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  <head>
5
5
  <script src="https://cdn.jsdelivr.net/npm/he@latest/he.min.js"></script>
6
- <script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.1.6/purify.min.js"></script>
6
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.3/purify.min.js"></script>
7
7
  <script src=" https://cdn.jsdelivr.net/npm/js-cookie@3.0.5/dist/js.cookie.min.js "></script>
8
8
  <link rel="stylesheet" href="{{ '/assets/obsidian/obsidian.css' | relative_url }}">
9
9
  <style>
@@ -152,6 +152,10 @@
152
152
 
153
153
  function getFileType(filePath) {
154
154
  const extensionToType = {
155
+ // Notes
156
+ 'mdj': 'note', 'txt': 'note',
157
+ // Canvas
158
+ 'canvas': 'canvas',
155
159
  // Images
156
160
  'jpg': 'image', 'jpeg': 'image', 'png': 'image', 'gif': 'image', 'bmp': 'image', 'webp': 'image',
157
161
  // PDFs
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Obsidian
5
- VERSION = "1.1.2"
5
+ VERSION = "1.1.8"
6
6
  end
7
7
  end
@@ -9,14 +9,6 @@ require_relative "obsidian/version"
9
9
 
10
10
  module Jekyll
11
11
  module Obsidian
12
- # Jekyll::Hooks.register :site, :post_write do |site|
13
- # vault = site.config["obsidian_vault"]
14
- # vault_path = File.join(site.dest, vault)
15
- # Dir.glob(File.join(vault_path, "**", "*.md")).each do |md_file|
16
- # new_file_path = md_file.sub(/\.md$/, ".mdnote")
17
- # File.rename(md_file, new_file_path)
18
- # end
19
- # end
20
12
  class FileTreeGenerator < Jekyll::Generator
21
13
  safe true
22
14
  priority :lowest
@@ -101,7 +93,7 @@ module Jekyll
101
93
  puts "#{File.basename(file)} currently exists"
102
94
  else
103
95
  FileUtils.cp(file, dir)
104
- puts "#{File.basename(file)} copied over"
96
+ # puts "#{File.basename(file)} copied over"
105
97
  end
106
98
  else
107
99
  puts "Error: #{file} does not exist"
@@ -140,13 +132,27 @@ module Jekyll
140
132
  next if File.zero?(entry_path) || File.empty?(entry_path)
141
133
 
142
134
  if File.extname(entry) == ".md"
143
- new_name = entry.sub(".md", ".mdnote")
135
+ new_name = entry.sub(".md", ".mdj")
136
+ # convert markdown to markdownjekyll files
144
137
  new_path = File.join(rootdir, new_name)
145
138
  File.rename(entry_path, new_path)
146
139
  entry_path = new_path
147
140
  entry = new_name
148
141
  end
149
142
 
143
+ if /\.\./.match?(entry) # Checks for two or more consecutive periods
144
+ base_name = File.basename(entry, File.extname(entry)).gsub(/\.{2,}/, ".")
145
+ base_name = base_name.chomp(".")
146
+ trimmed_name = base_name.chomp(".") + File.extname(entry)
147
+ puts "file path: #{trimmed_name} #{entry}"
148
+ if trimmed_name != entry
149
+ new_path = File.join(rootdir, trimmed_name)
150
+ File.rename(entry_path, new_path)
151
+ entry_path = new_path
152
+ entry = trimmed_name
153
+ end
154
+ end
155
+
150
156
  counts[:files] += 1
151
157
  counts[:size] += File.size(entry_path)
152
158
  {name: entry, type: "file", path: File.join(path, entry), size: File.size(entry_path)}
@@ -162,9 +168,10 @@ module Jekyll
162
168
  elsif file[:type] == "file"
163
169
  entry_path = File.join(rootdir, file[:path])
164
170
  next if File.zero?(entry_path) || excluded_file_exts(file[:name])
165
- if file[:name].end_with?(".mdnote", ".canvas")
171
+ if file[:name].end_with?(".mdj", ".canvas")
166
172
  begin
167
173
  content = File.read(entry_path)
174
+ updated = false
168
175
  rescue Errno::ENOENT
169
176
  puts "Error reading file: #{entry_path} - No such file"
170
177
  next
@@ -174,12 +181,9 @@ module Jekyll
174
181
  end
175
182
 
176
183
  links = content.scan(/\[\[(.*?)\]\]/).flatten
177
-
178
184
  backlinks[file[:path]] ||= {"backlink_paths" => []}
179
-
180
185
  links.each do |link|
181
- lowercase_link = link.downcase
182
- matched_entry = find_matching_entry(root_files, lowercase_link)
186
+ matched_entry = find_matching_entry(root_files, link.downcase)
183
187
  if matched_entry
184
188
  unless matched_entry[:path] == file[:path] ||
185
189
  backlinks[file[:path]]["backlink_paths"].include?(matched_entry[:path])
@@ -187,14 +191,29 @@ module Jekyll
187
191
  end
188
192
  end
189
193
  end
190
- elsif !file[:name].end_with?(".mdnote", ".canvas")
191
- if embeds[file[:path]].nil? || embeds[file[:path]]["embed_paths"].nil?
192
- embeds[file[:path]] = {"embed_paths" => [entry_path]}
193
- else
194
- unless embeds[file[:path]]["embed_paths"].include?(entry_path)
195
- embeds[file[:path]]["embed_paths"] << entry_path
194
+
195
+ embeds_ = content.scan(/!\[\[(.*?)\]\]/).flatten
196
+ embeds_.each do |embed|
197
+ if /\.\./.match?(embed)
198
+ base_name = File.basename(embed, File.extname(embed)).gsub(/\.\.+/, ".")
199
+ base_name = base_name.chomp(".")
200
+ trimmed_name = base_name + File.extname(embed)
201
+ content = content.gsub("![[#{embed}]]", "![[#{trimmed_name}]]")
202
+ puts("trimmed_name #{trimmed_name} #{content}")
203
+ updated = true
196
204
  end
197
205
  end
206
+ if updated
207
+ File.write(entry_path, content)
208
+ puts "Updated file: #{entry_path}"
209
+ end
210
+
211
+ elsif embeds[file[:path]].nil? || embeds[file[:path]]["embed_paths"].nil?
212
+ embeds[file[:path]] = {"embed_paths" => [entry_path]}
213
+ else
214
+ unless embeds[file[:path]]["embed_paths"].include?(entry_path)
215
+ embeds[file[:path]]["embed_paths"] << entry_path
216
+ end
198
217
  end
199
218
  else
200
219
  puts "Skipping non-markdown file: #{file[:name]}"
@@ -209,7 +228,7 @@ module Jekyll
209
228
  if file[:type] == "dir"
210
229
  result = find_matching_entry(file[:children], lowercase_link)
211
230
  return result if result
212
- elsif file[:type] == "file" && file[:name].end_with?(".mdnote", ".canvas")
231
+ elsif file[:type] == "file" && file[:name].end_with?(".mdj", ".canvas")
213
232
  file_name_without_extension = file[:name].sub(/\.\w+$/, "").downcase
214
233
  return file if file_name_without_extension == stripped_link
215
234
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-obsidian
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Khiem Luong
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-13 00:00:00.000000000 Z
10
+ date: 2025-01-10 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: jekyll
@@ -81,7 +80,6 @@ metadata:
81
80
  homepage_uri: https://khiemgluong.github.io/blade-ballad/
82
81
  source_code_uri: https://github.com/khiemgluong/jekyll-obsidian/
83
82
  changelog_uri: https://github.com/khiemgluong/jekyll-obsidian/blob/main/CHANGELOG.md
84
- post_install_message:
85
83
  rdoc_options: []
86
84
  require_paths:
87
85
  - lib
@@ -96,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
94
  - !ruby/object:Gem::Version
97
95
  version: '0'
98
96
  requirements: []
99
- rubygems_version: 3.5.18
100
- signing_key:
97
+ rubygems_version: 3.6.2
101
98
  specification_version: 4
102
99
  summary: Obsidian integration for Jekyll
103
100
  test_files: []