Skip to content

Commit

Permalink
Merge develop to main (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
dark-person authored Nov 29, 2023
2 parents ae98500 + b286ccb commit b250fd1
Show file tree
Hide file tree
Showing 36 changed files with 4,824 additions and 119 deletions.
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Changes Made

Give Details for all your changes, include an itemized list if you can.

### Reason of Changes

Give Reason for these changes, e.g. `input validation is not worked as expected`, or `improve UX`. Also give 2~3 sentence to explain your reason.

### Checklist:

- [ ] I have run the new code and ensure the change is work expected
- [ ] I have write/modify comments to important function & hard-to-understand code
- [ ] I have create/modify corresponding test for new changes
- [ ] I have made corresponding changes to the documentation
- [ ] I have run all new & existing test and pass locally with my changes
- [ ] I have checked my code has no misspellings & no warnings
- [ ] I have checked that only essential code remains in this pull request
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ go.work
temp/*

# Example File for developer reference only
ComicInfoStruct/Example.xml
Example.xml

# Wails Default
build/bin
Expand Down
31 changes: 31 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"cSpell.words": [
"assetserver",
"Colour",
"comicinfo",
"GTIN",
"innerxml",
"Komga",
"Penciller",
"wailsapp"
],
"editor.formatOnSave": true,
"editor.unicodeHighlight.includeStrings": false,
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"editor.tabSize": 4,
"editor.detectIndentation": true
}
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# README
# GUI ComicInfo Parser

## About

This is the official Wails React-TS template.
[ComicInfo.xml](https://anansi-project.github.io/docs/comicinfo/documentation) is a metadata for manga/comic. It is used in some self-hosted app, e.g. `komga`.

You can configure the project by editing `wails.json`. More information about the project settings can be found
here: https://wails.io/docs/reference/project-config
This Project is aim to provide a simple GUI for create `ComicInfo.xml` and `.cbz` archive at easy way.

## Live Development
## Feature Available

To run in live development mode, run `wails dev` in the project directory. This will run a Vite development
server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser
and have access to your Go methods, there is also a dev server that runs on https://localhost:34115. Connect
to this in your browser, and you can call your Go code from devtools.
### Quick Export (Komga Only)

## Building
Create a directory that can copy directly to `komga` comic directory.

To build a redistributable, production mode package, use `wails build`.
Already contains a `.cbz` archive and `ComicInfo.xml` at correct location.

## Develop

This project using `go` language, with `wails` framework and `react` typescript as frontend.

### Live Development Mode

To run in live development mode, run `wails dev` in the project directory.

This will run a Vite development server that will provide very fast hot reload of your frontend changes.

If you want to develop in a browser and have access to your Go methods, there is also a dev server that runs on https://localhost:34115. Connect to this in your browser, and you can call your Go code from devtools.

### Building

To build a re-distributable, production mode package, use `wails build`.
72 changes: 69 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ package main

import (
"context"
"encoding/xml"
"fmt"
"gui-comicinfo/internal/archive"
"gui-comicinfo/internal/scanner"
"os"
"path/filepath"

"github.com/sirupsen/logrus"
"github.com/wailsapp/wails/v2/pkg/runtime"
)

// App struct
Expand All @@ -21,7 +29,65 @@ func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}

// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
// Open a Dialog for user to select Directory.
//
// If Error is occur, then this function will return an empty string
func (a *App) GetDirectory() string {
directory, err := runtime.OpenDirectoryDialog(a.ctx, runtime.OpenDialogOptions{
Title: "Select Directory",
})

if err != nil {
logrus.Warnf("Error when getting directory from user: %v\n", err)
return ""
}
return directory
}

// Perform Quick Export Action,
// where ComicInfo.xml file can not be modified before archived.
//
// If error is occur, then return a string containing the error message.
// Otherwise, return empty string.
//
// This function will perform these task:
// 1. Scan the directory and create a ComicInfo.xml file
// 2. Archive the directory and xml file as .cbz file
// 3. Wrap the .cbz file with a folder to copy to komga
//
// This function is specific designed for komga folder structure.
func (a *App) QuickExportKomga(folder string) string {
absPath := folder

if absPath == "" {
return "folder cannot be empty"
}

// Load Abs Path
c := scanner.ScanBooks(absPath)

output, err := xml.MarshalIndent(c, " ", " ")
if err != nil {
fmt.Printf("error: %v\n", err)
}

// Open File for reading
f, err := os.Create(filepath.Join(absPath, "ComicInfo.xml"))
if err != nil {
return err.Error()
}
defer f.Close()

// Write XML Content to file
f.Write([]byte("<?xml version=\"1.0\"?>\n"))
f.Write(output)
f.Sync()

// Start Archive
filename, _ := archive.CreateZip(absPath)
err = archive.RenameZip(filename)
if err != nil {
fmt.Printf("error: %v\n", err)
}
return ""
}
21 changes: 10 additions & 11 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>Gui-comicInfo-Parser</title>
</head>
<body>
<div id="root"></div>
<script src="./src/main.tsx" type="module"></script>
</body>
<html lang="en" data-bs-theme="dark">
<head>
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Gui-comicInfo-Parser</title>
</head>
<body>
<div id="root"></div>
<script src="./src/main.tsx" type="module"></script>
</body>
</html>

Loading

0 comments on commit b250fd1

Please sign in to comment.