diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-08-01 23:22:42 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2024-08-15 03:48:43 +0200 |
commit | 26a64f20764b2406b797b2d94cd7a11f77c5bbb0 (patch) | |
tree | 50e26585477ce338f29fa9cce54f3e55903b2bbd /tmp.go | |
parent | b14f846182978e0f8e7f579b0ce986fa3b974ea3 (diff) | |
download | tmp-26a64f20764b2406b797b2d94cd7a11f77c5bbb0.tar.gz |
fix: add comments to the Go source
Diffstat (limited to 'tmp.go')
-rw-r--r-- | tmp.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -16,6 +16,13 @@ var COMPRESSED_EXTENSIONS = []string{".jpg", ".webm", ".ogg", ".gz", ".bz2", ".z ".avi", ".jar", ".opus", ".ogv", ".flac", ".msi", ".m4a"} +// THE VARIABLE URL_VARIANTS IS MEANT TO BE EDITED. Change various +// attributes to correspond to your situation. +// If new section is added (as here I have also 'tmp' for fedorapeople.org) +// and the script has a symlink named as the section (so I have tmp as +// a symlink to this script) it saves the file to the location defined in +// such section when called under the other name. +// So, `tmp filename` saves file filename to fedorapeople for me. var URL_VARIANTS = map[string]map[string]string{ "wotan": { "base_url": "wotan:Export/", @@ -80,6 +87,7 @@ func main() { if err != nil { log.Fatal(err) } + // To make scp happy modifiedFname := strings.Replace(fname, ":", "_", 1) err = os.Rename(fname, modifiedFname) if err != nil { @@ -93,10 +101,13 @@ func main() { } targetURL := config["target_url"] + filepath.Base(modifiedFname) + // Make target_URL into a safe URL safeTargetURL := url.QueryEscape(targetURL) safeTargetURL = strings.Replace(safeTargetURL, "%3A", ":", 1) fmt.Println(safeTargetURL) + // curl -s 'http://is.gd/create.php?format=simple&url=www.example.com' + // http://is.gd/MOgh5q if shortenAPI, ok := config["shorten_api"]; ok { shortenedURLBytes, err := exec.Command("curl", "-s", shortenAPI+safeTargetURL).Output() if err != nil { @@ -106,6 +117,7 @@ func main() { fmt.Println(shortenedURL) } + // The script should have no side-effects if COMPRESSED { os.Remove(modifiedFname) } else { |