summaryrefslogtreecommitdiff
path: root/lib/ccc_conventions.rb
blob: 52549c9e5d8ef7b6182aaabae1815bdea0a2a0f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module CccConventions
  TRASH_SLUG              = "trash"
  ERFA_PARENT_NAME        = "club/erfas"
  CHAOSTREFF_PARENT_NAME  = "club/chaostreffs"
  SITEMAP_COLLAPSED_PATHS = %w[updates club/erfas club/chaostreffs disclosure].freeze
  RESTRICTED_SUBTREES     = %w[updates disclosure].freeze

  NODE_KINDS = {
    "top_level" => {
      parent:       -> { Node.root },
      parent_match: ->(path) { path == [] },
      path_prefix:  "",
      label:        "Top Level"
    },
    "generic" => {
      parent_match: ->(path) { true },
      label:        "Generic",
      hint:         "Can be created anywhere - choose the parent below."
    },
    "update" => {
      parent:       -> { Update.find_or_create_parent },
      parent_match: ->(path) { path[0] == "updates" && (path.length == 1 || path[1] =~ /\A\d{4}\z/) },
      tags:         ["update"],
      path_prefix:  -> { "updates/#{Time.now.year}" },
      label:        "Update",
      hint:         -> { "Automatically created in /updates/#{Time.now.year}/, gets tag \"update\", and inherits the update template." }
    },
    "press_release" => {
      parent:       -> { Update.find_or_create_parent },
      parent_match: ->(path) { path[0] == "updates" && (path.length == 1 || path[1] =~ /\A\d{4}\z/) },
      tags:         ["update", "pressemitteilung"],
      path_prefix:  -> { "updates/#{Time.now.year}" },
      label:        "Pressemitteilung",
      hint:         -> { "Automatically created in /updates/#{Time.now.year}/, gets tags \"update, pressemitteilung\", and inherits the update template." }
    },
    "erfa" => {
      parent:       -> { Node.find_by_unique_name!(ERFA_PARENT_NAME) },
      parent_match: ->(path) { path == ["club", "erfas"] },
      tags:         ["erfa-detail"],
      template:     "chapter_detail",
      path_prefix:  ERFA_PARENT_NAME,
      label:        "Erfa",
      hint:         "Automatically created under the Erfa-Kreise overview page, gets tag \"erfa-detail\", and uses the chapter detail template."
    },
    "chaostreff" => {
      parent:       -> { Node.find_by_unique_name!(CHAOSTREFF_PARENT_NAME) },
      parent_match: ->(path) { path == ["club", "chaostreffs"] },
      tags:         ["chaostreff-detail"],
      template:     "chapter_detail",
      path_prefix:  CHAOSTREFF_PARENT_NAME,
      label:        "Chaostreff",
      hint:         "Automatically created under the Chaostreffs overview page, gets tag \"chaostreff-detail\", and uses the chapter detail template."
    }
  }.freeze

  # Tags whose aggregates are forced into a subtree. Editors may apply any
  # tag anywhere, but a page tagged "update" outside /updates will never
  # appear in the front-page widget or the RSS feed, because every aggregate
  # over that tag is scoped here rather than in the shortcode.
  TAG_SCOPES = {
    "update"           => "updates",
    "pressemitteilung" => "updates",
    "disclosure"       => "disclosure"
  }.freeze
end