New name.
This commit is contained in:
parent
2960bbfd61
commit
c5464fe992
24
main.py
24
main.py
@ -24,7 +24,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Database setup
|
# Database setup
|
||||||
DB_PATH = "devrant_community.db"
|
DB_PATH = "rant_community.db"
|
||||||
UPLOAD_DIR = Path("uploads")
|
UPLOAD_DIR = Path("uploads")
|
||||||
UPLOAD_DIR.mkdir(exist_ok=True)
|
UPLOAD_DIR.mkdir(exist_ok=True)
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ async def login(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.get("/api/devrant/rants")
|
@app.get("/api/rant/rants")
|
||||||
async def get_rants(
|
async def get_rants(
|
||||||
sort: str = "recent",
|
sort: str = "recent",
|
||||||
limit: int = 20,
|
limit: int = 20,
|
||||||
@ -384,7 +384,7 @@ async def get_rants(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.get("/api/devrant/rants/{rant_id}")
|
@app.get("/api/rant/rants/{rant_id}")
|
||||||
async def get_rant(
|
async def get_rant(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
app: int = 3,
|
app: int = 3,
|
||||||
@ -474,7 +474,7 @@ async def get_rant(
|
|||||||
"subscribed": subscribed
|
"subscribed": subscribed
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.post("/api/devrant/rants")
|
@app.post("/api/rant/rants")
|
||||||
async def create_rant(
|
async def create_rant(
|
||||||
rant: str = Form(...),
|
rant: str = Form(...),
|
||||||
tags: str = Form(...),
|
tags: str = Form(...),
|
||||||
@ -499,7 +499,7 @@ async def create_rant(
|
|||||||
if duplicate:
|
if duplicate:
|
||||||
return {
|
return {
|
||||||
"success": False,
|
"success": False,
|
||||||
"error": "It looks like you just posted this same rant! Your connection might have timed out while posting so you might have seen an error, but sometimes the rant still gets posted and in this case it seems it did, so please check :) If this was not the case please contact info@devrant.io. Thanks!"
|
"error": "It looks like you just posted this same rant! Your connection might have timed out while posting so you might have seen an error, but sometimes the rant still gets posted and in this case it seems it did, so please check :) If this was not the case please contact info@rant.io. Thanks!"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle image upload
|
# Handle image upload
|
||||||
@ -529,7 +529,7 @@ async def create_rant(
|
|||||||
|
|
||||||
return {"success": True, "rant_id": rant_id}
|
return {"success": True, "rant_id": rant_id}
|
||||||
|
|
||||||
@app.post("/api/devrant/rants/{rant_id}")
|
@app.post("/api/rant/rants/{rant_id}")
|
||||||
async def update_rant(
|
async def update_rant(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
rant: str = Form(...),
|
rant: str = Form(...),
|
||||||
@ -560,7 +560,7 @@ async def update_rant(
|
|||||||
|
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
|
|
||||||
@app.delete("/api/devrant/rants/{rant_id}")
|
@app.delete("/api/rant/rants/{rant_id}")
|
||||||
async def delete_rant(
|
async def delete_rant(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
app: int = 3,
|
app: int = 3,
|
||||||
@ -589,7 +589,7 @@ async def delete_rant(
|
|||||||
|
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
|
|
||||||
@app.post("/api/devrant/rants/{rant_id}/vote")
|
@app.post("/api/rant/rants/{rant_id}/vote")
|
||||||
async def vote_rant(
|
async def vote_rant(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
vote: int = Form(...),
|
vote: int = Form(...),
|
||||||
@ -688,7 +688,7 @@ async def vote_rant(
|
|||||||
"rant": await format_rant(rant_data, user_data, current_user_id)
|
"rant": await format_rant(rant_data, user_data, current_user_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@app.post("/api/devrant/rants/{rant_id}/favorite")
|
@app.post("/api/rant/rants/{rant_id}/favorite")
|
||||||
async def favorite_rant(
|
async def favorite_rant(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
app: int = Form(3),
|
app: int = Form(3),
|
||||||
@ -709,7 +709,7 @@ async def favorite_rant(
|
|||||||
except Exception:
|
except Exception:
|
||||||
return {"success": False, "error": "Already favorited"}
|
return {"success": False, "error": "Already favorited"}
|
||||||
|
|
||||||
@app.post("/api/devrant/rants/{rant_id}/unfavorite")
|
@app.post("/api/rant/rants/{rant_id}/unfavorite")
|
||||||
async def unfavorite_rant(
|
async def unfavorite_rant(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
app: int = Form(3),
|
app: int = Form(3),
|
||||||
@ -728,7 +728,7 @@ async def unfavorite_rant(
|
|||||||
|
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
|
|
||||||
@app.post("/api/devrant/rants/{rant_id}/comments")
|
@app.post("/api/rant/rants/{rant_id}/comments")
|
||||||
async def create_comment(
|
async def create_comment(
|
||||||
rant_id: int,
|
rant_id: int,
|
||||||
comment: str = Form(...),
|
comment: str = Form(...),
|
||||||
@ -1097,7 +1097,7 @@ async def get_user_id(
|
|||||||
|
|
||||||
return {"success": True, "user_id": user['id']}
|
return {"success": True, "user_id": user['id']}
|
||||||
|
|
||||||
@app.get("/api/devrant/search")
|
@app.get("/api/rant/search")
|
||||||
async def search(
|
async def search(
|
||||||
term: str,
|
term: str,
|
||||||
app: int = 3,
|
app: int = 3,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>DevRant Community</title>
|
<title>Rant Community</title>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -555,7 +555,7 @@
|
|||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav>
|
<nav>
|
||||||
<div class="nav-container">
|
<div class="nav-container">
|
||||||
<a href="#" class="logo" onclick="showFeed()">DevRant</a>
|
<a href="#" class="logo" onclick="showFeed()">Rant</a>
|
||||||
<div class="nav-links">
|
<div class="nav-links">
|
||||||
<a href="#" onclick="showFeed()">Feed</a>
|
<a href="#" onclick="showFeed()">Feed</a>
|
||||||
<a href="#" onclick="showSearch()">Search</a>
|
<a href="#" onclick="showSearch()">Search</a>
|
||||||
@ -691,7 +691,7 @@ async function apiCall(endpoint, options = {}) {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const params = new URLSearchParams({ sort, limit: 50, skip: 0, app: APP_ID });
|
const params = new URLSearchParams({ sort, limit: 50, skip: 0, app: APP_ID });
|
||||||
const data = await apiCall(`/devrant/rants?${params}`);
|
const data = await apiCall(`/rant/rants?${params}`);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
content.innerHTML = `
|
content.innerHTML = `
|
||||||
@ -753,7 +753,7 @@ async function apiCall(endpoint, options = {}) {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const params = new URLSearchParams({ app: APP_ID });
|
const params = new URLSearchParams({ app: APP_ID });
|
||||||
const data = await apiCall(`/devrant/rants/${rantId}?${params}`);
|
const data = await apiCall(`/rant/rants/${rantId}?${params}`);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
const rant = data.rant;
|
const rant = data.rant;
|
||||||
@ -972,7 +972,7 @@ async function apiCall(endpoint, options = {}) {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const params = new URLSearchParams({ term, app: APP_ID });
|
const params = new URLSearchParams({ term, app: APP_ID });
|
||||||
const data = await apiCall(`/devrant/search?${params}`);
|
const data = await apiCall(`/rant/search?${params}`);
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
if (data.results.length === 0) {
|
if (data.results.length === 0) {
|
||||||
@ -1230,7 +1230,7 @@ async function checkNotifications() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const formData = new FormData(event.target);
|
const formData = new FormData(event.target);
|
||||||
|
|
||||||
const data = await apiCall('/devrant/rants', {
|
const data = await apiCall('/rant/rants', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
@ -1255,7 +1255,7 @@ async function checkNotifications() {
|
|||||||
formData.append('reason', 0); // Not for me
|
formData.append('reason', 0); // Not for me
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await apiCall(`/devrant/rants/${rantId}/vote`, {
|
const data = await apiCall(`/rant/rants/${rantId}/vote`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
@ -1300,7 +1300,7 @@ async function checkNotifications() {
|
|||||||
const endpoint = isFavorited ? 'unfavorite' : 'favorite';
|
const endpoint = isFavorited ? 'unfavorite' : 'favorite';
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
const data = await apiCall(`/devrant/rants/${rantId}/${endpoint}`, {
|
const data = await apiCall(`/rant/rants/${rantId}/${endpoint}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
@ -1314,7 +1314,7 @@ async function checkNotifications() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const formData = new FormData(event.target);
|
const formData = new FormData(event.target);
|
||||||
|
|
||||||
const data = await apiCall(`/devrant/rants/${rantId}/comments`, {
|
const data = await apiCall(`/rant/rants/${rantId}/comments`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
@ -1333,7 +1333,7 @@ async function checkNotifications() {
|
|||||||
params.append('token_key', currentUser.token_key);
|
params.append('token_key', currentUser.token_key);
|
||||||
params.append('user_id', currentUser.id);
|
params.append('user_id', currentUser.id);
|
||||||
|
|
||||||
const data = await apiCall(`/devrant/rants/${rantId}?${params}`, {
|
const data = await apiCall(`/rant/rants/${rantId}?${params}`, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user