v / examples / templates
Raw file | 210 loc (202 sloc) | 6.19 KB | Latest commit hash 108a01d65
1module main
2
3import os
4import json
5
6pub struct SiteConfig {
7pub mut:
8 name string
9 url string
10 branch string = 'default' // means is the default branch
11 pull bool
12 cat SiteCat
13 alias string
14 path_code string
15 domains []string
16 descr string
17}
18
19pub enum SiteCat {
20 wiki
21 data
22 web
23}
24
25fn data_get() []SiteConfig {
26 data := [
27 SiteConfig{
28 name: 'www_threefold_io'
29 url: 'https://github.com/threefoldfoundation/www_threefold_io'
30 branch: 'default'
31 pull: false
32 cat: .web
33 alias: 'tf'
34 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_io'
35 domains: ['www.threefold.io', 'www.threefold.me']
36 descr: 'is our entry point for everyone, redirect to the detailed websites underneath.'
37 },
38 SiteConfig{
39 name: 'www_threefold_cloud'
40 url: 'https://github.com/threefoldfoundation/www_threefold_cloud'
41 branch: 'default'
42 pull: false
43 cat: .web
44 alias: 'cloud'
45 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_cloud'
46 domains: ['cloud.threefold.io', 'cloud.threefold.me']
47 descr: 'for people looking to deploy solutions on top of a cloud, alternative to e.g. digital ocean'
48 },
49 SiteConfig{
50 name: 'www_threefold_farming'
51 url: 'https://github.com/threefoldfoundation/www_threefold_farming'
52 branch: 'default'
53 pull: false
54 cat: .web
55 alias: 'farming'
56 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_farming'
57 domains: ['farming.threefold.io', 'farming.threefold.me']
58 descr: 'crypto & minining enthusiasts, be the internet, know about farming & tokens.'
59 },
60 SiteConfig{
61 name: 'www_threefold_twin'
62 url: 'https://github.com/threefoldfoundation/www_threefold_twin'
63 branch: 'default'
64 pull: false
65 cat: .web
66 alias: 'twin'
67 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_twin'
68 domains: ['twin.threefold.io', 'twin.threefold.me']
69 descr: 'you digital life'
70 },
71 SiteConfig{
72 name: 'www_threefold_marketplace'
73 url: 'https://github.com/threefoldfoundation/www_threefold_marketplace'
74 branch: 'default'
75 pull: false
76 cat: .web
77 alias: 'marketplace'
78 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_threefold_marketplace'
79 domains: ['now.threefold.io', 'marketplace.threefold.io', 'now.threefold.me',
80 'marketplace.threefold.me']
81 descr: 'apps for community builders, runs on top of evdc'
82 },
83 SiteConfig{
84 name: 'www_conscious_internet'
85 url: 'https://github.com/threefoldfoundation/www_conscious_internet'
86 branch: 'default'
87 pull: false
88 cat: .web
89 alias: 'conscious_internet'
90 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_conscious_internet'
91 domains: ['www.consciousinternet.org', 'eco.threefold.io', 'community.threefold.io',
92 'eco.threefold.me', 'community.threefold.me']
93 descr: 'community around threefold, partners, friends, ...'
94 },
95 SiteConfig{
96 name: 'www_threefold_tech'
97 url: 'https://github.com/threefoldtech/www_threefold_tech'
98 branch: 'default'
99 pull: false
100 cat: .web
101 alias: 'tech'
102 path_code: '/Users/despiegk/codewww/github/threefoldtech/www_threefold_tech'
103 domains: ['www.threefold.tech']
104 descr: 'cyberpandemic, use the tech to build your own solutions with, certification for TFGrid'
105 },
106 SiteConfig{
107 name: 'www_examplesite'
108 url: 'https://github.com/threefoldfoundation/www_examplesite'
109 branch: 'default'
110 pull: false
111 cat: .web
112 alias: 'example'
113 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/www_examplesite'
114 domains: ['example.threefold.io']
115 descr: ''
116 },
117 SiteConfig{
118 name: 'info_threefold'
119 url: 'https://github.com/threefoldfoundation/info_foundation_archive'
120 branch: 'default'
121 pull: false
122 cat: .wiki
123 alias: 'threefold'
124 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_foundation_archive'
125 domains: ['info.threefold.io']
126 descr: 'wiki for foundation, collaborate, what if farmings, tokens'
127 },
128 SiteConfig{
129 name: 'info_sdk'
130 url: 'https://github.com/threefoldfoundation/info_sdk'
131 branch: 'default'
132 pull: false
133 cat: .wiki
134 alias: 'sdk'
135 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_sdk'
136 domains: ['sdk.threefold.io', 'sdk_info.threefold.io']
137 descr: 'for IAC, devops, how to do Infrastructure As Code, 3bot, Ansible, tfgrid-sdk, ...'
138 },
139 SiteConfig{
140 name: 'info_legal'
141 url: 'https://github.com/threefoldfoundation/info_legal'
142 branch: 'default'
143 pull: false
144 cat: .wiki
145 alias: 'legal'
146 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_legal'
147 domains: ['legal.threefold.io', 'legal_info.threefold.io']
148 descr: ''
149 },
150 SiteConfig{
151 name: 'info_cloud'
152 url: 'https://github.com/threefoldfoundation/info_cloud'
153 branch: 'default'
154 pull: false
155 cat: .wiki
156 alias: 'cloud'
157 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_cloud'
158 domains: ['cloud_info.threefold.io']
159 descr: 'how to use the cloud for deploying apps: evdc, kubernetes, planetary fs, ... + marketplace solutions '
160 },
161 SiteConfig{
162 name: 'info_tftech'
163 url: 'https://github.com/threefoldtech/info_tftech'
164 branch: 'default'
165 pull: false
166 cat: .wiki
167 alias: 'tftech'
168 path_code: '/Users/despiegk/codewww/github/threefoldtech/info_tftech'
169 domains: ['info.threefold.tech']
170 descr: ''
171 },
172 SiteConfig{
173 name: 'info_digitaltwin'
174 url: 'https://github.com/threefoldfoundation/info_digitaltwin.git'
175 branch: 'default'
176 pull: false
177 cat: .wiki
178 alias: 'twin'
179 path_code: '/Users/despiegk/codewww/github/threefoldfoundation/info_digitaltwin'
180 domains: ['twin_info.threefold.io']
181 descr: ''
182 },
183 ]
184 return data
185}
186
187fn data_dump(data []SiteConfig) {
188 a := json.encode_pretty(data)
189 os.write_file(os.resource_abs_path('data.json'), a) or { panic(err) }
190}
191
192fn data_load() []SiteConfig {
193 data := os.read_file(os.resource_abs_path('data.json')) or { panic(err) }
194 a := json.decode([]SiteConfig, data) or { panic(err) }
195 return a
196}
197
198fn filled_in_template() string {
199 port_str := '80'
200 sites := data_load()
201 return $tmpl('template.md')
202}
203
204fn main() {
205 // A NICE test how to work with the json module
206 // data := data_get()
207 // data_dump(data)
208 b := filled_in_template()
209 println(b)
210}