feat: rename to shortify

This commit is contained in:
Steven 2023-03-16 08:25:58 +08:00
parent 143bdb7596
commit d08a738a57
43 changed files with 114 additions and 116 deletions

View File

@ -5,7 +5,7 @@ body:
- type: markdown
attributes:
value: |
Thanks for taking the time to suggest an idea for Corgi!
Thanks for taking the time to suggest an idea for Shortify!
- type: textarea
attributes:
label: Is your feature request related to a problem?

View File

@ -33,12 +33,13 @@ jobs:
with:
install: true
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: stevenlgtm/corgi:${{ env.VERSION }}
# TODO(steven)
# - name: Build and Push
# id: docker_build
# uses: docker/build-push-action@v3
# with:
# context: ./
# file: ./Dockerfile
# platforms: linux/amd64,linux/arm64
# push: true
# tags: stevenlgtm/shortify:${{ env.VERSION }}

View File

@ -26,12 +26,13 @@ jobs:
install: true
version: v0.9.1
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: stevenlgtm/corgi:test
# TODO(steven)
# - name: Build and Push
# id: docker_build
# uses: docker/build-push-action@v3
# with:
# context: ./
# file: ./Dockerfile
# platforms: linux/amd64
# push: true
# tags: stevenlgtm/corgi:test

View File

@ -15,15 +15,15 @@ RUN apk update && apk add --no-cache gcc musl-dev
COPY . .
COPY --from=frontend /frontend-build/dist ./server/dist
RUN go build -o corgi ./main.go
RUN go build -o shortify ./main.go
# Make workspace with above generated files.
FROM alpine:3.16 AS monolithic
WORKDIR /usr/local/corgi
WORKDIR /usr/local/shortify
COPY --from=backend /backend-build/corgi /usr/local/corgi/
COPY --from=backend /backend-build/shortify /usr/local/shortify/
# Directory to store the data, which can be referenced as the mounting point.
RUN mkdir -p /var/opt/corgi
RUN mkdir -p /var/opt/shortify
ENTRYPOINT ["./corgi", "--mode", "prod", "--port", "5231"]
ENTRYPOINT ["./shortify", "--mode", "prod", "--port", "5231"]

View File

