]> git.lizzy.rs Git - cheatdb.git/blob - setup.py
Add pagination and search to topics
[cheatdb.git] / setup.py
1 # Content DB
2 # Copyright (C) 2018  rubenwardy
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17
18 import os, sys, datetime
19
20 if not "FLASK_CONFIG" in os.environ:
21         os.environ["FLASK_CONFIG"] = "../config.cfg"
22
23 test_data = len(sys.argv) >= 2 and sys.argv[1].strip() == "-t"
24
25 from app.models import *
26 from app.utils import make_flask_user_password
27
28 def defineDummyData(licenses, tags, ruben):
29         ez = User("Shara")
30         ez.github_username = "Ezhh"
31         ez.forums_username = "Shara"
32         ez.rank = UserRank.EDITOR
33         db.session.add(ez)
34
35         not1 = Notification(ruben, ez, "Awards approved", "/packages/rubenwardy/awards/")
36         db.session.add(not1)
37
38         jeija = User("Jeija")
39         jeija.github_username = "Jeija"
40         jeija.forums_username = "Jeija"
41         db.session.add(jeija)
42
43
44         mod = Package()
45         mod.approved = True
46         mod.name = "alpha"
47         mod.title = "Alpha Test"
48         mod.license = licenses["MIT"]
49         mod.type = PackageType.MOD
50         mod.author = ruben
51         mod.tags.append(tags["mapgen"])
52         mod.tags.append(tags["environment"])
53         mod.repo = "https://github.com/ezhh/other_worlds"
54         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
55         mod.forums = 16015
56         mod.shortDesc = "The content library should not be used yet as it is still in alpha"
57         mod.desc = "This is the long desc"
58         db.session.add(mod)
59
60         rel = PackageRelease()
61         rel.package = mod
62         rel.title = "v1.0.0"
63         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
64         rel.approved = True
65         db.session.add(rel)
66
67         mod1 = Package()
68         mod1.approved = True
69         mod1.name = "awards"
70         mod1.title = "Awards"
71         mod1.license = licenses["LGPLv2.1"]
72         mod1.type = PackageType.MOD
73         mod1.author = ruben
74         mod1.tags.append(tags["player_effects"])
75         mod1.repo = "https://github.com/rubenwardy/awards"
76         mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
77         mod1.forums = 4870
78         mod1.shortDesc = "Adds achievements and an API to register new ones."
79         mod1.desc = """
80 Majority of awards are back ported from Calinou's old fork in Carbone, under same license.
81
82 ```
83 awards.register_achievement("award_mesefind",{
84     title = "First Mese Find",
85     description = "Found some Mese!",
86     trigger = {
87         type   = "dig",          -- award is given when
88         node   = "default:mese", -- this type of node has been dug
89         target = 1,              -- this number of times
90     },
91 })
92 ```
93 """
94
95         rel = PackageRelease()
96         rel.package = mod1
97         rel.title = "v1.0.0"
98         rel.url = "https://github.com/rubenwardy/awards/archive/master.zip"
99         rel.approved = True
100         db.session.add(rel)
101
102         mod2 = Package()
103         mod2.approved = True
104         mod2.name = "mesecons"
105         mod2.title = "Mesecons"
106         mod2.tags.append(tags["tools"])
107         mod2.type = PackageType.MOD
108         mod2.license = licenses["LGPLv3"]
109         mod2.author = jeija
110         mod2.repo = "https://github.com/minetest-mods/mesecons/"
111         mod2.issueTracker = "https://github.com/minetest-mods/mesecons/issues"
112         mod2.forums = 628
113         mod2.shortDesc = "Mesecons adds everything digital, from all kinds of sensors, switches, solar panels, detectors, pistons, lamps, sound blocks to advanced digital circuitry like logic gates and programmable blocks."
114         mod2.desc = """
115     ########################################################################
116     ##  __    __   _____   _____   _____   _____   _____   _   _   _____  ##
117     ## |  \  /  | |  ___| |  ___| |  ___| |  ___| |  _  | | \ | | |  ___| ##
118     ## |   \/   | | |___  | |___  | |___  | |     | | | | |  \| | | |___  ##
119     ## | |\__/| | |  ___| |___  | |  ___| | |     | | | | |     | |___  | ##
120     ## | |    | | | |___   ___| | | |___  | |___  | |_| | | |\  |  ___| | ##
121     ## |_|    |_| |_____| |_____| |_____| |_____| |_____| |_| \_| |_____| ##
122     ##                                                                    ##
123     ########################################################################
124
125 MESECONS by Jeija and contributors
126
127 Mezzee-what?
128 ------------
129 [Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
130
131 Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
132
133 Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
134
135 OK, I want in.
136 --------------
137 Go get it!
138
139 [DOWNLOAD IT NOW](https://github.com/minetest-mods/mesecons/archive/master.zip)
140
141 Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
142
143 1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
144 2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
145 3. Open up the Minetest mods folder - usually `/mods/`. If you see the `minetest` or folder inside of that, that is your mod folder instead.
146 4. Copy the Mesecons folder into the mods folder.
147
148 Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.
149
150 There are no dependencies - it will work right after installing!
151
152 How do I use this thing?
153 ------------------------
154 How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
155
156 Or maybe a [comprehensive reference](http://mesecons.net/items.html) is your style?
157
158 An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
159
160 Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
161
162 Want to contribute to Mesecons itself? Check out the [source code](https://github.com/minetest-mods/mesecons)!
163
164 Who wrote it anyways?
165 ---------------------
166 These awesome people made Mesecons possible!
167
168 | Contributor     | Contribution                     |
169 | --------------- | -------------------------------- |
170 | Hawk777         | Code for VoxelManip caching      |
171 | Jat15           | Various tweaks.                  |
172 | Jeija           | **Main developer! Everything.**  |
173 | Jordach         | Noteblock sounds.                |
174 | khonkhortistan  | Code, recipes, textures.         |
175 | Kotolegokot     | Nodeboxes for items.             |
176 | minerd247       | Textures.                        |
177 | Nore/Novatux    | Code.                            |
178 | RealBadAngel    | Fixes, improvements.             |
179 | sfan5           | Code, recipes, textures.         |
180 | suzenako        | Piston sounds.                   |
181 | Uberi/Temperest | Code, textures, documentation.   |
182 | VanessaE        | Code, recipes, textures, design. |
183 | Whiskers75      | Logic gates implementation.      |
184
185 There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
186
187 Alright, how can I use it?
188 --------------------------
189 All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
190
191 All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
192
193 No warranty is provided, express or implied, for any part of the project.
194
195 """
196
197         db.session.add(mod1)
198         db.session.add(mod2)
199
200         mod = Package()
201         mod.approved = True
202         mod.name = "handholds"
203         mod.title = "Handholds"
204         mod.license = licenses["MIT"]
205         mod.type = PackageType.MOD
206         mod.author = ez
207         mod.tags.append(tags["player_effects"])
208         mod.repo = "https://github.com/ezhh/handholds"
209         mod.issueTracker = "https://github.com/ezhh/handholds/issues"
210         mod.forums = 17069
211         mod.shortDesc = "Adds hand holds and climbing thingies"
212         mod.desc = "This is the long desc"
213         db.session.add(mod)
214
215         rel = PackageRelease()
216         rel.package = mod
217         rel.title = "v1.0.0"
218         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
219         rel.approved = True
220         db.session.add(rel)
221
222         mod = Package()
223         mod.approved = True
224         mod.name = "other_worlds"
225         mod.title = "Other Worlds"
226         mod.license = licenses["MIT"]
227         mod.type = PackageType.MOD
228         mod.author = ez
229         mod.tags.append(tags["mapgen"])
230         mod.tags.append(tags["environment"])
231         mod.repo = "https://github.com/ezhh/other_worlds"
232         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
233         mod.forums = 16015
234         mod.shortDesc = "Adds space with asteroids and comets"
235         mod.desc = "This is the long desc"
236         db.session.add(mod)
237
238         mod = Package()
239         mod.approved = True
240         mod.name = "food"
241         mod.title = "Food"
242         mod.license = licenses["LGPLv2.1"]
243         mod.type = PackageType.MOD
244         mod.author = ruben
245         mod.tags.append(tags["player_effects"])
246         mod.repo = "https://github.com/rubenwardy/food/"
247         mod.issueTracker = "https://github.com/rubenwardy/food/issues/"
248         mod.forums = 2960
249         mod.shortDesc = "Adds lots of food and an API to manage ingredients"
250         mod.desc = "This is the long desc"
251         food = mod
252         db.session.add(mod)
253
254         mod = Package()
255         mod.approved = True
256         mod.name = "food_sweet"
257         mod.title = "Sweet Foods"
258         mod.license = licenses["CC0"]
259         mod.type = PackageType.MOD
260         mod.author = ruben
261         mod.tags.append(tags["player_effects"])
262         mod.repo = "https://github.com/rubenwardy/food_sweet/"
263         mod.issueTracker = "https://github.com/rubenwardy/food_sweet/issues/"
264         mod.forums = 9039
265         mod.shortDesc = "Adds sweet food"
266         mod.desc = "This is the long desc"
267         food_sweet = mod
268         db.session.add(mod)
269
270         game1 = Package()
271         game1.approved = True
272         game1.name = "capturetheflag"
273         game1.title = "Capture The Flag"
274         game1.type = PackageType.GAME
275         game1.license = licenses["LGPLv2.1"]
276         game1.author = ruben
277         game1.tags.append(tags["pvp"])
278         game1.tags.append(tags["survival"])
279         game1.tags.append(tags["multiplayer"])
280         game1.repo = "https://github.com/rubenwardy/capturetheflag"
281         game1.issueTracker = "https://github.com/rubenwardy/capturetheflag/issues"
282         game1.forums = 12835
283         game1.shortDesc = "Two teams battle to snatch and return the enemy's flag, before the enemy takes their own!"
284         game1.desc = """
285 As seen on the Capture the Flag server (minetest.rubenwardy.com:30000)
286
287 Uses the CTF PvP Engine.
288 """
289
290         db.session.add(game1)
291
292         rel = PackageRelease()
293         rel.package = game1
294         rel.title = "v1.0.0"
295         rel.url = "https://github.com/rubenwardy/capturetheflag/archive/master.zip"
296         rel.approved = True
297         db.session.add(rel)
298
299
300         mod = Package()
301         mod.approved = True
302         mod.name = "pixelbox"
303         mod.title = "PixelBOX Reloaded"
304         mod.license = licenses["CC0"]
305         mod.type = PackageType.TXP
306         mod.author = ruben
307         mod.forums = 14132
308         mod.shortDesc = "This is an update of the original PixelBOX texture pack by the brillant artist Gambit"
309         mod.desc = "This is the long desc"
310         db.session.add(mod)
311
312         rel = PackageRelease()
313         rel.package = mod
314         rel.title = "v1.0.0"
315         rel.url = "http://mamadou3.free.fr/Minetest/PixelBOX.zip"
316         rel.approved = True
317         db.session.add(rel)
318
319         db.session.commit()
320
321         metas = {}
322         for package in Package.query.filter_by(type=PackageType.MOD).all():
323                 meta = None
324                 try:
325                         meta = metas[package.name]
326                 except KeyError:
327                         meta = MetaPackage(package.name)
328                         db.session.add(meta)
329                         metas[package.name] = meta
330                 package.provides.append(meta)
331
332         dep = Dependency(food_sweet, meta=metas["food"])
333         db.session.add(dep)
334
335
336
337 delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
338 if delete_db and os.path.isfile("db.sqlite"):
339         os.remove("db.sqlite")
340
341 print("Creating database tables...")
342 db.create_all()
343 print("Filling database...")
344
345 ruben = User("rubenwardy")
346 ruben.active = True
347 ruben.password = make_flask_user_password("tuckfrump")
348 ruben.github_username = "rubenwardy"
349 ruben.forums_username = "rubenwardy"
350 ruben.rank = UserRank.ADMIN
351 db.session.add(ruben)
352
353 tags = {}
354 for tag in ["Inventory", "Mapgen", "Building", \
355                 "Mobs and NPCs", "Tools", "Player effects", \
356                 "Environment", "Transport", "Maintenance", "Plants and farming", \
357                 "PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer"]:
358         row = Tag(tag)
359         tags[row.name] = row
360         db.session.add(row)
361
362 licenses = {}
363 for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
364                                 "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
365                                 "CC-BY", "MIT", "ZLib", "Other (Free)"]:
366         row = License(license)
367         licenses[row.name] = row
368         db.session.add(row)
369
370 for license in ["CC-BY-NC-SA", "Other (Non-free)"]:
371         row = License(license, False)
372         licenses[row.name] = row
373         db.session.add(row)
374
375 if test_data:
376         defineDummyData(licenses, tags, ruben)
377
378 db.session.commit()