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 - type: markdown
attributes: attributes:
value: | 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 - type: textarea
attributes: attributes:
label: Is your feature request related to a problem? label: Is your feature request related to a problem?

View File

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

View File

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

View File

@ -15,15 +15,15 @@ RUN apk update && apk add --no-cache gcc musl-dev
COPY . . COPY . .
COPY --from=frontend /frontend-build/dist ./server/dist 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. # Make workspace with above generated files.
FROM alpine:3.16 AS monolithic 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. # 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 ## Demo
> The project is under development and your contributions and feedback are welcome. > The project is under development and your contributions and feedback are welcome.
![demo](./resources/demo.gif) ![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 package api
import "github.com/boojack/corgi/server/profile" import "github.com/boojack/shortify/server/profile"
type SystemStatus struct { type SystemStatus struct {
Profile *profile.Profile `json:"profile"` Profile *profile.Profile `json:"profile"`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<body> <body>
<h2>Corgi extension</h2> <h2>Shortify extension</h2>
<div> <div>
<span>Domain</span> <span>Domain</span>
<input id="domain-input" type="text" /> <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 saveButton = document.body.querySelector("#save-button");
const domainInput = document.body.querySelector("#domain-input"); const domainInput = document.body.querySelector("#domain-input");
@ -6,7 +6,7 @@ const openIdInput = document.body.querySelector("#openid-input");
saveButton.addEventListener("click", () => { saveButton.addEventListener("click", () => {
chrome.storage.local.set({ chrome.storage.local.set({
corgi: { shortify: {
domain: domainInput.value, domain: domainInput.value,
openId: openIdInput.value, openId: openIdInput.value,
}, },
@ -14,9 +14,9 @@ saveButton.addEventListener("click", () => {
}); });
(async () => { (async () => {
const corgiData = await getCorgiData(); const shortifyData = await getShortifyData();
if (corgiData) { if (shortifyData) {
domainInput.value = corgiData.domain; domainInput.value = shortifyData.domain;
openIdInput.value = corgiData.openId; 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 go 1.19

View File

@ -3,7 +3,7 @@ package main
import ( import (
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
"github.com/boojack/corgi/cmd" "github.com/boojack/shortify/cmd"
) )
func main() { 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" tmp_dir = ".air"
[build] [build]
bin = "./.air/corgi" bin = "./.air/shortify"
cmd = "go build -o ./.air/corgi ./main.go" cmd = "go build -o ./.air/shortify ./main.go"
delay = 1000 delay = 1000
exclude_dir = [".air", "web", "build"] exclude_dir = [".air", "web", "build"]
exclude_file = [] exclude_file = []

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/boojack/corgi/server/version" "github.com/boojack/shortify/server/version"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -18,7 +18,7 @@ type Profile struct {
Port int `json:"port"` Port int `json:"port"`
// Data is the data directory // Data is the data directory
Data string `json:"data"` 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"` DSN string `json:"dsn"`
// Version is the current version of server // Version is the current version of server
Version string `json:"version"` Version string `json:"version"`
@ -57,7 +57,7 @@ func GetProfile() (*Profile, error) {
} }
if profile.Mode == "prod" && profile.Data == "" { if profile.Mode == "prod" && profile.Data == "" {
profile.Data = "/var/opt/corgi" profile.Data = "/var/opt/shortify"
} }
dataDir, err := checkDSN(profile.Data) dataDir, err := checkDSN(profile.Data)
@ -67,7 +67,7 @@ func GetProfile() (*Profile, error) {
} }
profile.Data = dataDir 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) profile.Version = version.GetCurrentVersion(profile.Mode)
return &profile, nil return &profile, nil
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,8 +12,8 @@ import (
"sort" "sort"
"time" "time"
"github.com/boojack/corgi/server/profile" "github.com/boojack/shortify/server/profile"
"github.com/boojack/corgi/server/version" "github.com/boojack/shortify/server/version"
) )
//go:embed migration //go:embed migration
@ -87,7 +87,7 @@ func (db *DB) Open(ctx context.Context) (err error) {
if err != nil { if err != nil {
return fmt.Errorf("failed to read raw database file, err: %w", err) 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 { if err := os.WriteFile(backupDBFilePath, rawBytes, 0644); err != nil {
return fmt.Errorf("failed to write raw database file, err: %w", err) return fmt.Errorf("failed to write raw database file, err: %w", err)
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1 +1 @@
# Corgi # Shortify

View File

@ -2,10 +2,10 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <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="theme-color" content="#FFFFFF" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>Corgi</title> <title>Shortify</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@ -1,5 +1,5 @@
{ {
"name": "corgi", "name": "shortify",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "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="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"> <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"> <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="" /> <img src="/logo.png" className="w-8 h-auto mr-2" alt="" />
Corgi Shortify
</Link> </Link>
{workspaceList.length > 0 && activedWorkspace !== undefined && ( {workspaceList.length > 0 && activedWorkspace !== undefined && (
<> <>

View File

@ -30,7 +30,7 @@ const Auth: React.FC = () => {
api.getSystemStatus().then(({ data }) => { api.getSystemStatus().then(({ data }) => {
const { data: status } = data; const { data: status } = data;
if (status.profile.mode === "dev") { if (status.profile.mode === "dev") {
setEmail("frank@iamcorgi.com"); setEmail("frank@shortify.demo");
setPassword("secret"); 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-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="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"> <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"> <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" />} {actionBtnLoadingState.isLoading && <Icon.Loader className="ml-2 w-5 h-auto animate-spin" />}
</div> </div>
</div> </div>