« get me outta code hell

listRandomPageLinks.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/listRandomPageLinks.js
blob: 43bf7dd550975c86730a1bca5b493a4aa76cabcb (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
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
export default {
  contentDependencies: [
    'generateListingPage',
    'generateListRandomPageLinksGroupSection',
  ],

  extraDependencies: ['html', 'language', 'wikiData'],

  sprawl({groupData}) {
    return {groupData};
  },

  query(sprawl, spec) {
    const group = directory =>
      sprawl.groupData.find(group => group.directory === directory);

    return {
      spec,
      officialGroup: group('official'),
      fandomGroup: group('fandom'),
      beyondGroup: group('beyond'),
    };
  },

  relations(relation, query) {
    return {
      page: relation('generateListingPage', query.spec),

      officialSection:
        relation('generateListRandomPageLinksGroupSection', query.officialGroup),

      fandomSection:
        relation('generateListRandomPageLinksGroupSection', query.fandomGroup),

      beyondSection:
        relation('generateListRandomPageLinksGroupSection', query.beyondGroup),
    };
  },

  generate(relations, {html, language}) {
    return relations.page.slots({
      type: 'custom',
      content: [
        html.tag('p',
          language.$('listingPage.other.randomPages.chooseLinkLine')),

        html.tag('p',
          {class: 'js-hide-once-data'},
          language.$('listingPage.other.randomPages.dataLoadingLine')),

        html.tag('p',
          {class: 'js-show-once-data'},
          language.$('listingPage.other.randomPages.dataLoadedLine')),

        html.tag('dl', [
          html.tag('dt',
            language.$('listingPage.other.randomPages.misc')),

          html.tag('dd',
            html.tag('ul', [
              html.tag('li', [
                html.tag('a',
                  {href: '#', 'data-random': 'artist'},
                  language.$('listingPage.other.randomPages.misc.randomArtist')),

                '(' +
                html.tag('a',
                  {href: '#', 'data-random': 'artist-more-than-one-contrib'},
                  language.$('listingPage.other.randomPages.misc.atLeastTwoContributions')) +
                ')',
              ]),

              html.tag('li',
                html.tag('a',
                  {href: '#', 'data-random': 'album'},
                  language.$('listingPage.other.randomPages.misc.randomAlbumWholeSite'))),

              html.tag('li',
                html.tag('a',
                  {href: '#', 'data-random': 'track'},
                  language.$('listingPage.other.randomPages.misc.randomTrackWholeSite'))),
            ])),

          relations.officialSection,
          relations.fandomSection,
          relations.beyondSection,
        ]),
      ],
    });
  },
};