Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
YamiOdymel committed Sep 2, 2024
0 parents commit 9bfb4e1
Show file tree
Hide file tree
Showing 63 changed files with 7,795 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
db.sqlite
config.json
tunalog
data
bin
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
data
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 Caris Events

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Tunalog [![](https://img.shields.io/github/v/release/caris-events/tunalog)](https://github.com/caris-events/tunalog/releases) [![](https://img.shields.io/badge/license-MIT-green)](https://github.com/caris-events/tunalog/blob/master/LICENSE)

A no-installation, easy-to-use blogging system written in Go.

- 📘 Official Webiste: [tunalog.org](https://tunalog.org) ([Source Code](https://github.com/caris-events/tunalog-docs))
- 📦 Source Code: [GitHub](https://github.com/caris-events/tunalog)
- 🌎 Supported Languages: 🇹🇼 台灣正體, 🇺🇸 English (US)

---

- Easy Markdown editor (powered by [SimpleMDE](<[https://simplemde.com/](https://github.com/sparksuite/simplemde-markdown-editor)>)).
- Portable, Zero-configuration SQLite file database.
- Only 30 MiB in size and uses 32 MiB of memory while running.

&nbsp;

## Getting Started

> Launch with the `-p :8123` argument if you want to change the port.
>
> - http://localhost:8080 - 🐟 Site
> - http://localhost:8080/admin - 👩‍💼 Admin Panel
&nbsp;

### Using on Linux

1. Download latest Tunalog

```
$ wget -c https://github.com/caris-events/tunalog/releases/latest/download/x64_linux_tunalog
```

2. Run Tunalog

```
./x64_linux_tunalog
```

### Using on Windows

1. Download latest Tunalog: [x64_windows_tunalog.exe](https://github.com/caris-events/tunalog/releases/latest/download/x64_windows_tunalog.exe)

2. Double-click the downloaded `x64_windows_tunalog.exe` file to run.

&nbsp;

## Help

```
████████╗██╗ ██╗███╗ ██╗ █████╗ ██╗ ██████╗ ██████╗
╚══██╔══╝██║ ██║████╗ ██║██╔══██╗██║ ██╔═══██╗██╔════╝
██║ ██║ ██║██╔██╗ ██║███████║██║ ██║ ██║██║ ███╗
██║ ╚██████╔╝██║ ╚████║██║ ██║███████╗╚██████╔╝╚██████╔╝
╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝
NAME:
tunalog - A simple blogging system written in Golang ✨
USAGE:
tunalog [global options] command [command options]
VERSION:
1.0.0
COMMANDS:
reset-password reset the password of a user, email address is required
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--port value, -p value port to listen on (default: ":8080")
--tls-key value path to TLS key file
--tls-crt value path to TLS certificate file
--help, -h show help
--version, -v print the version
```

&nbsp;

## Links

- [twitter/twemoji](https://github.com/twitter/twemoji) - Default fish favicon because I was too lazy to draw one myself.
- [teacat/tocas](https://github.com/teacat/tocas) - The UI used in the default theme and admin panel.
- [cznic/sqlite](https://gitlab.com/cznic/sqlite) - For the CGO-free SQLite driver, making it easier to cross-compile Tunalog.

And Tunalog is inspired by [Ghost Blog](https://ghost.org/) and [WordPress](https://wordpress.org/).

&nbsp;

## ❤️ Love from Taiwan

٩(ˊᗜˋ\*)و Developed by Yami Odymel from <span class="ts-flag is-taiwan-flag is-small"></span> Taiwan, along with the ❤️ from [contributors](https://github.com/caris-events/tunalog/graphs/contributors). The source code is licensed under [MIT](https://github.com/caris-events/tunalog/blob/master/LICENSE). Feel free to use, share, or contribute. Tunalog is co-developed by [Caris Events](https://caris.events), part of [Sorae & Co., Ltd.](https://sorae.co)
28 changes: 28 additions & 0 deletions README_DEV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Tunalog Development Notes

Compile All at once:

```
GOOS=windows GOARCH=amd64 go build -o bin/x64_windows_tunalog.exe &&
GOOS=darwin GOARCH=amd64 go build -o bin/x64_macos_tunalog &&
GOOS=linux GOARCH=amd64 go build -o bin/x64_linux_tunalog &&
GOOS=windows GOARCH=arm64 go build -o bin/arm64_windows_tunalog.exe &&
GOOS=darwin GOARCH=arm64 go build -o bin/arm64_macos_tunalog &&
GOOS=linux GOARCH=arm64 go build -o bin/arm64_linux_tunalog
```

or Compile for 64-bit Windows, macOS, Linux:

```
GOOS=windows GOARCH=amd64 go build -o bin/x64_windows_tunalog.exe &&
GOOS=darwin GOARCH=amd64 go build -o bin/x64_macos_tunalog &&
GOOS=linux GOARCH=amd64 go build -o bin/x64_linux_tunalog
```

or for arm64 Windows, macOS, Linux:

```
GOOS=windows GOARCH=arm64 go build -o bin/arm64_windows_tunalog.exe &&
GOOS=darwin GOARCH=arm64 go build -o bin/arm64_macos_tunalog &&
GOOS=linux GOARCH=arm64 go build -o bin/arm64_linux_tunalog
```
55 changes: 55 additions & 0 deletions entity/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package entity

type ColorScheme string

const (
ColorSchemeLight ColorScheme = "light"
ColorSchemeDark ColorScheme = "dark"
ColorSchemeAuto ColorScheme = ""
)

type FontFamily string

const (
FontFamilyNotoSans FontFamily = "sans"
FontFamilyNotoSerif FontFamily = "serif"
)

type AuthorBlock string

const (
AuthorBlockNone AuthorBlock = "none"
AuthorBlockStart AuthorBlock = "start"
AuthorBlockEnd AuthorBlock = "end"
)

type Config struct {
Name string `json:"name"`
Description string `json:"description"`
IsPublic bool `json:"is_public"`
DateFormat string `json:"date_format"`
TimeFormat string `json:"time_format"`
Timezone int `json:"timezone"`
InjectedHead string `json:"injected_head"`
InjectedFoot string `json:"injected_foot"`
InjectedPostStart string `json:"injected_post_start"`
InjectedPostEnd string `json:"injected_post_end"`
FooterText string `json:"footer_text"`
ColorScheme ColorScheme `json:"color_scheme"`
ContainerWidth string `json:"container_width"`
FontFamily FontFamily `json:"font_family"`
FontSize string `json:"font_size"`
HighlightJS bool `json:"highlight_js"`
AuthorBlock AuthorBlock `json:"author_block"`
PostsPerPage int `json:"posts_per_page"`
Theme string `json:"theme"`
Locale string `json:"locale"`
}

func (c *Config) IsCustomTimeFormat() bool {
return c.TimeFormat != "PM 03:04" && c.TimeFormat != "15:04" && c.TimeFormat != "03:04 PM"
}

func (c *Config) IsCustomDateFormat() bool {
return c.DateFormat != "2006-01-02" && c.DateFormat != "01/02/2006" && c.DateFormat != "02/01/2006"
}
116 changes: 116 additions & 0 deletions entity/entity.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package entity

import "html/template"

type Pagination struct {
CurrentPage int
TotalCount int
TotalPages int
Query template.URL
}

var Timezones = map[string]int{
"UTC-12:00": -60 * 60 * 12,
"UTC-11:30": -60 * 60 * 11.5,
"UTC-11:00": -60 * 60 * 11,
"UTC-10:30": -60 * 60 * 10.5,
"UTC-10:00": -60 * 60 * 10,
"UTC-09:30": -60 * 60 * 9.5,
"UTC-09:00": -60 * 60 * 9,
"UTC-08:30": -60 * 60 * 8.5,
"UTC-08:00": -60 * 60 * 8,
"UTC-07:30": -60 * 60 * 7.5,
"UTC-07:00": -60 * 60 * 7,
"UTC-06:30": -60 * 60 * 6.5,
"UTC-06:00": -60 * 60 * 6,
"UTC-05:30": -60 * 60 * 5.5,
"UTC-05:00": -60 * 60 * 5,
"UTC-04:30": -60 * 60 * 4.5,
"UTC-04:00": -60 * 60 * 4,
"UTC-03:30": -60 * 60 * 3.5,
"UTC-03:00": -60 * 60 * 3,
"UTC-02:30": -60 * 60 * 2.5,
"UTC-02:00": -60 * 60 * 2,
"UTC-01:30": -60 * 60 * 1.5,
"UTC-01:00": -60 * 60 * 1,
"UTC-00:30": -60 * 60 * 0.5,
"UTC+00:00": 0,
"UTC+00:30": +60 * 60 * 0.5,
"UTC+01:00": +60 * 60 * 1,
"UTC+01:30": +60 * 60 * 1.5,
"UTC+02:00": +60 * 60 * 2,
"UTC+02:30": +60 * 60 * 2.5,
"UTC+03:00": +60 * 60 * 3,
"UTC+03:30": +60 * 60 * 3.5,
"UTC+04:00": +60 * 60 * 4,
"UTC+04:30": +60 * 60 * 4.5,
"UTC+05:00": +60 * 60 * 5,
"UTC+05:30": +60 * 60 * 5.5,
"UTC+05:45": +60 * 60 * 5.75,
"UTC+06:00": +60 * 60 * 6,
"UTC+06:30": +60 * 60 * 6.5,
"UTC+07:00": +60 * 60 * 7,
"UTC+07:30": +60 * 60 * 7.5,
"UTC+08:00": +60 * 60 * 8,
"UTC+08:30": +60 * 60 * 8.5,
"UTC+08:45": +60 * 60 * 8.75,
"UTC+09:00": +60 * 60 * 9,
"UTC+09:30": +60 * 60 * 9.5,
"UTC+10:00": +60 * 60 * 10,
"UTC+10:30": +60 * 60 * 10.5,
"UTC+11:00": +60 * 60 * 11,
"UTC+11:30": +60 * 60 * 11.5,
"UTC+12:00": +60 * 60 * 12,
"UTC+12:45": +60 * 60 * 12.75,
"UTC+13:00": +60 * 60 * 13,
"UTC+13:45": +60 * 60 * 13.75,
"UTC+14:00": +60 * 60 * 14,
}

var Locales = map[string]string{
"台灣正體": "zh-tw",
"English": "en-us",
}

var PageTypes = map[string]string{
"/admin/users": "user",
"/admin/user/:id": "user",
"/admin/posts": "post",
"/admin/post/create": "post",
"/admin/post/:id": "post",
"/admin/tags": "tag",
"/admin/tag/:id": "tag",
"/admin/photos": "media",
"/admin/navigations": "navigation",
"/admin/settings": "settings",
"/admin/appearances": "appearances",
}

var RelativeRoots = map[string]string{
"/wizard": "../../",
"/login": "../../",
"/admin/users": "../../",
"/admin/navigations": "../../",
"/admin/tags": "../../",
"/admin/settings": "../../",
"/admin/appearances": "../../",
"/admin/posts": "../../",
"/admin/photos": "../../",
"/tag/:tag": "../../",
"/author/:author": "../../",
"/archive/:year": "../../",
"/post/:slug": "../../",
"/admin/user/:id": "../../../",
"/navigations/edit": "../../../",
"/admin/tag/:id": "../../../",
"/admin/appearances/injected": "../../../",
"/admin/post/create": "../../../",
"/admin/trashes/clear": "../../../",
"/admin/post/:id": "../../../",
"/archive/:year/:month": "../../../",
"/admin/tag/:id/delete": "../../../../",
"/admin/post/:id/delete": "../../../../",
"/admin/post/:id/trash": "../../../../",
"/admin/post/:id/untrash": "../../../../",
"/archive/:year/:month/:day": "../../../../",
}
15 changes: 15 additions & 0 deletions entity/navigation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package entity

type NavigationW struct {
ID string
URL string
Name string
Sequence int
}

type NavigationR struct {
ID string
URL string
Name string
Sequence int
}
Loading

0 comments on commit 9bfb4e1

Please sign in to comment.