commit fccba9b150ace24993b597e3f48dd3020c70ca14
parent 11a1a7dccce27c6ffcd4a88fc878ebc32ee735db
Author: FIGBERT <figbert@figbert.com>
Date: Tue, 26 Jul 2022 13:53:06 -0700
Delete easy things
Diffstat:
4 files changed, 0 insertions(+), 163 deletions(-)
diff --git a/app/app.go b/app/app.go
@@ -1,6 +0,0 @@
-package app
-
-const (
- Name = "circumflex"
- Version = "2.3-dev"
-)
diff --git a/constants/category/category.go b/constants/category/category.go
@@ -1,10 +0,0 @@
-package category
-
-const (
- FrontPage = 0
- New = 1
- Ask = 2
- Show = 3
- Favorites = 4
- Buffer = 5
-)
diff --git a/endpoints/endpoints.go b/endpoints/endpoints.go
@@ -1,90 +0,0 @@
-package endpoints
-
-import "time"
-
-type Story struct {
- ID int `json:"id"`
- Title string `json:"title"`
- Points int `json:"points"`
- Author string `json:"user"`
- Time int64 `json:"time"`
- CommentsCount int `json:"comments_count"`
- URL string `json:"url"`
- Domain string `json:"domain"`
- Type string `json:"type"`
-}
-
-type HN struct {
- By string `json:"by"`
- Descendants int `json:"descendants"`
- Id int `json:"id"`
- Kids []int `json:"kids"`
- Score int `json:"score"`
- Time int `json:"time"`
- Title string `json:"title"`
- Type string `json:"type"`
- Url string `json:"url"`
-}
-
-type Comments struct {
- ID int `json:"id"`
- Title string `json:"title"`
- Points int `json:"points"`
- User string `json:"user"`
- Time int64 `json:"time"`
- TimeAgo string `json:"time_ago"`
- Type string `json:"type"`
- URL string `json:"url"`
- Level int `json:"level"`
- Domain string `json:"domain"`
- Comments []Comments `json:"comments"`
- Content string `json:"content"`
- CommentsCount int `json:"comments_count"`
-}
-
-type Algolia struct {
- Hits []struct {
- CreatedAt time.Time `json:"created_at"`
- Title string `json:"title"`
- URL string `json:"url"`
- Author string `json:"author"`
- Points int `json:"points"`
- StoryText interface{} `json:"story_text"`
- CommentText interface{} `json:"comment_text"`
- NumComments int `json:"num_comments"`
- StoryID interface{} `json:"story_id"`
- StoryTitle interface{} `json:"story_title"`
- StoryURL interface{} `json:"story_url"`
- ParentID interface{} `json:"parent_id"`
- CreatedAtI int `json:"created_at_i"`
- Tags []string `json:"_tags"`
- ObjectID string `json:"objectID"`
- HighlightResult struct {
- Title struct {
- Value string `json:"value"`
- MatchLevel string `json:"matchLevel"`
- MatchedWords []interface{} `json:"matchedWords"`
- } `json:"title"`
- URL struct {
- Value string `json:"value"`
- MatchLevel string `json:"matchLevel"`
- MatchedWords []interface{} `json:"matchedWords"`
- } `json:"url"`
- Author struct {
- Value string `json:"value"`
- MatchLevel string `json:"matchLevel"`
- MatchedWords []interface{} `json:"matchedWords"`
- } `json:"author"`
- } `json:"_highlightResult"`
- } `json:"hits"`
- NbHits int `json:"nbHits"`
- Page int `json:"page"`
- NbPages int `json:"nbPages"`
- HitsPerPage int `json:"hitsPerPage"`
- ExhaustiveNbHits bool `json:"exhaustiveNbHits"`
- ExhaustiveTypo bool `json:"exhaustiveTypo"`
- Query string `json:"query"`
- Params string `json:"params"`
- RenderingContent struct{} `json:"renderingContent"`
- ProcessingTimeMS int `json:"processingTimeMS"`
-}
diff --git a/utils/http/fetcher.go b/utils/http/fetcher.go
@@ -1,57 +0,0 @@
-package http
-
-import (
- "fmt"
- "strconv"
- "time"
-
- "git.figbert.com/clx-browser/app"
- "git.figbert.com/clx-browser/constants/category"
- "git.figbert.com/clx-browser/endpoints"
-
- "github.com/go-resty/resty/v2"
-)
-
-const (
- baseURL = "http://api.hackerwebapp.com/"
- page = "?page="
-)
-
-func FetchStories(page int, category int) ([]*endpoints.Story, error) {
- url := getURL(category)
- p := strconv.Itoa(page)
-
- var s []*endpoints.Story
-
- client := resty.New()
- client.SetTimeout(5 * time.Second)
-
- _, err := client.R().
- SetHeader("User-Agent", app.Name+"/"+app.Version).
- SetResult(&s).
- Get(url + p)
- if err != nil {
- return nil, fmt.Errorf("could not fetch stories: %w", err)
- }
-
- return s, nil
-}
-
-func getURL(cat int) string {
- switch cat {
- case category.FrontPage:
- return baseURL + "news" + page
-
- case category.New:
- return baseURL + "newest" + page
-
- case category.Ask:
- return baseURL + "ask" + page
-
- case category.Show:
- return baseURL + "show" + page
-
- default:
- return ""
- }
-}