ヘルプとバージョン表示(CLI)の削除
このコミットが含まれているのは:
コミット
6056cf6d68
|
@ -1,6 +1,7 @@
|
||||||
# 2.3.0
|
# 2.3.0
|
||||||
* GPL→ISC
|
* GPL→ISC
|
||||||
* GNU Make→BSD Make
|
* GNU Make→BSD Make
|
||||||
|
* ヘルプとバージョン表示(CLI)の削除
|
||||||
|
|
||||||
# 2.2.0
|
# 2.2.0
|
||||||
* ポート番号の修正
|
* ポート番号の修正
|
||||||
|
|
|
@ -63,7 +63,9 @@ func getconf () (Config, error) {
|
||||||
data, err := ioutil.ReadFile(cnf.configpath)
|
data, err := ioutil.ReadFile(cnf.configpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("config.jsonを開けられません: ", err)
|
fmt.Println("config.jsonを開けられません: ", err)
|
||||||
return cnf, errors.New("コンフィグファイルは " + cnf.configpath + " に創作して下さい。")
|
return cnf, errors.New(
|
||||||
|
"コンフィグファイルは " + cnf.configpath + " に創作して下さい。",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var payload map[string]interface{}
|
var payload map[string]interface{}
|
||||||
|
@ -82,7 +84,9 @@ func getconf () (Config, error) {
|
||||||
return cnf, errors.New("mkdirコマンドを使って、 " + payload["webpath"].(string))
|
return cnf, errors.New("mkdirコマンドを使って、 " + payload["webpath"].(string))
|
||||||
}
|
}
|
||||||
if !checkprefix(payload["domain"].(string)) {
|
if !checkprefix(payload["domain"].(string)) {
|
||||||
return cnf, errors.New("URLは「http://」又は「https://」で始める様にして下さい。")
|
return cnf, errors.New(
|
||||||
|
"URLは「http://」又は「https://」で始める様にして下さい。",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
cnf.webpath = payload["webpath"].(string)
|
cnf.webpath = payload["webpath"].(string)
|
||||||
cnf.domain = payload["domain"].(string)
|
cnf.domain = payload["domain"].(string)
|
||||||
|
|
72
main.go
72
main.go
|
@ -9,18 +9,11 @@ import (
|
||||||
var sofname = "urloli"
|
var sofname = "urloli"
|
||||||
var version = "2.3.0"
|
var version = "2.3.0"
|
||||||
|
|
||||||
func help () {
|
func usage() {
|
||||||
fmt.Println("076 URLロリ - クッソ小さいURL短縮作成ソフトだわ〜♡")
|
fmt.Printf("%s-%s\nusage: %s [-s port] [url]\n", sofname, version, sofname)
|
||||||
fmt.Println("https://urlo.li/ | https://gitler.moe/suwako/urloli")
|
|
||||||
fmt.Println("")
|
|
||||||
fmt.Println("使い方:");
|
|
||||||
fmt.Println("urloli -v :バージョンを表示");
|
|
||||||
fmt.Println("urloli -s [ポート番号] :ポート番号でウェブサーバーを実行(デフォルト=9910)");
|
|
||||||
fmt.Println("urloli -h :ヘルプを表示");
|
|
||||||
fmt.Println("urloli <URL> :コマンドラインでURLを短縮");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main () {
|
func main() {
|
||||||
cnf, err := getconf()
|
cnf, err := getconf()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -28,38 +21,33 @@ func main () {
|
||||||
}
|
}
|
||||||
args := os.Args
|
args := os.Args
|
||||||
|
|
||||||
if len(args) == 2 {
|
if len(args) < 2 {
|
||||||
if args[1] == "-v" {
|
usage()
|
||||||
fmt.Println("urloli-" + version)
|
|
||||||
return
|
|
||||||
} else if args[1] == "-s" {
|
|
||||||
serv(cnf, 9910)
|
|
||||||
} else if args[1] == "-h" {
|
|
||||||
help()
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
if checkprefix(args[1]) {
|
|
||||||
_, key := geturl(args[1], cnf.linkpath, true)
|
|
||||||
if (key != "") {
|
|
||||||
fmt.Println(cnf.domain + "/" + key)
|
|
||||||
} else {
|
|
||||||
fmt.Println(cnf.domain + "/" + insertjson(args[1], cnf.linkpath))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
fmt.Println("URLは不正です。終了…")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if len(args) == 3 && args[1] == "-s" {
|
|
||||||
if port, err := strconv.Atoi(args[2]); err != nil {
|
|
||||||
fmt.Printf("%qは数字ではありません。\n", args[2])
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
serv(cnf, port)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
help()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(args) == 2 && args[1] == "-s" {
|
||||||
|
serv(cnf, 9910)
|
||||||
|
} else if len(args) == 2 && args[1] != "-s" {
|
||||||
|
if !checkprefix(args[1]) {
|
||||||
|
fmt.Println("URLは不正です。終了…")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, key := geturl(args[1], cnf.linkpath, true)
|
||||||
|
if (key != "") {
|
||||||
|
fmt.Println(cnf.domain + "/" + key)
|
||||||
|
} else {
|
||||||
|
fmt.Println(cnf.domain + "/" + insertjson(args[1], cnf.linkpath))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else if len(args) == 3 && args[1] == "-s" {
|
||||||
|
port, err := strconv.Atoi(args[2])
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%qは数字ではありません。\n", args[2])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
serv(cnf, port)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
40
srv.go
40
srv.go
|
@ -62,8 +62,15 @@ func serv (cnf Config, port int) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(cnf.webpath + "/static"))))
|
http.Handle(
|
||||||
ftmpl := []string{cnf.webpath + "/view/index.html", cnf.webpath + "/view/header.html", cnf.webpath + "/view/footer.html"}
|
"/static/",
|
||||||
|
http.StripPrefix("/static/", http.FileServer(http.Dir(cnf.webpath + "/static"))),
|
||||||
|
)
|
||||||
|
ftmpl := []string{
|
||||||
|
cnf.webpath + "/view/index.html",
|
||||||
|
cnf.webpath + "/view/header.html",
|
||||||
|
cnf.webpath + "/view/footer.html",
|
||||||
|
}
|
||||||
|
|
||||||
http.HandleFunc("/api", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/api", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||||
|
@ -76,7 +83,7 @@ func serv (cnf Config, port int) {
|
||||||
lang := initloc(r)
|
lang := initloc(r)
|
||||||
i18n, err := goliblocale.GetLocale(cnf.webpath + "/locale/" + lang)
|
i18n, err := goliblocale.GetLocale(cnf.webpath + "/locale/" + lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("liblocaleエラー:%v", err)
|
fmt.Printf("liblocaleエラー:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +110,19 @@ func serv (cnf Config, port int) {
|
||||||
if chklim && chkprx {
|
if chklim && chkprx {
|
||||||
chkfn, key := geturl(addurl, cnf.linkpath, true)
|
chkfn, key := geturl(addurl, cnf.linkpath, true)
|
||||||
if chkfn != "" {
|
if chkfn != "" {
|
||||||
res = &Api{Cod: 200, Url: cnf.domain + "/" + key, Mot: addurl, New: false}
|
res = &Api{
|
||||||
|
Cod: 200,
|
||||||
|
Url: cnf.domain + "/" + key,
|
||||||
|
Mot: addurl,
|
||||||
|
New: false,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res = &Api{Cod: 200, Url: cnf.domain + "/" + insertjson(addurl, cnf.linkpath), Mot: addurl, New: true}
|
res = &Api{
|
||||||
|
Cod: 200,
|
||||||
|
Url: cnf.domain + "/" + insertjson(addurl, cnf.linkpath),
|
||||||
|
Mot: addurl,
|
||||||
|
New: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -125,7 +142,7 @@ func serv (cnf Config, port int) {
|
||||||
|
|
||||||
i18n, err := goliblocale.GetLocale(cnf.webpath + "/locale/" + lang)
|
i18n, err := goliblocale.GetLocale(cnf.webpath + "/locale/" + lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("liblocaleエラー:%v", err)
|
fmt.Printf("liblocaleエラー:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data.i18n = i18n
|
data.i18n = i18n
|
||||||
|
@ -169,7 +186,10 @@ func serv (cnf Config, port int) {
|
||||||
}
|
}
|
||||||
} else if r.PostForm.Get("langchange") != "" {
|
} else if r.PostForm.Get("langchange") != "" {
|
||||||
lang := r.PostForm.Get("lang")
|
lang := r.PostForm.Get("lang")
|
||||||
http.SetCookie(w, &http.Cookie{Name: "lang", Value: lang, MaxAge: 31536000, Path: "/"})
|
http.SetCookie(
|
||||||
|
w,
|
||||||
|
&http.Cookie{Name: "lang", Value: lang, MaxAge: 31536000, Path: "/"},
|
||||||
|
)
|
||||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -191,6 +211,10 @@ func serv (cnf Config, port int) {
|
||||||
data = nil
|
data = nil
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Println(fmt.Sprint("http://" + cnf.ip + ":", port, " でサーバーを実行中。終了するには、CTRL+Cを押して下さい。"))
|
fmt.Println(fmt.Sprint(
|
||||||
|
"http://" + cnf.ip + ":",
|
||||||
|
port,
|
||||||
|
" でサーバーを実行中。終了するには、CTRL+Cを押して下さい。",
|
||||||
|
))
|
||||||
http.ListenAndServe(fmt.Sprint(cnf.ip + ":", port), nil)
|
http.ListenAndServe(fmt.Sprint(cnf.ip + ":", port), nil)
|
||||||
}
|
}
|
||||||
|
|
8
urloli.1
8
urloli.1
|
@ -8,22 +8,18 @@ URLロリ - クッソ小さいURL短縮作成ソフトだわ〜♡
|
||||||
.PP
|
.PP
|
||||||
URLロリはクッソ小さいURL短縮作成ソフトです。
|
URLロリはクッソ小さいURL短縮作成ソフトです。
|
||||||
.TP
|
.TP
|
||||||
\fB\-v\fR
|
|
||||||
バージョンを表示
|
|
||||||
.TP
|
.TP
|
||||||
\fB\-s [ポート番号]\fR
|
\fB\-s [ポート番号]\fR
|
||||||
ポート番号でサーバーを開始(デフォルト=9910)
|
ポート番号でサーバーを開始(デフォルト=9910)
|
||||||
.TP
|
.TP
|
||||||
\fB\-h\fR
|
|
||||||
ヘルプを表示
|
|
||||||
.TP
|
.TP
|
||||||
.B オプションなし
|
.B オプションなし
|
||||||
ローカルにURLを短縮
|
ローカルにURLを短縮
|
||||||
.SH 会話
|
.SH 会話
|
||||||
.PP
|
.PP
|
||||||
XMPP: xmpp:urloli@chat.xmpp.076.ne.jp?join
|
XMPP: xmpp:moriyajinja@chat.xmpp.076.ne.jp?join
|
||||||
.br
|
.br
|
||||||
IRC: irc.076.ne.jp/6697 #urloli
|
IRC: irc.076.moe/6697 #moriyajinja
|
||||||
.br
|
.br
|
||||||
メーリングリスト: (開発中)
|
メーリングリスト: (開発中)
|
||||||
.SH バグ報告
|
.SH バグ報告
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
{{define "footer"}}
|
{{define "footer"}}
|
||||||
</div>
|
</div>
|
||||||
<p class="footer">
|
<p class="footer">
|
||||||
<a href="https://gitler.moe/suwako/urloli"><img src="/static/git.png" alt="Git" /></a> |
|
<a href="https://gitler.moe/suwako/urloli">
|
||||||
|
<img src="/static/git.png" alt="Git" />
|
||||||
|
</a> |
|
||||||
<a href="https://076.moe/">076</a>
|
<a href="https://076.moe/">076</a>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{{define "header"}}
|
{{define "header"}}
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
|
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
|
||||||
|
@ -17,6 +18,8 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<p>
|
<p>
|
||||||
<a href="/">{{.T "top"}}</a> |
|
<a href="/">{{.T "top"}}</a> |
|
||||||
<a href="https://technicalsuwako.moe/blog/urloli-{{.Ves}}/">urloli-{{.Ver}}</a>
|
<a href="https://technicalsuwako.moe/blog/urloli-{{.Ves}}/">
|
||||||
|
urloli-{{.Ver}}
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -5,7 +5,12 @@
|
||||||
<option value="ja"{{if eq .Lan "ja"}} selected{{end}}>日本語</option>
|
<option value="ja"{{if eq .Lan "ja"}} selected{{end}}>日本語</option>
|
||||||
<option value="en"{{if eq .Lan "en"}} selected{{end}}>English</option>
|
<option value="en"{{if eq .Lan "en"}} selected{{end}}>English</option>
|
||||||
</select>
|
</select>
|
||||||
<input class="langchange" type="submit" name="langchange" value="{{.T "langchange"}}" />
|
<input
|
||||||
|
class="langchange"
|
||||||
|
type="submit"
|
||||||
|
name="langchange"
|
||||||
|
value="{{.T "langchange"}}"
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
{{template "header" .}}
|
{{template "header" .}}
|
||||||
{{.T "canunderaccess"}}
|
{{.T "canunderaccess"}}
|
||||||
<br />
|
<br />
|
||||||
|
|
読み込み中…
新しいイシューから参照