mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-29 22:24:31 +02:00
fix: download page api code
(because afn couldn't do it properly the first time)
This commit is contained in:
parent
1428e17efe
commit
10812aef27
@ -125,10 +125,38 @@ import { dev_log } from "$lib/utils";
|
||||
|
||||
export type ContribData = { repositories: Repository[] };
|
||||
export type PatchesData = { patches: Patch[]; packages: string[] };
|
||||
export type ToolsData = { tools: Tool[] };
|
||||
export type ToolsData = { tools: { [repo: string]: Tool } };
|
||||
|
||||
export const contributors = new API<ContribData>("contributors", undefined, { repositories: [] });
|
||||
export const tools = new API<ToolsData>("tools", undefined, { tools: [] } )
|
||||
export const tools = new API<ToolsData>("tools", json => {
|
||||
// The API returns data in a weird shape. Make it easier to work with.
|
||||
let map: Map<string, Tool> = new Map();
|
||||
for (const tool of json["tools"]) {
|
||||
const repo: string = tool.repository;
|
||||
|
||||
if (!map.has(repo)) {
|
||||
map.set(repo, {
|
||||
version: tool.version,
|
||||
repository: repo,
|
||||
// Just use the timestamp of the first one we find.
|
||||
timestamp: tool.timestamp,
|
||||
assets: []
|
||||
});
|
||||
}
|
||||
|
||||
let value = map.get(repo);
|
||||
value.assets.push({
|
||||
name: tool.name,
|
||||
size: tool.size,
|
||||
url: tool.browser_download_url,
|
||||
content_type: tool.content_type
|
||||
});
|
||||
|
||||
map.set(repo, value);
|
||||
}
|
||||
|
||||
return { tools: Object.fromEntries(map) };
|
||||
});
|
||||
|
||||
export const patches = new API<PatchesData>("patches", patches => {
|
||||
let packages: string[] = [];
|
||||
|
@ -33,12 +33,17 @@ export interface PatchOption {
|
||||
choices: string[];
|
||||
}
|
||||
|
||||
export interface Asset {
|
||||
name: string;
|
||||
size: string|null;
|
||||
url: string;
|
||||
content_type: string;
|
||||
};
|
||||
|
||||
export interface Tool {
|
||||
repository: string
|
||||
version: string
|
||||
timestamp: string
|
||||
name: string
|
||||
size?: string
|
||||
browser_download_url: string
|
||||
content_type: string
|
||||
}
|
||||
repository: string;
|
||||
version: string;
|
||||
timestamp: string;
|
||||
assets: Asset[];
|
||||
};
|
||||
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
export let data: PageData;
|
||||
api_tools.init(data);
|
||||
$: tools = data.tools;
|
||||
|
||||
$: manager = $api_tools.tools["revanced/revanced-manager"];
|
||||
</script>
|
||||
|
||||
<div class="wrapper">
|
||||
<h1>ReVanced Manager</h1>
|
||||
<h6>Patch your favourite apps, on-device.</h6>
|
||||
<Button kind="primary" icon="download" href={tools[5].browser_download_url}>{tools[5].version}</Button>
|
||||
<Button kind="primary" icon="download" href={manager.assets[0].url}>{manager.version}</Button>
|
||||
<img src="../manager_two.png" alt="Manager Screenshot"/>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user