Skip to content

Commit

Permalink
2️⃣ Initial support for Deta Space's Alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoder committed Oct 13, 2022
1 parent f375dc8 commit 41605e7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
static/tailwind-dev.css
node_modules
templates/testing-files.html
.space/meta
13 changes: 13 additions & 0 deletions Spacefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Spacefile Docs: https://go.deta.dev/docs/spacefile/v0
v: 0
micros:
- name: deta-vc-cms-cdn
src: .
engine: python3.9
primary: true
public_routes:
- "/file/*"
- "/api/collection/*"
- "/api/content/*"
- "/api/collections"
icon: berowra.png
Binary file added berowra.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def new():
"templateItems": finalData,
"lastUpdated": str(datetime.datetime.now(utc))
})
return redirect(f"{path}{host}/")
return redirect(f"/")
else:
return render_template('new.html')

Expand Down Expand Up @@ -166,7 +166,7 @@ def collectionAddField(id):
"type": request.form['fieldType']
})
collectionsDB.put(data)
return redirect(f"{path}{host}/collection/"+id+"/edit")
return redirect(f"/collection/"+id+"/edit")

@app.route('/collection/<id>/edit/edit-field/<field>', methods=['POST'])
def collectionEditField(id, field):
Expand All @@ -179,7 +179,7 @@ def collectionEditField(id, field):
"type": request.form['fieldType']
}
collectionsDB.put(data)
return redirect(f"{path}{host}/collection/"+id+"/edit")
return redirect(f"/collection/"+id+"/edit")

@app.route('/collection/<id>/edit/delete-field/<field>', methods=['GET'])
def collectionDeleteField(id, field):
Expand All @@ -188,19 +188,19 @@ def collectionDeleteField(id, field):
if int(templateItem['id']) == int(field):
del data['templateItems'][templateItemIndex]
collectionsDB.put(data)
return redirect(f"{path}{host}/collection/"+id+"/edit")
return redirect(f"/collection/"+id+"/edit")

@app.route('/collection/<id>/delete', methods=['GET'])
def collectionDelete(id):
collectionsDB.delete(id)
return redirect(f"{path}{host}/")
return redirect(f"/")


@app.route('/content/<id>/delete', methods=['GET'])
def contentDelete(id):
contentData = contentDB.get(id)
contentDB.delete(id)
return redirect(f"{path}{host}/collection/"+contentData['collectionKey'])
return redirect(f"/collection/"+contentData['collectionKey'])


@app.route('/content/<id>', methods=['GET', 'POST'])
Expand Down Expand Up @@ -240,7 +240,7 @@ def content(id):
contentArray = list(content.items())
contentDB.update({'content': content, 'published': published, 'title': title, 'titleCaps': title.upper(),
"lastUpdated": str(datetime.datetime.now(utc))}, id)
return redirect(f"{path}{host}/collection/{contentData['collectionKey']}")
return redirect(f"/collection/{contentData['collectionKey']}")
getContentData = contentDB.get(id)
getCollectionData = collectionsDB.get(getContentData['collectionKey'])
getContent = getContentData['content']
Expand Down Expand Up @@ -280,7 +280,7 @@ def newContent(id):
res = contentDB.insert(
{"collectionKey": id, "content": {}, "title": "Unnamed Content", "published": False, "lastUpdated": str(datetime.datetime.now(utc))})
print(res)
return redirect(f"{path}{host}/content/" + res['key'])
return redirect(f"/content/" + res['key'])


@app.route('/api/content/<id>', methods=['GET'])
Expand Down

0 comments on commit 41605e7

Please sign in to comment.