decap

package module
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

README

= Decap

== Build

=== Prerequisites (developer laptop)

* https://go.dev/doc/install[Go compiler] (go1.18 or above)
* Docker (18.06 or above)

=== On laptop

[source,shell]
$ go build ./cmd/...
$ docker-compose build

== Run locally

[source,shell]
$ ./decap

or via Docker

[source,shell]
$ docker-compose up -d

== Deploy

=== Prerequisites (deployment server)

* Docker (18.06 or above)
* Variant of docker-compose.yml configured for deployment (and without build
  steps)
** If there are multiple configurations, the filename should match the
   deployment host

=== On laptop

[source,shell]
$ docker login <docker registry>
$ docker-compose push

=== On server

_(Perform docker login like above if needed.)_

[source,shell]
$ cd <main repo root>/conf/decap
$ docker-compose -f docker-compose-<hostname>.yml pull
$ docker-compose -f docker-compose-<hostname>.yml up -d

== Maintenance and other arcana

=== Update Decap dependencies to the newest version

[source,shell]
$ go get -u github.com/chromedp/chromedp

=== Bypass Docker registry when deploying image to server

When performing rapid successive Decap deployments using different Chromium
binaries, we can avoid polluting the Docker registry with hundreds of megabytes
of additional binary blobs by using `docker save` and `docker load`.

==== On laptop (-> remote host)

[source,shell]
$ docker save <docker registry>/decap:latest | ssh <remote host> docker load

==== On remote jump host (-> production host)

[source,shell]
$ docker save <docker registry>/decap:latest | ssh <more remote host> docker load

Documentation

Index

Constants

View Source
const (
	MaxRenderDelay = 10 * time.Second
	MaxTimeout     = 120 * time.Second
)

Variables

View Source
var (
	DefaultPageloadEvents = []string{
		"DOMContentLoaded",
		"firstMeaningfulPaint",
		"load",
		"networkAlmostIdle",
	}
)

Functions

func AllocateSessions

func AllocateSessions()

Types

type Action

type Action []string

func NewAction

func NewAction(list ...string) Action

func (Action) Arg

func (xa Action) Arg(n int) string

func (Action) Args

func (xa Action) Args() []string

func (Action) MustArgCount

func (xa Action) MustArgCount(ns ...int) error

func (Action) MustBeNonEmpty

func (xa Action) MustBeNonEmpty() error

func (Action) Name

func (xa Action) Name() string

func (Action) NamedArgs

func (xa Action) NamedArgs(offset int) (map[string]string, error)

type QueryBlock

type QueryBlock struct {
	Actions []Action `json:"actions"`
	Repeat  *int     `json:"repeat"`
	While   *Action  `json:"while"`
	// contains filtered or unexported fields
}

type Request

type Request struct {
	Query            []*QueryBlock  `json:"query"`
	EmulateViewport  *ViewportBlock `json:"emulate_viewport"`
	ForwardUserAgent bool           `json:"forward_user_agent"`
	RenderDelay      string         `json:"global_render_delay"`
	ReuseTab         bool           `json:"reuse_tab"`
	ReuseWindow      bool           `json:"reuse_window"`
	SessionID        string         `json:"sessionid"`
	Timeout          string         `json:"timeout"`
	// contains filtered or unexported fields
}

func (*Request) Execute

func (r *Request) Execute() (*Result, error)

func (*Request) ParseRequest

func (r *Request) ParseRequest(body io.Reader) error

type Result

type Result struct {
	Err      []string   `json:"err"`
	Out      [][]string `json:"out"`
	TabID    string     `json:"tab_id"`
	WindowID string     `json:"window_id"`
	// contains filtered or unexported fields
}

func (*Result) ImgBuffer

func (res *Result) ImgBuffer() []byte

func (*Result) PDFBuffer added in v0.15.2

func (res *Result) PDFBuffer() []byte

func (*Result) Type

func (res *Result) Type() string

type ViewportBlock added in v0.15.0

type ViewportBlock struct {
	Width       int      `json:"width"`
	Height      int      `json:"height"`
	Orientation *string  `json:"orientation"`
	Mobile      bool     `json:"mobile"`
	Scale       *float64 `json:"scale"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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