aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-12-09 08:52:03 -0800
committerChristine Dodrill <me@christine.website>2018-12-09 08:52:30 -0800
commit223095c3f5da5ae63cddcecdfc16f0371afa9939 (patch)
tree985330b212a8c1b7450d773f3f9a5a1d7f5064d8 /tools
parentd66cd9cd7505c19b76379fe18ca7dbae1ff2a4a8 (diff)
downloadx-223095c3f5da5ae63cddcecdfc16f0371afa9939.tar.xz
x-223095c3f5da5ae63cddcecdfc16f0371afa9939.zip
start on manpages
Diffstat (limited to 'tools')
-rw-r--r--tools/dbupload/.gitignore1
-rw-r--r--tools/dbupload/db.go49
-rw-r--r--tools/dbupload/dbmanifestgen/.gitignore1
l---------tools/dbupload/dbmanifestgen/db.go1
-rw-r--r--tools/dbupload/dbmanifestgen/main.go62
-rwxr-xr-xtools/dbupload/dbsimplegen/dbsimplegen11
-rw-r--r--tools/dbupload/main.go116
-rw-r--r--tools/ghstat/main.go2
-rw-r--r--tools/license/main.go1
-rw-r--r--tools/mcrcon/.gitignore1
-rw-r--r--tools/mcrcon/main.go32
11 files changed, 2 insertions, 275 deletions
diff --git a/tools/dbupload/.gitignore b/tools/dbupload/.gitignore
deleted file mode 100644
index fa5221a..0000000
--- a/tools/dbupload/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-dbupload
diff --git a/tools/dbupload/db.go b/tools/dbupload/db.go
deleted file mode 100644
index 5307d04..0000000
--- a/tools/dbupload/db.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package main
-
-type UploadImage struct {
- Image struct {
- SourceURL string `json:"source_url"`
- Tags string `json:"tag_list"`
- ImageURL string `json:"image_url"`
- } `json:"image"`
-}
-
-type Image struct {
- ID string `json:"id"`
- IDNumber int `json:"id_number"`
- CreatedAt string `json:"created_at"`
- UpdatedAt string `json:"updated_at"`
- DuplicateReports []interface{} `json:"duplicate_reports"`
- FileName string `json:"file_name"`
- Description string `json:"description"`
- Uploader string `json:"uploader"`
- Image string `json:"image"`
- Score int `json:"score"`
- Upvotes int `json:"upvotes"`
- Downvotes int `json:"downvotes"`
- Faves int `json:"faves"`
- CommentCount int `json:"comment_count"`
- Tags string `json:"tags"`
- TagIds []string `json:"tag_ids"`
- Width int `json:"width"`
- Height int `json:"height"`
- AspectRatio float64 `json:"aspect_ratio"`
- OriginalFormat string `json:"original_format"`
- MimeType string `json:"mime_type"`
- Sha512Hash string `json:"sha512_hash"`
- OrigSha512Hash string `json:"orig_sha512_hash"`
- SourceURL string `json:"source_url"`
- License string `json:"license"`
- Representations struct {
- ThumbTiny string `json:"thumb_tiny"`
- ThumbSmall string `json:"thumb_small"`
- Thumb string `json:"thumb"`
- Small string `json:"small"`
- Medium string `json:"medium"`
- Large string `json:"large"`
- Tall string `json:"tall"`
- Full string `json:"full"`
- } `json:"representations"`
- IsRendered bool `json:"is_rendered"`
- IsOptimized bool `json:"is_optimized"`
-}
diff --git a/tools/dbupload/dbmanifestgen/.gitignore b/tools/dbupload/dbmanifestgen/.gitignore
deleted file mode 100644
index fb82ff6..0000000
--- a/tools/dbupload/dbmanifestgen/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-dbmanifestgen
diff --git a/tools/dbupload/dbmanifestgen/db.go b/tools/dbupload/dbmanifestgen/db.go
deleted file mode 120000
index 18b3e05..0000000
--- a/tools/dbupload/dbmanifestgen/db.go
+++ /dev/null
@@ -1 +0,0 @@
-../db.go \ No newline at end of file
diff --git a/tools/dbupload/dbmanifestgen/main.go b/tools/dbupload/dbmanifestgen/main.go
deleted file mode 100644
index c5bbb2b..0000000
--- a/tools/dbupload/dbmanifestgen/main.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package main
-
-import (
- "encoding/json"
- "flag"
- "fmt"
- "io/ioutil"
- "log"
- "os"
- "path/filepath"
- "strings"
-)
-
-var (
- serverloc = flag.String("serverloc", "http://static.xeserv.us/", "server to prepend to url paths")
- sourceloc = flag.String("sourceloc", "", "source URL for metadata generation")
- set = flag.String("set", "", "comic set")
-)
-
-func main() {
- flag.Parse()
-
- if flag.NArg() == 0 {
- fmt.Printf("%s: <dir>\n", os.Args[0])
- flag.Usage()
- }
-
- if *sourceloc == "" {
- log.Fatal("Need a source location")
- }
-
- images, err := ioutil.ReadDir(flag.Arg(0))
- if err != nil {
- panic(err)
- }
-
- for _, image := range images {
- if strings.HasSuffix(image.Name(), ".json") {
- log.Printf("Skipped %s...", image)
- continue
- }
-
- fout, err := os.Create(image.Name() + ".json")
-
- var i UploadImage
- i.Image.SourceURL = *sourceloc
- i.Image.ImageURL = *serverloc + filepath.Base(image.Name())
- i.Image.Tags = "explicit"
-
- if *set != "" {
- i.Image.Tags = i.Image.Tags + ", comic:" + *set
- }
-
- outdata, err := json.MarshalIndent(&i, "", "\t")
- if err != nil {
- panic(err)
- }
-
- fout.Write(outdata)
- fout.Close()
- }
-}
diff --git a/tools/dbupload/dbsimplegen/dbsimplegen b/tools/dbupload/dbsimplegen/dbsimplegen
deleted file mode 100755
index e8939e8..0000000
--- a/tools/dbupload/dbsimplegen/dbsimplegen
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-cat << EOF
-{
- "image": {
- "source_url": "$1",
- "tag_list": "$2",
- "image_url": "$3"
- }
-}
-EOF
diff --git a/tools/dbupload/main.go b/tools/dbupload/main.go
deleted file mode 100644
index cc07cd7..0000000
--- a/tools/dbupload/main.go
+++ /dev/null
@@ -1,116 +0,0 @@
-package main
-
-import (
- "bytes"
- "encoding/json"
- "flag"
- "fmt"
- "io"
- "io/ioutil"
- "log"
- "net/http"
- "os"
- "strings"
- "time"
-)
-
-var (
- apiKeyLocation = flag.String("apikeyloc", "/home/xena/.local/share/within/db.key", "Derpibooru API key location")
- cookieLocation = flag.String("cookieloc", "/home/xena/.db.cookie", "Location for magic cookie")
-)
-
-func main() {
- flag.Parse()
-
- if flag.NArg() == 0 {
- fmt.Printf("%s: <image to upload>\n", os.Args[0])
- fmt.Printf("All files must have a manifest json file.\n")
- flag.Usage()
- }
-
- dbkey, err := ioutil.ReadFile(*apiKeyLocation)
- if err != nil {
- panic(err)
- }
-
- mydbkey := strings.Split(string(dbkey), "\n")[0]
-
- cookie, err := ioutil.ReadFile(*cookieLocation)
- if err != nil {
- panic(err)
- }
-
- image := flag.Arg(0)
-
- if strings.HasSuffix(image, ".json") {
- log.Printf("Skipped %s...", image)
- return
- }
-
- metafin, err := os.Open(image + ".json")
- if err != nil {
- log.Fatal("image " + image + " MUST have description manifest for derpibooru")
- }
- defer metafin.Close()
-
- metabytes, err := ioutil.ReadAll(metafin)
- if err != nil {
- log.Fatal(err)
- }
-
- var meta UploadImage
- err = json.Unmarshal(metabytes, &meta)
- if err != nil {
- log.Fatal(err)
- }
-
- imfin, err := os.Open(image)
- if err != nil {
- log.Fatal("cannot open " + image)
- }
- defer imfin.Close()
-
- if meta.Image.ImageURL == "" {
- panic("need file uploaded somewhere?")
- }
-
- outmetabytes, err := json.Marshal(&meta)
-
- req, err := http.NewRequest("POST", "https://derpibooru.org/images.json?key="+mydbkey, bytes.NewBuffer(outmetabytes))
- if err != nil {
- panic(err)
- }
-
- c := &http.Client{}
-
- req.Header = http.Header{
- "User-Agent": {"Xena's crappy upload tool"},
- "Cookie": {string(cookie)},
- "Content-Type": {"application/json"},
- }
-
- resp, err := c.Do(req)
- if err != nil {
- log.Printf("%#v", err)
- fmt.Printf("Request ID: %s\n", resp.Header.Get("X-Request-Id"))
- return
- }
-
- if resp.StatusCode != 201 {
- io.Copy(os.Stdout, resp.Body)
- return
- }
-
- respbytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- log.Println(err)
- return
- }
-
- var i Image
- json.Unmarshal(respbytes, &i)
-
- fmt.Printf("Uploaded as https://derpibooru.org/%d\n", i.IDNumber)
-
- time.Sleep(20 * time.Second)
-}
diff --git a/tools/ghstat/main.go b/tools/ghstat/main.go
index 91f260d..2185d93 100644
--- a/tools/ghstat/main.go
+++ b/tools/ghstat/main.go
@@ -8,6 +8,7 @@ import (
"net/http"
"os"
+ "github.com/Xe/x/internal"
"github.com/Xe/x/web/ghstat"
)
@@ -20,6 +21,7 @@ var (
func main() {
flag.Parse()
+ internal.HandleLicense()
if *messageFlag {
req := ghstat.LastMessage()
diff --git a/tools/license/main.go b/tools/license/main.go
index 6840912..881ebbd 100644
--- a/tools/license/main.go
+++ b/tools/license/main.go
@@ -35,7 +35,6 @@ func init() {
func main() {
flag.Parse()
-
internal.HandleLicense()
if *showAll {
diff --git a/tools/mcrcon/.gitignore b/tools/mcrcon/.gitignore
deleted file mode 100644
index 9247261..0000000
--- a/tools/mcrcon/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-mcrcon
diff --git a/tools/mcrcon/main.go b/tools/mcrcon/main.go
deleted file mode 100644
index 1c5ebd6..0000000
--- a/tools/mcrcon/main.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "log"
- "strings"
-
- "github.com/bearbin/mcgorcon"
-)
-
-var (
- host = flag.String("host", "127.0.0.1", "server hostname")
- port = flag.Int("port", 25575, "rcon port")
- password = flag.String("pass", "swag", "rcon password")
-)
-
-func main() {
- flag.Parse()
-
- client, err := mcgorcon.Dial(*host, *port, *password)
- if err != nil {
- log.Fatal(err)
- }
-
- data, err := client.SendCommand(strings.Join(flag.Args(), " "))
- if err != nil {
- log.Fatal(err)
- }
-
- fmt.Println(data)
-}