summaryrefslogtreecommitdiff
path: root/index.js
blob: 5b40c83b9b7510018b723e10faa6427f319b7bef (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import okcms from "okcms";
import path from "path";

const __dirname = path.resolve();

var isProduction = process.env.OK_PRODUCTION === "true";

// Charles' types from the spreadsheet
var tagTypes = [
  "(none)",
  "No6092",
  "1620s",
  "painting",
  "blunt",
  "National Gallery of Canada",
  "AGO",
  "courtauld",
  "intervensions",
  "connosieurship",
  "double agent",
  "forensics",
  "black box",
].map((type, index) => [index, type]);

var app = okcms
  .createApp({
    project: "No. 6092",

    debug: !isProduction,
    production: isProduction,

    admin: {
      dashboard: {
        resources: {},
      },
    },

    schemas: {
      page: {
        id: { type: "string", hidden: true },
        title: { type: "string" },
        author: { type: "string" },
        description: { type: "text" },
        thumbnail: { type: "image" },
        images: { type: "gallery" },
        tag_0: { type: "enum", options: tagTypes, alias: "Tag #1" },
        tag_1: { type: "enum", options: tagTypes, alias: "Tag #2" },
        tag_2: { type: "enum", options: tagTypes, alias: "Tag #3" },
        tag_3: { type: "enum", options: tagTypes, alias: "Tag #4" },
        tag_4: { type: "enum", options: tagTypes, alias: "Tag #5" },
        tag_5: { type: "enum", options: tagTypes, alias: "Tag #6" },
        tag_6: { type: "enum", options: tagTypes, alias: "Tag #7" },
        tag_7: { type: "enum", options: tagTypes, alias: "Tag #8" },
        tag_8: { type: "enum", options: tagTypes, alias: "Tag #9" },
        hidden: { type: "flag" },
      },
      ui: {
        id: { type: "string", hidden: true },
        title: { type: "string" },
        body: { type: "text" },
        hidden: { type: "flag" },
      },
    },

    resources: [{ type: "page" }, { type: "ui" }],

    views: {
      "/": {
        template: "home",
        data: [
          { type: "page", query: "*" },
          { type: "ui", query: "*" },
        ],
      },
    },

    services: {
      s3: {
        // key: process.env.S3_KEY,
        // secret: process.env.S3_SECRET,
        // bucket: process.env.S3_BUCKET,
        // dirname: "km",
        local: {
          localPath: path.join(__dirname, "./public/assets/uploads/"),
          remotePath: "/assets/uploads/",
        },
        image: {
          allowed: true,
          preserveFilename: false,
          maxbytes: 2 * 1024 * 1024,
        },
        file: {
          allowed: true,
          preserveFilename: true,
          maxbytes: 100 * 1024 * 1024,
        },
        video: {
          allowed: true,
          preserveFilename: true,
          maxbytes: 200 * 1024 * 1024,
        },
        audio: {
          allowed: true,
          preserveFilename: true,
          maxbytes: 100 * 1024 * 1024,
        },
      },
    },
  })
  .listen(process.env.PORT || 3000);

console.log("Server listening at port " + (process.env.PORT || 3000) + "...");