feat(ui): add changelog view
This commit is contained in:
parent
82401d52a5
commit
74e8c5bb83
@ -6,6 +6,7 @@ steps:
|
|||||||
image: node
|
image: node
|
||||||
commands:
|
commands:
|
||||||
- make build-view
|
- make build-view
|
||||||
|
- make git-json
|
||||||
volumes:
|
volumes:
|
||||||
- name: cache
|
- name: cache
|
||||||
path: /drone/src/view/node_modules
|
path: /drone/src/view/node_modules
|
||||||
|
7
Makefile
7
Makefile
@ -1,11 +1,11 @@
|
|||||||
MAKEFLAGS += -j2
|
MAKEFLAGS += -j2
|
||||||
|
|
||||||
export PORT = 8080
|
dev: export PORT = 8080
|
||||||
|
|
||||||
dev: dev-server dev-view
|
dev: dev-server dev-view
|
||||||
|
|
||||||
dev-server:
|
dev-server:
|
||||||
cd server && gin run main.go
|
cd server && gin -p $$PORT run main.go
|
||||||
dev-view:
|
dev-view:
|
||||||
cd view && npm run dev
|
cd view && npm run dev
|
||||||
|
|
||||||
@ -13,3 +13,6 @@ build: build-view
|
|||||||
|
|
||||||
build-view:
|
build-view:
|
||||||
cd view && npm i && npm run build
|
cd view && npm i && npm run build
|
||||||
|
|
||||||
|
git-json:
|
||||||
|
echo "[$$(git log --pretty=format:'{"id":"%h","subject":"%s","date":"%cD"},')]" | sed "s/,]/]/g" > view/public/build/commits.json
|
@ -3,6 +3,7 @@
|
|||||||
import * as routes from "./routes";
|
import * as routes from "./routes";
|
||||||
import ToastWrapper from "./components/Toast/ToastWrapper.svelte";
|
import ToastWrapper from "./components/Toast/ToastWrapper.svelte";
|
||||||
import { route as currentRoute } from "./stores";
|
import { route as currentRoute } from "./stores";
|
||||||
|
import Changelog from "components/Changelog";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $currentRoute.startsWith("editor")}
|
{#if $currentRoute.startsWith("editor")}
|
||||||
|
7
view/src/components/Changelog/Commit.svelte
Normal file
7
view/src/components/Changelog/Commit.svelte
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let commit: Commit;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{commit.subject}
|
||||||
|
</p>
|
65
view/src/routes/changelog.svelte
Normal file
65
view/src/routes/changelog.svelte
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<script>
|
||||||
|
import Commit from "components/Changelog/Commit.svelte";
|
||||||
|
import { commitStore, route } from "stores";
|
||||||
|
|
||||||
|
$: if ($commitStore.length) {
|
||||||
|
localStorage.setItem(
|
||||||
|
"currentCommit",
|
||||||
|
$commitStore[$commitStore.length - 1].id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$: commits =
|
||||||
|
$commitStore.length &&
|
||||||
|
$commitStore
|
||||||
|
.filter((commit) => {
|
||||||
|
return (
|
||||||
|
commit.subject.startsWith("feat") &&
|
||||||
|
commit.subject.replace("feat:", "").length > 3
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.map((commit) => {
|
||||||
|
commit.subject = commit.subject.replace("feat:", "").trim();
|
||||||
|
commit.date = new Date(commit.date);
|
||||||
|
return commit;
|
||||||
|
});
|
||||||
|
|
||||||
|
let day = $commitStore.length && new Date($commitStore[0].date).getDay();
|
||||||
|
|
||||||
|
const checkDate = (commit) => {
|
||||||
|
console.log(commit);
|
||||||
|
|
||||||
|
const d = new Date(commit.date);
|
||||||
|
if (d.getDay() != day) {
|
||||||
|
day = d.getDay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const prettyDate = (date) => {
|
||||||
|
return new Date(date).toLocaleDateString();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<button on:click={() => ($route = "list")}>exit</button>
|
||||||
|
<h1>Changelog</h1>
|
||||||
|
|
||||||
|
{#each commits as commit}
|
||||||
|
{#if checkDate(commit)}
|
||||||
|
<h3>
|
||||||
|
{prettyDate(commit.date)}
|
||||||
|
</h3>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Commit {commit} />
|
||||||
|
{/each}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
main {
|
||||||
|
max-width: 640px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,2 +1,3 @@
|
|||||||
export { default as main } from "./main.svelte"
|
export { default as main } from "./main.svelte"
|
||||||
export { default as list } from "./list.svelte"
|
export { default as list } from "./list.svelte"
|
||||||
|
export { default as changelog } from "./changelog.svelte"
|
8
view/src/stores/commits.ts
Normal file
8
view/src/stores/commits.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { writable } from "svelte/store";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const store = writable<Commit[]>([]);
|
||||||
|
|
||||||
|
|
||||||
|
export default store;
|
@ -1,3 +1,4 @@
|
|||||||
import * as images from "./images";
|
import * as images from "./images";
|
||||||
export { images }
|
export { images }
|
||||||
export { default as route } from "./route";
|
export { default as route } from "./route";
|
||||||
|
export { default as commitStore } from "./commits";
|
6
view/src/types.d.ts
vendored
6
view/src/types.d.ts
vendored
@ -11,6 +11,12 @@ interface Image {
|
|||||||
data: ArrayBuffer
|
data: ArrayBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Commit {
|
||||||
|
id: string,
|
||||||
|
subject: string,
|
||||||
|
date: Date
|
||||||
|
}
|
||||||
|
|
||||||
declare module "*.frag" {
|
declare module "*.frag" {
|
||||||
const content: string;
|
const content: string;
|
||||||
export default content;
|
export default content;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user