Skip to content

Commit

Permalink
🤦
Browse files Browse the repository at this point in the history
  • Loading branch information
Bot committed Jan 31, 2025
1 parent 36e5ab0 commit c644ea6
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 57 deletions.
9 changes: 8 additions & 1 deletion an_website/quotes/quotes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
import { get, PopStateHandlers, post, setLastLocation, d, e as getElementById } from "@utils/utils.js";
import {
d,
e as getElementById,
get,
PopStateHandlers,
post,
setLastLocation,
} from "@utils/utils.js";

function startQuotes() {
const nextButton = getElementById("next") as HTMLAnchorElement;
Expand Down
26 changes: 13 additions & 13 deletions an_website/quotes/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ class QuoteReportArgs:
quote_id: int | None = None
reason: str | None = None

def validate(self) -> None:
"""Validate the arguments."""
if self.author_id is None and self.quote_id is None:
raise MissingArgumentError("quote_id")

def get_quote_url_path(self) -> str:
"""Get the URL that got reported."""
if self.author_id is None:
return f"/zitate/info/q/{self.quote_id}"
if self.quote_id is None:
return f"/zitate/info/a/{self.author_id}"
return f"/zitate/{self.quote_id}-{self.quote_id}"

async def get_quote_object(self) -> Quote | WrongQuote | Author | None:
"""Get the quote object."""
if self.author_id is not None:
Expand All @@ -62,6 +49,19 @@ async def get_quote_object(self) -> Quote | WrongQuote | Author | None:
return QUOTES_CACHE.get(self.quote_id)
return None

def get_quote_url_path(self) -> str:
"""Get the URL that got reported."""
if self.author_id is None:
return f"/zitate/info/q/{self.quote_id}"
if self.quote_id is None:
return f"/zitate/info/a/{self.author_id}"
return f"/zitate/{self.quote_id}-{self.quote_id}"

def validate(self) -> None:
"""Validate the arguments."""
if self.author_id is None and self.quote_id is None:
raise MissingArgumentError("quote_id")


class QuoteReportApi(APIRequestHandler):
"""Report wrong quotes."""
Expand Down
18 changes: 9 additions & 9 deletions an_website/quotes/report.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { post, e as getElementById } from "@utils/utils.js";
import { e as getElementById, post } from "@utils/utils.js";

interface Reasoned {
reason?: string;
}

type Data = {
author_id: number,
quote_id: number,
author_id: number;
quote_id: number;
} | {
author_id: number,
author_id: number;
} | {
quote_id: number,
quote_id: number;
};

function getDataFromUrl(): Data {
const path: string[] = location.pathname.split('/');
const path: string[] = location.pathname.split("/");
console.debug(path);
if (path[path.length - 1] == "") {
path.pop();
Expand All @@ -37,7 +37,7 @@ function getDataFromUrl(): Data {
}

function createReportButton(anchor: HTMLAnchorElement) {
anchor.removeAttribute('href')
anchor.removeAttribute("href");
anchor.addEventListener("click", (event: Event) => {
event.preventDefault();
const data: Data & Reasoned = getDataFromUrl();
Expand All @@ -61,9 +61,9 @@ function reportQuote(reportData: Data & Reasoned): Promise<void> {
reportData,
(data: boolean) => {
if (data) {
alert("Erfolgreich gemeldet!")
alert("Erfolgreich gemeldet!");
}
}
},
);
}

Expand Down
8 changes: 7 additions & 1 deletion an_website/search/search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
import { get, PopStateHandlers, setURLParam, e as getElementById, d } from "@utils/utils.js";
import {
d,
e as getElementById,
get,
PopStateHandlers,
setURLParam,
} from "@utils/utils.js";

const resultsList = getElementById("search-results")!;
const searchForm = getElementById("search-form") as HTMLFormElement;
Expand Down
2 changes: 1 addition & 1 deletion an_website/static/js/quotes/quotes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c644ea6

Please sign in to comment.