@ -1,15 +1,11 @@
# Corgi
# Shortify
<img align="right" src="./resources/corgi-logo.png" height="96px" alt="corgi logo">
<img align="right" src="./resources/logo.png" height="96px" alt="logo">
Corgi is a URL shortening and bookmarking service that helps users to shorten long links into short and manageable ones. This service is designed to simplify the sharing of links on blogs, social media, and other platforms.
Shortify is a URL shortening and bookmarking service that helps users to shorten long links into short and manageable ones. This service is designed to simplify the sharing of links on blogs, social media, and other platforms.
## Demo
> The project is under development and your contributions and feedback are welcome.
![demo](./resources/demo.gif)
---
Thanks to Andrei for the [Corgi Avatar](https://www.artstation.com/artwork/bK6gqn) artwork!

View File

@ -1,6 +1,6 @@
package api
import "github.com/boojack/corgi/server/profile"
import "github.com/boojack/shortify/server/profile"
type SystemStatus struct {
Profile *profile.Profile `json:"profile"`

View File

@ -3,7 +3,7 @@ package api
import (
"fmt"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/common"
)
type User struct {

View File

@ -11,18 +11,18 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/boojack/corgi/server"
_profile "github.com/boojack/corgi/server/profile"
"github.com/boojack/shortify/server"
_profile "github.com/boojack/shortify/server/profile"
)
const (
greetingBanner = `
`
)
@ -33,7 +33,7 @@ var (
data string
rootCmd = &cobra.Command{
Use: "corgi",
Use: "shortify",
Short: "",
Run: func(_cmd *cobra.Command, _args []string) {
ctx, cancel := context.WithCancel(context.Background())
@ -97,7 +97,7 @@ func init() {
viper.SetDefault("mode", "dev")
viper.SetDefault("port", 8082)
viper.SetEnvPrefix("corgi")
viper.SetEnvPrefix("shortify")
}
func initConfig() {

View File

@ -1,4 +1,4 @@
import { getCorgiData } from "./common.js";
import { getShortifyData } from "./common.js";
const urlRegex = /https?:\/\/o\/(.+)/;
@ -6,16 +6,16 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
if (typeof tab.url === "string") {
const matchResult = urlRegex.exec(tab.url);
if (matchResult) {
const corgiData = await getCorgiData();
const shortifyData = await getShortifyData();
const name = matchResult[1];
const url = `${corgiData.domain}/api/shortcut?openId=${corgiData.openId}&name=${name}&redirect=true`;
const url = `${shortifyData.domain}/api/shortcut?openId=${shortifyData.openId}&name=${name}&redirect=true`;
return chrome.tabs.update({ url });
}
}
});
chrome.omnibox.onInputEntered.addListener(async (text) => {
const corgiData = await getCorgiData();
const url = `${corgiData.domain}/api/shortcut?openId=${corgiData.openId}&name=${text}&redirect=true`;
const shortifyData = await getShortifyData();
const url = `${shortifyData.domain}/api/shortcut?openId=${shortifyData.openId}&name=${text}&redirect=true`;
return chrome.tabs.update({ url });
});

View File

@ -1,10 +1,10 @@
export const getCorgiData = () => {
export const getShortifyData = () => {
return new Promise((resolve, reject) => {
chrome.storage.local.get(["corgi"], (data) => {
if (data?.corgi) {
resolve(data.corgi);
chrome.storage.local.get(["shortify"], (data) => {
if (data?.shortify) {
resolve(data.shortify);
} else {
reject("corgi data not found");
reject("shortify data not found");
}
});
});

View File

@ -1,6 +1,6 @@
{
"name": "Corgi",
"description": "Corgi is an URL manager.",
"name": "Shortify",
"description": "",
"version": "0.0.1",
"manifest_version": 3,
"omnibox": {

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<body>
<h2>Corgi extension</h2>
<h2>Shortify extension</h2>
<div>
<span>Domain</span>
<input id="domain-input" type="text" />

View File

@ -1,4 +1,4 @@
import { getCorgiData } from "./common.js";
import { getShortifyData } from "./common.js";
const saveButton = document.body.querySelector("#save-button");
const domainInput = document.body.querySelector("#domain-input");
@ -6,7 +6,7 @@ const openIdInput = document.body.querySelector("#openid-input");
saveButton.addEventListener("click", () => {
chrome.storage.local.set({
corgi: {
shortify: {
domain: domainInput.value,
openId: openIdInput.value,
},
@ -14,9 +14,9 @@ saveButton.addEventListener("click", () => {
});
(async () => {
const corgiData = await getCorgiData();
if (corgiData) {
domainInput.value = corgiData.domain;
openIdInput.value = corgiData.openId;
const shortifyData = await getShortifyData();
if (shortifyData) {
domainInput.value = shortifyData.domain;
openIdInput.value = shortifyData.openId;
}
})();

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/boojack/corgi
module github.com/boojack/shortify
go 1.19

View File

@ -3,7 +3,7 @@ package main
import (
_ "github.com/mattn/go-sqlite3"
"github.com/boojack/corgi/cmd"
"github.com/boojack/shortify/cmd"
)
func main() {

View File

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -2,8 +2,8 @@ root = "."
tmp_dir = ".air"
[build]
bin = "./.air/corgi"
cmd = "go build -o ./.air/corgi ./main.go"
bin = "./.air/shortify"
cmd = "go build -o ./.air/shortify ./main.go"
delay = 1000
exclude_dir = [".air", "web", "build"]
exclude_file = []

View File

@ -8,6 +8,6 @@ cd "$(dirname "$0")/../"
echo "Start building backend..."
go build -o ./build/corgi ./main.go
go build -o ./build/shortify ./main.go
echo "Backend built!"

View File

@ -5,8 +5,8 @@ import (
"net/http"
"strconv"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
@ -15,7 +15,7 @@ import (
var (
userIDContextKey = "user-id"
sessionName = "corgi_session"
sessionName = "shortify-session"
)
func getUserIDContextKey() string {

View File

@ -5,8 +5,8 @@ import (
"fmt"
"net/http"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/labstack/echo/v4"
"golang.org/x/crypto/bcrypt"

View File

@ -1,8 +1,8 @@
package server
import (
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/labstack/echo/v4"
)

View File

@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"
"github.com/boojack/corgi/server/version"
"github.com/boojack/shortify/server/version"
"github.com/spf13/viper"
)
@ -18,7 +18,7 @@ type Profile struct {
Port int `json:"port"`
// Data is the data directory
Data string `json:"data"`
// DSN points to where Corgi stores its own data
// DSN points to where Shortify stores its own data
DSN string `json:"dsn"`
// Version is the current version of server
Version string `json:"version"`
@ -57,7 +57,7 @@ func GetProfile() (*Profile, error) {
}
if profile.Mode == "prod" && profile.Data == "" {
profile.Data = "/var/opt/corgi"
profile.Data = "/var/opt/shortify"
}
dataDir, err := checkDSN(profile.Data)
@ -67,7 +67,7 @@ func GetProfile() (*Profile, error) {
}
profile.Data = dataDir
profile.DSN = fmt.Sprintf("%s/corgi_%s.db", dataDir, profile.Mode)
profile.DSN = fmt.Sprintf("%s/shortify_%s.db", dataDir, profile.Mode)
profile.Version = version.GetCurrentVersion(profile.Mode)
return &profile, nil
}

View File

@ -3,7 +3,7 @@ package server
import (
"net/http"
"github.com/boojack/corgi/api"
"github.com/boojack/shortify/api"
"github.com/labstack/echo/v4"
)

View File

@ -6,9 +6,9 @@ import (
"fmt"
"time"
"github.com/boojack/corgi/server/profile"
"github.com/boojack/corgi/store"
"github.com/boojack/corgi/store/db"
"github.com/boojack/shortify/server/profile"
"github.com/boojack/shortify/store"
"github.com/boojack/shortify/store/db"
"github.com/pkg/errors"
"github.com/gorilla/securecookie"
@ -64,7 +64,7 @@ func NewServer(ctx context.Context, profile *profile.Profile) (*Server, error) {
embedFrontend(e)
// In dev mode, set the const secret key to make signin session persistence.
secret := []byte("iamcorgi")
secret := []byte("iamshortify")
if profile.Mode == "prod" {
secret = securecookie.GenerateRandomKey(16)
}

View File

@ -6,8 +6,8 @@ import (
"net/http"
"strconv"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/labstack/echo/v4"
)

View File

@ -3,7 +3,7 @@ package server
import (
"net/http"
"github.com/boojack/corgi/api"
"github.com/boojack/shortify/api"
"github.com/labstack/echo/v4"
)

View File

@ -6,8 +6,8 @@ import (
"net/http"
"strconv"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/labstack/echo/v4"
"golang.org/x/crypto/bcrypt"

View File

@ -6,8 +6,8 @@ import (
"net/http"
"strconv"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/labstack/echo/v4"
)

View File

@ -6,8 +6,8 @@ import (
"net/http"
"strconv"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
"github.com/labstack/echo/v4"
)

View File

@ -12,8 +12,8 @@ import (
"sort"
"time"
"github.com/boojack/corgi/server/profile"
"github.com/boojack/corgi/server/version"
"github.com/boojack/shortify/server/profile"
"github.com/boojack/shortify/server/version"
)
//go:embed migration
@ -87,7 +87,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
if err != nil {
return fmt.Errorf("failed to read raw database file, err: %w", err)
}
backupDBFilePath := fmt.Sprintf("%s/corgi_%s_%d_backup.db", db.profile.Data, db.profile.Version, time.Now().Unix())
backupDBFilePath := fmt.Sprintf("%s/shortify_%s_%d_backup.db", db.profile.Data, db.profile.Version, time.Now().Unix())
if err := os.WriteFile(backupDBFilePath, rawBytes, 0644); err != nil {
return fmt.Errorf("failed to write raw database file, err: %w", err)
}

View File

@ -9,7 +9,7 @@ INSERT INTO
VALUES
(
101,
'frank@iamcorgi.com',
'frank@shortify.demo',
'Frank',
-- raw password: secret
'$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK',
@ -27,7 +27,7 @@ INSERT INTO
VALUES
(
102,
'bob@iamcorgi.com',
'bob@shortify.demo',
'Bob',
-- raw password: secret
'$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK',

View File

@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
)
// shortcutRaw is the store model for an Shortcut.

View File

@ -4,7 +4,7 @@ import (
"database/sql"
"sync"
"github.com/boojack/corgi/server/profile"
"github.com/boojack/shortify/server/profile"
)
// Store provides database access to all raw objects.

View File

@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
)
// userRaw is the store model for an User.

View File

@ -5,7 +5,7 @@ import (
"database/sql"
"strings"
"github.com/boojack/corgi/api"
"github.com/boojack/shortify/api"
)
type userSettingRaw struct {

View File

@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
)
// workspaceRaw is the store model for Workspace.

View File

@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"github.com/boojack/corgi/api"
"github.com/boojack/corgi/common"
"github.com/boojack/shortify/api"
"github.com/boojack/shortify/common"
)
// workspaceUserRaw is the store model for WorkspaceUser.

View File

@ -1 +1 @@
# Corgi
# Shortify

View File

@ -2,10 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/corgi-logo.png" type="image/*" />
<link rel="icon" href="/logo.png" type="image/*" />
<meta name="theme-color" content="#FFFFFF" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>Corgi</title>
<title>Shortify</title>
</head>
<body>
<div id="root"></div>

View File

@ -1,5 +1,5 @@
{
"name": "corgi",
"name": "shortify",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",

View File

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -38,8 +38,8 @@ const Header: React.FC = () => {
<div className="w-full max-w-4xl mx-auto px-3 py-5 flex flex-row justify-between items-center">
<div className="flex flex-row justify-start items-center shrink mr-2">
<Link to="/" className="text-base font-mono font-medium cursor-pointer flex flex-row justify-start items-center">
<img src="/corgi-logo.png" className="w-8 h-auto mr-2" alt="" />
Corgi
<img src="/logo.png" className="w-8 h-auto mr-2" alt="" />
Shortify
</Link>
{workspaceList.length > 0 && activedWorkspace !== undefined && (
<>

View File

@ -30,7 +30,7 @@ const Auth: React.FC = () => {
api.getSystemStatus().then(({ data }) => {
const { data: status } = data;
if (status.profile.mode === "dev") {
setEmail("frank@iamcorgi.com");
setEmail("frank@shortify.demo");
setPassword("secret");
}
});
@ -121,9 +121,9 @@ const Auth: React.FC = () => {
<div className="w-80 max-w-full h-full py-4 flex flex-col justify-start items-center">
<div className="w-full py-4 grow flex flex-col justify-center items-center">
<div className="flex flex-row justify-start items-center w-full mb-4">
<img src="/corgi-logo.png" className="w-14 h-auto mr-1" alt="" />
<img src="/logo.png" className="w-14 h-auto mr-1" alt="" />
<div className="text-3xl font-medium font-mono flex flex-row justify-start items-center">
Corgi
Shortify
{actionBtnLoadingState.isLoading && <Icon.Loader className="ml-2 w-5 h-auto animate-spin" />}
</div>
</div>