Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

0.1.0: Refactoring #1

Merged
merged 19 commits into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
# Compiled class file
*.class
.idea
.gradle

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
media
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ FROM gradle:jdk8 AS build
WORKDIR /app
COPY --from=cache /app/gradle /home/gradle/.gradle
COPY *.gradle.kts gradle.properties /app/
COPY src/commonMain/ /app/src/commonMain/
COPY src/jvmMain/ /app/src/jvmMain/
# Stop printing Welcome
RUN gradle -version > /dev/null \
Expand All @@ -24,6 +23,7 @@ RUN gradle -version > /dev/null \
# Final Stage
FROM openjdk:17-jdk-alpine
COPY --from=build /app/build/libs/stella-all.jar /app/stella.jar
COPY docs/ /app/docs/

WORKDIR /app
ENTRYPOINT ["java", "-jar", "/app/stella.jar"]
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ services:
TWITTER_CS: xxx
TWITTER_AT: xxx
TWITTER_ATS: xxx
PIXIV_EMAIL: xxx
PIXIV_PASSWORD: xxx
PIXIV_REFRESH_TOKEN: xxx
NIJIE_EMAIL: xxx
NIJIE_PASSWORD: xxx

Expand Down
35 changes: 18 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
kotlin("multiplatform") version "1.4.30"
kotlin("plugin.serialization") version "1.4.30"
id("com.github.johnrengelman.shadow") version "6.1.0"

id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
Expand All @@ -8,11 +9,10 @@ plugins {
}

