core

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_ETC_PATH        = "/etc/girie"
	DEFAULT_LOG_TIME_FORMAT = "02.01.2006 15:04:05.000"
	DEFAULT_LISTEN          = ":8080"
	DEFAULT_PROXY           = ""
	DEFAULT_RETRY           = 2
	DEFAULT_SPAN_THRESHOLD  = 10
	DEFAULT_TIMEOUT         = 10

	LOG_CONFIG_ERROR = "config error"

	VIPER_DEFAULT_LISTEN     = "default.listen"
	VIPER_DEFAULT_PROXY      = "default.proxy"
	VIPER_DEFAULT_RETRY      = "default.retry"
	VIPER_DEFAULT_TIMEOUT    = "default.timeout"
	VIPER_DEFAULT_USER_AGENT = "default.user_agent"

	VIPER_ENV_LISTEN     = "listen"
	VIPER_ENV_PROXY      = "proxy"
	VIPER_ENV_RETRY      = "retry"
	VIPER_ENV_TIMEOUT    = "timeout"
	VIPER_ENV_USER_AGENT = "user_agent"
)

Variables

View Source
var (
	APP_NAME           = "girie"
	APP_VERSION        = "devel"
	DEFAULT_USER_AGENT = APP_NAME + " " + APP_VERSION
)
View Source
var Schema, _ = graphql.NewSchema(graphql.SchemaConfig{
	Query: rootQuery,
})

Functions

func ExtractJSONLd

func ExtractJSONLd(html string) string

func ExtractLang

func ExtractLang(html string) string

func ExtractMicrodata

func ExtractMicrodata(html string, url string) string

func ExtractOpengraph

func ExtractOpengraph(html string) string

func ExtractRDFA

func ExtractRDFA(html string) string

func ExtractTitle

func ExtractTitle(html string) string

func FetchPage

func FetchPage(url, proxy string, retry, timeout int, userAgent string) (string, error)

func GetArguments

func GetArguments(query string) (string, string, error)

func GetConfig

func GetConfig() *viper.Viper

func GetInt

func GetInt(v string, d int) int

func SanitizeHTMLTags

func SanitizeHTMLTags(html string) string

Types

type Article

type Article struct {
	HTML      string   `json:"html"`
	Images    []string `json:"images"`
	Text      string   `json:"text"`
	TextSpans []string `json:"text_spans"`
}

type Data

type Data struct {
	HTML string `json:"html"`
	URL  string `json:"url"`

	JsonLd    string `json:"jsonld"`
	Microdata string `json:"microdata"`
	Opengraph string `json:"opengraph"`
	Rdfa      string `json:"rdfa"`
	Title     string `json:"title"`

	Article Article `json:"article"`
	Page    Page    `json:"page"`
}

type Error

type Error struct {
	Code        int
	Description string
	Error       interface{}
}

type Image

type Image struct {
	Alt    string `json:"alt"`
	Height int    `json:"height"`
	Src    string `json:"src"`
	Width  int    `json:"width"`
}

func ExtractImages

func ExtractImages(html string) []Image

type InputData

type InputData struct {
	Query     string                 `json:"query"`
	Operation string                 `json:"operation"`
	Variables map[string]interface{} `json:"variables"`
}

type Page

type Page struct {
	HTML   string   `json:"html"`
	Images []string `json:"images"`
	Lang   string   `json:"lang"`
	Text   string   `json:"text"`
}

type TextSpan

type TextSpan struct {
	Lang         string `json:"lang"`
	Text         string `json:"text"`
	TokensAmount int    `json:"tokens_amount"`
}

func GetTextSpan

func GetTextSpan(s *string) *TextSpan

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL