about summary refs log tree commit diff stats
path: root/README.md
Commit message (Collapse)AuthorAgeFilesLines
* Add notmuch docsReto Brunner2019-08-081-0/+6
|
* Update README.mdDrew DeVault2019-07-141-0/+2
|
* Document collecting log outputLyle Hanson2019-06-141-0/+4
| | | | | | | | | | Redirecting stdout writes log output to that file, but this wasn't easily discoverable. v2 removes changes to aerc-tutorial; I was also on the fence about that, and agree that it isn't on-topic for the tutorial. Addresses https://todo.sr.ht/~sircmpwn/aerc2/180
* Update docs per filters rewriteDrew DeVault2019-06-071-8/+0
|
* Clarify socksify dependencyDrew DeVault2019-06-041-1/+1
|
* Update README.md with better dependency listDrew DeVault2019-06-041-1/+9
|
* Update to the latest go-libvtermDrew DeVault2019-05-261-3/+2
|
* Add aerc-announce to README.mdDrew DeVault2019-05-261-3/+6
|
* Update README.mdDrew DeVault2019-05-251-1/+1
|
* Update README.mdDrew DeVault2019-05-251-13/+4
|
* Update README.mdDrew DeVault2019-05-251-1/+3
|
* Document dependenciesDrew DeVault2019-05-171-0/+6
|
* Add man pagesDrew DeVault2019-05-171-2/+7
|
* Add IRC link to README.mdDrew DeVault2019-05-141-0/+2
|
* Move aerc to dedicated mailing listDrew DeVault2019-05-111-1/+1
|
* Update README.mdDrew DeVault2019-03-211-3/+7
|
* Add link to todo trackerDrew DeVault2019-03-171-0/+2
|
* Add README.md, update license (MIT -2019)Drew DeVault2019-01-131-0/+20
encoding/json" "fmt" "io/ioutil" "math/rand" "net/http" "regexp" "time" ) // APOD holds responses type APOD struct { Copyright string `json:"copyright"` Date string `json:"date"` Explanation string `json:"explanation"` HDURL string `json:"hdurl"` MediaType string `json:"media_type"` ServiceVersion string `json:"service_version"` Title string `json:"title"` URL string `json:"url"` Code int `json:"code"` Msg string `json:"msg"` } // RandDate returns a random date between 1995-06-16 & today func RandDate() string { var ( min int64 max int64 sec int64 delta int64 date string ) min = time.Date(1995, 6, 16, 0, 0, 0, 0, time.UTC).Unix() max = time.Now().UTC().Unix() delta = max - min sec = rand.Int63n(delta) + min date = time.Unix(sec, 0).Format("2006-01-02") return date } // APODPath returns Astronomy Picture of the Day path func APODPath(apodInfo map[string]string, timeout time.Duration) (APOD, error) { var err error apodRes := APOD{} // validate date re := regexp.MustCompile("((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])") if !re.MatchString(apodInfo["date"]) { return apodRes, fmt.Errorf("%s does not match format 'YYYY-MM-DD'", apodInfo["date"]) } client := http.Client{ Timeout: time.Second * timeout, } req, err := http.NewRequest(http.MethodGet, apodInfo["api"], nil) if err != nil { return apodRes, err } q := req.URL.Query() q.Add("api_key", apodInfo["apiKey"]) q.Add("date", apodInfo["date"]) req.URL.RawQuery = q.Encode() res, err := client.Do(req) if err != nil { fmt.Printf("Error: GET %s\n", apodInfo["api"]) return apodRes, err } defer res.Body.Close() resBody, err := ioutil.ReadAll(res.Body) if err != nil { return apodRes, err } err = json.Unmarshal([]byte(resBody), &apodRes) if err != nil { return apodRes, err } if res.StatusCode != 200 { return apodRes, fmt.Errorf("Unexpected response status code received: %d %s", res.StatusCode, http.StatusText(res.StatusCode)) } return apodRes, err }