object Versions {
const val Ktor = "1.5.1"
const val Ktor = "1.5.2"
const val Penicillin = "6.0.5"
const val KMongo = "4.2.3"
const val Jsoup = "1.13.1"
const val CommonsLang = "3.8.1"

const val JUnit = "5.7.0"

Expand All @@ -22,15 +22,15 @@ object Versions {
}

object Libraries {
const val Penicillin = "blue.starry:penicillin:${Versions.Penicillin}"

const val KtorServerCIO = "io.ktor:ktor-server-cio:${Versions.Ktor}"
const val KtorLocations = "io.ktor:ktor-locations:${Versions.Ktor}"
const val KtorSerialization = "io.ktor:ktor-serialization:${Versions.Ktor}"
const val KtorClientCIO = "io.ktor:ktor-client-cio:${Versions.Ktor}"
const val KtorClientLogging = "io.ktor:ktor-client-logging:${Versions.Ktor}"

const val KMongoCoroutine = "org.litote.kmongo:kmongo-coroutine:${Versions.KMongo}"
const val CommonsLang3 = "org.apache.commons:commons-lang3:${Versions.CommonsLang}"

const val KMongoCoroutineSerialization = "org.litote.kmongo:kmongo-coroutine-serialization:${Versions.KMongo}"
const val KMongoIdSerialization = "org.litote.kmongo:kmongo-id-serialization:${Versions.KMongo}"
const val Penicillin = "blue.starry:penicillin:${Versions.Penicillin}"
const val Jsoup = "org.jsoup:jsoup:${Versions.Jsoup}"

const val KotlinLogging = "io.github.microutils:kotlin-logging:${Versions.KotlinLogging}"
Expand All @@ -48,13 +48,14 @@ object Libraries {
"kotlin.time.ExperimentalTime",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"io.ktor.util.KtorExperimentalAPI",
"io.ktor.locations.KtorExperimentalLocationsAPI"
"io.ktor.locations.KtorExperimentalLocationsAPI",
"kotlinx.coroutines.FlowPreview"
)
}

repositories {
mavenCentral()
// jcenter()

maven(url = "https://kotlin.bintray.com/kotlinx")
}

Expand All @@ -70,6 +71,10 @@ kotlin {

sourceSets {
commonMain {
dependencies {
implementation(Libraries.Penicillin)
implementation(Libraries.KotlinLogging)
}
}
commonTest {
dependencies {
Expand All @@ -80,20 +85,16 @@ kotlin {

named("jvmMain") {
dependencies {
implementation(kotlin("reflect"))

implementation(Libraries.Penicillin)

implementation(Libraries.KtorServerCIO)
implementation(Libraries.KtorLocations)
implementation(Libraries.KtorSerialization)
implementation(Libraries.KtorClientCIO)
implementation(Libraries.KtorClientLogging)

implementation(Libraries.KMongoCoroutine)
implementation(Libraries.CommonsLang3)

implementation(Libraries.KMongoCoroutineSerialization)
implementation(Libraries.KMongoIdSerialization)
implementation(Libraries.Jsoup)

implementation(Libraries.KotlinLogging)
implementation(Libraries.LogbackCore)
implementation(Libraries.LogbackClassic)
implementation(Libraries.Jansi)
Expand Down
1 change: 0 additions & 1 deletion docs/CNAME

This file was deleted.

32 changes: 14 additions & 18 deletions docs/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
};

const App = {
mediaBaseUrl: "https://stella-api.starry.blue/media/",
mediaBaseUrl: "/api/media/",
mobileWarningArea: document.getElementById("mobile-warning"),
isMobile: navigator.userAgent.includes("iPhone OS") || navigator.userAgent.includes("Android") || navigator.userAgent.includes("Mobile"),
countEntriesArea: document.getElementById("count-entries"),
Expand All @@ -104,15 +104,15 @@
parameters.count = 10;
const query = API.buildParameterString(parameters);

return `https://stella-api.starry.blue/query${query !== null ? "?" + query : ""}`;
return `/api/query${query !== null ? "?" + query : ""}`;
},
responseType: "text",
status: ".page-load-status",
history: false
});

App.infiniteScroll.on("load", response => {
JSON.parse(response).result.map(t => (new PicElementBuilder(t)).build());
JSON.parse(response).map(t => (new PicElementBuilder(t)).build());

const items = Container.element.querySelectorAll(".direction-reveal__card");
App.infiniteScroll.appendItems(items);
Expand Down Expand Up @@ -481,7 +481,7 @@
createMediaItem() {
const a = document.createElement("a");
a.classList.add("direction-reveal__card", "media-item");
a.setAttribute("data-id", this.pic.id);
a.setAttribute("data-id", this.pic._id);
return a;
}

Expand Down Expand Up @@ -1153,7 +1153,7 @@
this.pic.tags.push({user: null, locked: false, value: tagValue});
this.tagCurrentResult.appendChild(this.createDeleteTagEach({user: null, locked: false, value: tagValue}));

for (const element of Array.from(Container.element.querySelectorAll(`a.media-item[data-id="${this.pic.id}"] .overlay-tags`))) {
for (const element of Array.from(Container.element.querySelectorAll(`a.media-item[data-id="${this.pic._id}"] .overlay-tags`))) {
element.insertBefore(PicOverlayBuilder.createTagEach({user: null, locked: false, value: tagValue}), element.lastChild);
}

Expand All @@ -1164,7 +1164,7 @@
this.pic.tags = this.pic.tags.filter(e => e.value !== tagValue);
this.tagRelationalResult.appendChild(this.createAddTagEach(tagValue));

for (const element of Array.from(Container.element.querySelector(`a.media-item[data-id="${this.pic.id}"] a[data-tag=\"${tagValue}\"]`))) {
for (const element of Array.from(Container.element.querySelector(`a.media-item[data-id="${this.pic._id}"] a[data-tag=\"${tagValue}\"]`))) {
element.remove();
}

Expand Down Expand Up @@ -1215,15 +1215,11 @@
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
const query = API.buildParameterString(params);
xhr.open(method, `https://stella-api.starry.blue${path}${query !== null ? "?" + query : ""}`, true);
xhr.open(method, `/api${path}${query !== null ? "?" + query : ""}`, true);
xhr.onload = () => {
try {
const json = JSON.parse(xhr.responseText);
if (json.success && xhr.status === 200) {
resolve(json.result);
} else {
reject(new Error(json.error));
}
resolve(json);
} catch (e) {
reject(e);
}
Expand Down Expand Up @@ -1252,12 +1248,12 @@
}).map(value => `${encodeURIComponent(value[0])}=${encodeURIComponent(value[1])}`).join("&");
},
summary: () => API.asyncRequest("GET", "/summary", null, null),
refreshEntry: pic => API.asyncRequest("PUT", `/refresh/${pic.id}`, null, null),
addTag: (pic, tag) => API.asyncRequest("PUT", `/edit/${pic.id}/tag`, null, {tag: tag}),
deleteTag: (pic, tag) => API.asyncRequest("DELETE", `/edit/${pic.id}/tag`, null, {tag: tag}),
updateSensitiveLevel: (pic, level) => API.asyncRequest("PATCH", `/edit/${pic.id}/sensitive_level`, null, {sensitive_level: level}),
relationalTags: pic => API.asyncRequest("GET", "/query/tags", {id: pic.id, sensitive_level: pic.sensitive_level, count: 20}, null),
searchTags: (pic, name) => API.asyncRequest("GET", "/query/tags", {id: pic.id, name: name, sensitive_level: pic.sensitive_level, count: 30}, null)
refreshEntry: pic => API.asyncRequest("PUT", `/pic/${pic._id}/refresh`, null, null),
addTag: (pic, tag) => API.asyncRequest("PUT", `/pic/${pic._id}/tag`, null, {tag: tag}),
deleteTag: (pic, tag) => API.asyncRequest("DELETE", `/pic/${pic._id}/tag`, null, {tag: tag}),
updateSensitiveLevel: (pic, level) => API.asyncRequest("PATCH", `/pic/${pic._id}/sensitive_level`, null, {sensitive_level: level}),
relationalTags: pic => API.asyncRequest("GET", "/query/tags", {id: pic._id, sensitive_level: pic.sensitive_level, count: 20}, null),
searchTags: (pic, name) => API.asyncRequest("GET", "/query/tags", {id: pic._id, name: name, sensitive_level: pic.sensitive_level, count: 30}, null)
};

if (App.isMobile) {
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Thu Jul 16 01:27:03 JST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down

This file was deleted.

63 changes: 0 additions & 63 deletions src/commonMain/kotlin/blue.starry.stella/common/PicModel.kt

This file was deleted.

Loading