markdown_extension 0.0.5 → 0.0.6

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: 82d7c32cfae2b681bc6f6e6d38748fb70d5d3d51ca9766d3847e713fc088d4d2
4
- data.tar.gz: 5e7e661e48acc68946c3a17c1c0e7d32191d2ec3af35b7f26f67589447c6bd8a
3
+ metadata.gz: 3ddb3ebd46cfa75b4a02431c3f695df13cf45fac0dae5d30b0d7f710c3bbfcf1
4
+ data.tar.gz: 22bc0feb032ec88c5c83c053c0da28397d7b4fa2cd0bf7e030b6659dcf83cfff
5
5
  SHA512:
6
- metadata.gz: 11ba5ee235ad603da4f65aa44d39b2f5c481ead42854a6f06c03ccc7d15d4cbfebba648d10b0568c28c8dc386a080115635d287c03b174ad315c06bcec369c1f
7
- data.tar.gz: d347742662afa0826627bbab26fa3d50cda4656a3b021f2d7ffd8d9e9d2264879538f9935f4621a0a00940a99b2e35df253ac0b29738289cfb1b4c710416bd3d
6
+ metadata.gz: 5e0322c6afe27efdfdfbf5fd921b8c7896e400809e5b61bcff609ce9881e5d120adec2dcba648f3aa50c97a3411cb67d672f75c0ba05b20162f94c077e4041e4
7
+ data.tar.gz: 76c998a06980e6ec32d40819e94323d925fb812a5462660e55999d3d4e7fe1ba413d33e8f6c4564902a053b906ca9393461dab6b70301f4efb005203ec2a9ee4
@@ -4,7 +4,7 @@ module MarkdownExtension
4
4
  class Config
5
5
  attr_accessor :raw_config, :file, :type
6
6
 
7
- def load_file(file, type)
7
+ def load_file(file)
8
8
  @raw_config = begin
9
9
  Tomlrb.load_file(file)
10
10
  rescue
@@ -15,26 +15,33 @@ module MarkdownExtension
15
15
  def initialize(file, type)
16
16
  @file = file
17
17
  @type = type
18
- load_file(file , type)
18
+ load_file(file)
19
19
  return self
20
20
  end
21
21
 
22
- def title
22
+ def get_base_info(name)
23
23
  if @raw_config
24
24
  if @raw_config[@type.to_s]
25
- return @raw_config[@type.to_s]["title"]
25
+ return @raw_config[@type.to_s][name]
26
26
  end
27
27
  end
28
28
  ""
29
29
  end
30
30
 
31
+ def title
32
+ get_base_info("title")
33
+ end
34
+
31
35
  def src
32
- if @raw_config
33
- if @raw_config[@type.to_s]
34
- return @raw_config[@type.to_s]["src"]
35
- end
36
- end
37
- ""
36
+ get_base_info("src")
37
+ end
38
+
39
+ def pages
40
+ get_base_info("pages")
41
+ end
42
+
43
+ def journals
44
+ get_base_info("journals")
38
45
  end
39
46
 
40
47
  def preprocessing
@@ -4,9 +4,10 @@ require "tomlrb"
4
4
 
5
5
  module MarkdownExtension
6
6
  class Page
7
- attr_accessor :site, :markdown, :meta, :item_name
7
+ attr_accessor :site, :markdown, :meta, :item_name, :title
8
8
 
9
9
  def initialize(file, site)
10
+ @title = file.split("/")[-1].gsub(".md","")
10
11
  @site = site
11
12
  if File.exists?(file)
12
13
  @markdown = File.read(file)
@@ -2,12 +2,14 @@ require "json"
2
2
 
3
3
  module MarkdownExtension
4
4
  class Site
5
- attr_accessor :config, :summary, :pages, :references, :reverse_references
5
+ attr_accessor :config, :summary, :pages, :journals, :references, :reverse_references
6
6
  attr_accessor :nodes, :links
7
7
 
8
8
  def initialize(config, type)
9
9
  @config = MarkdownExtension::Config.new(config, type)
10
- @summary = MarkdownExtension::Summary.new(@config)
10
+ unless type == :logseq
11
+ @summary = MarkdownExtension::Summary.new(@config)
12
+ end
11
13
  @references = {}
12
14
  @reverse_references = {}
13
15
  @nodes = []
@@ -18,12 +20,23 @@ module MarkdownExtension
18
20
 
19
21
  def load_source_files
20
22
  @pages = []
23
+ @journals = []
21
24
  if @config
22
- files = Dir.glob(@config.src + "/*.md")
25
+ if @config.type == :logseq
26
+ journal_files = Dir.glob(@config.journals + "/*.md")
27
+ journal_files.each do |file|
28
+ page = MarkdownExtension::Page.new(file, self)
29
+ @journals << page
30
+ end
31
+ pages_path = @config.pages
32
+ else
33
+ pages_path = @config.src
34
+ end
35
+ files = Dir.glob(pages_path + "/*.md")
23
36
  files.each do |file|
24
- unless file == @config.src + "/summary.md"
37
+ unless file == @config.pages + "/summary.md"
25
38
  page = MarkdownExtension::Page.new(file, self)
26
- pages << page
39
+ @pages << page
27
40
  gen_references(file , page.markdown)
28
41
  end
29
42
  end
@@ -1,3 +1,3 @@
1
1
  module MarkdownExtension
2
- Version = '0.0.5'
2
+ Version = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhuang Biaowei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-29 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb