Module: Woods::Obsidian::VaultAssets
- Defined in:
- lib/woods/obsidian/vault_assets.rb
Overview
Generates the static-ish vault configuration files: the .obsidian/
settings Obsidian reads (app.json, types.json, graph.json) and the
Units.base Obsidian Bases view.
Grounded in Steph Ango's published vault conventions and the official Obsidian docs:
app.jsononly governs links Obsidian generates; our authored[[path|alias]]links resolve regardless. We still set absolute-path wikilinks as a courtesy for the user's future edits.- We deliberately do NOT ship
core-plugins.json— graph and Bases are enabled by default, and a partial plugin list could disable other defaults. types.jsontypes the properties so Bases columns sort numerically (pagerank/counts) and tags render as tags.graph.jsoncolor groups apply to the global graph only (local-graph colors live in volatile workspace.json, which must not be shipped).
Constant Summary collapse
- PALETTE =
Palette of 24-bit RGB ints assigned to type tags in sorted order so the graph coloring is deterministic across runs.
[ 0xE5_5A_5A, 0x5A_9B_E5, 0x5A_E5_8B, 0xE5_C8_5A, 0xB4_5A_E5, 0x5A_E5_D6, 0xE5_8B_5A, 0x8B_E5_5A, 0xE5_5A_B4, 0x5A_6B_E5 ].freeze
- PROPERTY_TYPES =
{ 'id' => 'text', 'type' => 'text', 'file' => 'text', 'source_hash' => 'text', 'pagerank' => 'number', 'dependency_count' => 'number', 'dependent_count' => 'number', 'tags' => 'tags', 'aliases' => 'aliases' }.freeze
Class Method Summary collapse
-
.app_json ⇒ String
.obsidian/app.json.
-
.graph_json(types) ⇒ String
.obsidian/graph.json with per-type color groups.
- .pretty(hash) ⇒ Object
-
.types_json ⇒ String
.obsidian/types.json (property -> type registry).
-
.units_base ⇒ String
Units.base — an Obsidian Bases view (YAML).
Class Method Details
.app_json ⇒ String
Returns .obsidian/app.json.
40 41 42 43 44 45 46 |
# File 'lib/woods/obsidian/vault_assets.rb', line 40 def app_json pretty( 'newLinkFormat' => 'absolute', 'useMarkdownLinks' => false, 'alwaysUpdateLinks' => true ) end |
.graph_json(types) ⇒ String
Returns .obsidian/graph.json with per-type color groups.
55 56 57 58 59 60 |
# File 'lib/woods/obsidian/vault_assets.rb', line 55 def graph_json(types) groups = Array(types).uniq.sort.each_with_index.map do |type, i| { 'query' => "tag:#woods/#{type}", 'color' => { 'a' => 1, 'rgb' => PALETTE[i % PALETTE.size] } } end pretty('colorGroups' => groups, 'showTags' => true, 'showAttachments' => false) end |
.pretty(hash) ⇒ Object
99 100 101 |
# File 'lib/woods/obsidian/vault_assets.rb', line 99 def pretty(hash) "#{JSON.pretty_generate(hash)}\n" end |
.types_json ⇒ String
Returns .obsidian/types.json (property -> type registry).
49 50 51 |
# File 'lib/woods/obsidian/vault_assets.rb', line 49 def types_json pretty('types' => PROPERTY_TYPES) end |
.units_base ⇒ String
Returns Units.base — an Obsidian Bases view (YAML).
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/woods/obsidian/vault_assets.rb', line 63 def units_base <<~YAML filters: and: - 'file.hasTag("woods/unit")' properties: type: displayName: Type pagerank: displayName: PageRank dependent_count: displayName: Used by dependency_count: displayName: Depends on views: - type: table name: All units groupBy: type order: - file.name - type - pagerank - dependent_count - dependency_count - type: table name: Hubs filters: and: - 'file.hasTag("woods/hub")' order: - file.name - dependent_count - pagerank YAML end |