mirror of
https://github.com/unidoc/unihtml.git
synced 2025-04-24 13:48:52 +08:00
Merge pull request #2 from unidoc-build/prep-rc-v0.2.0
Prepare release UniHTML 0.2.0
This commit is contained in:
commit
eafca2ed61
File diff suppressed because one or more lines are too long
@ -9,4 +9,4 @@
|
||||
// Use of this source code is governed by the UniDoc End User License Agreement
|
||||
// terms that can be accessed at https://unidoc.io/eula/
|
||||
|
||||
package main ;import _a "github.com/unidoc/unihtml/cli/cmd";func main (){_a .Execute ()};
|
||||
package main ;import _g "github.com/unidoc/unihtml/cli/cmd";func main (){_g .Execute ()};
|
220
client/client.go
220
client/client.go
@ -11,135 +11,163 @@
|
||||
|
||||
// Package client contains HTML Converter HTTP Client. The Client implements htmlcreator.HTMLConverter interface
|
||||
// for the UniPDF module and can be used as a plugin for the UniPDF creator.Creator.
|
||||
package client ;import (_ec "bytes";_e "context";_g "errors";_ge "fmt";_gfc "github.com/unidoc/unihtml/content";_ecf "github.com/unidoc/unihtml/sizes";_ag "github.com/unidoc/unipdf/v3/common";_f "golang.org/x/xerrors";_a "io/ioutil";_df "net";_gf "net/http";_b "net/url";_dc "strconv";_ee "strings";_gc "time";);
|
||||
package client ;import (_dc "bytes";_d "compress/flate";_f "compress/gzip";_bc "context";_aa "errors";_dcd "fmt";_da "github.com/unidoc/unihtml/content";_fa "github.com/unidoc/unihtml/sizes";_e "github.com/unidoc/unipdf/v3/common";_ff "golang.org/x/xerrors";
|
||||
_a "io/ioutil";_g "net";_ba "net/http";_cc "net/url";_bcb "strconv";_ae "strings";_c "time";);
|
||||
|
||||
// ConvertHTML converts provided Query input into PDF file data.
|
||||
// Implements creator.HTMLConverter interface.
|
||||
func (_ca *Client )ConvertHTML (ctx _e .Context ,q *Query )(*PDFResponse ,error ){if _ae :=q .Validate ();_ae !=nil {return nil ,_ae ;};_ab ,_cc :=_ca .getRequest (ctx ,q );if _cc !=nil {return nil ,_cc ;};_ag .Log .Trace ("\u0052\u0065\u0071\u0075\u0065\u0073\u0074 \u002d\u0020\u0025s\u0020\u002d\u0020\u0025s\u0025\u0073\u002c\u0020\u0048\u0065\u0061\u0064\u0065\u0072\u0073\u003a\u0020\u0025\u0076\u002c\u0020\u0051\u0075\u0065\u0072\u0079\u003a\u0020\u0025\u0076",_ab .Method ,_ab .URL .Hostname (),_ab .URL .Path ,_ab .Header ,_ab .URL .Query ());_dd ,_cc :=_ca .Client .Do (_ab );if _cc !=nil {return nil ,_cc ;};var _fa error ;switch _dd .StatusCode {case _gf .StatusNotFound :_fa =ErrNotFound ;case _gf .StatusBadRequest :_fa =ErrBadRequest ;case _gf .StatusNotImplemented :_fa =ErrNotImplemented ;case _gf .StatusCreated :default:_fa =ErrInternalError ;};_bcc ,_cc :=_a .ReadAll (_dd .Body );if _cc !=nil &&_fa ==nil {return nil ,_cc ;};_ag .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_dd .StatusCode ,_ab .Method ,_ab .URL .Host ,_ab .URL .Path );if _fa !=nil {return nil ,_ge .Errorf ("\u0025\u0073\u0020%\u0077",string (_bcc ),_fa );};_fab :=_dd .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_ag .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_fab );return &PDFResponse {ID :_fab ,Data :_bcc },nil ;};
|
||||
// Landscape sets up the landscape portrait orientation.
|
||||
func (_ab *QueryBuilder )Landscape ()*QueryBuilder {_ab ._cea .PageParameters .Orientation =_fa .Landscape ;return _ab ;};
|
||||
|
||||
// Orientation sets the page orientation for the Query.
|
||||
func (_bgg *QueryBuilder )Orientation (orientation _fa .Orientation )*QueryBuilder {_bgg ._cea .PageParameters .Orientation =orientation ;return _bgg ;};
|
||||
|
||||
// PDFResponse is the response used by the HTMLConverter.
|
||||
type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;};
|
||||
|
||||
// New creates new client with provided options.
|
||||
func New (o Options )*Client {o .DefaultTimeout =_gc .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _ce =&_gf .Transport {DialContext :(&_df .Dialer {Timeout :5*_gc .Second }).DialContext ,TLSHandshakeTimeout :5*_gc .Second };_ag .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_gf .Client {Transport :_ce ,Timeout :o .DefaultTimeout }};};
|
||||
func New (o Options )*Client {o .DefaultTimeout =_c .Second *30;if o .Port <=0{o .Port =8080;};if o .Hostname ==""{o .Hostname ="\u00312\u0037\u002e\u0030\u002e\u0030\u002e1";};var _bad =&_ba .Transport {DialContext :(&_g .Dialer {Timeout :5*_c .Second }).DialContext ,TLSHandshakeTimeout :5*_c .Second };
|
||||
_e .Log .Info ("\u0043l\u0069e\u006e\u0074\u0020\u0041\u0064\u0064\u0072\u003a\u0020\u0025\u0073",o .Addr ());return &Client {Options :o ,Client :&_ba .Client {Transport :_bad ,Timeout :o .DefaultTimeout }};};
|
||||
|
||||
// PaperHeight sets up the PaperHeight (in cm) parameter for the query.
|
||||
func (_bf *QueryBuilder )PaperHeight (paperHeight _ecf .Length )*QueryBuilder {_bf ._gd .PageParameters .PaperHeight =paperHeight ;return _bf ;};
|
||||
// ParseOptions parses options for the Client.
|
||||
func ParseOptions (connectPath string )(Options ,error ){if !_ae .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_aeg ,_ee :=_cc .Parse (connectPath );if _ee !=nil {return Options {},_ff .Errorf ("p\u0072\u006f\u0076\u0069\u0064\u0065d\u0020\u0069\u006e\u0076\u0061\u006ci\u0064\u0020\u0075\u006e\u0069\u0068\u0074m\u006c\u002d\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0075r\u006c");
|
||||
};var _af int ;if _aeg .Port ()!=""{_af ,_ee =_bcb .Atoi (_aeg .Port ());if _ee !=nil {return Options {},_ff .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_ee );
|
||||
};};return Options {Hostname :_aeg .Hostname (),Port :_af ,HTTPS :_aeg .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_aeg .Path },nil ;};
|
||||
|
||||
// Err gets the error which could occur in the query.
|
||||
func (_ecfg *QueryBuilder )Err ()error {return _ecfg ._eec };
|
||||
|
||||
// MarginTop sets up the MarginTop parameter for the query.
|
||||
func (_geb *QueryBuilder )MarginTop (marginTop _ecf .Length )*QueryBuilder {_geb ._gd .PageParameters .MarginTop =marginTop ;return _geb ;};
|
||||
// WithPrefix sets the client prefix.
|
||||
func WithPrefix (prefix string )Option {return func (_be *Options ){_be .Prefix =prefix }};
|
||||
|
||||
// BuildHTMLQuery creates a Query builder that is supposed to create valid
|
||||
func BuildHTMLQuery ()*QueryBuilder {return &QueryBuilder {}};
|
||||
|
||||
// MarginBottom sets up the MarginBottom parameter for the query.
|
||||
func (_dg *QueryBuilder )MarginBottom (marginBottom _ecf .Length )*QueryBuilder {_dg ._gd .PageParameters .MarginBottom =marginBottom ;return _dg ;};
|
||||
// QueryBuilder is the query that converts HTMLConverter defined data
|
||||
type QueryBuilder struct{_cea Query ;_bf error ;};var (ErrNotFound =_aa .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed");ErrBadRequest =_aa .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");ErrNotImplemented =_aa .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064");
|
||||
ErrInternalError =_aa .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072");ErrBadGateway =_aa .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079"););
|
||||
|
||||
// Err gets the error which could occur in the query.
|
||||
func (_fg *QueryBuilder )Err ()error {return _fg ._bf };
|
||||
|
||||
// MarginRight sets up the MarginRight parameter for the query.
|
||||
func (_baae *QueryBuilder )MarginRight (marginRight _fa .Length )*QueryBuilder {_baae ._cea .PageParameters .MarginRight =marginRight ;return _baae ;};
|
||||
|
||||
// SetContent sets custom data with it's content type.
|
||||
func (_ad *QueryBuilder )SetContent (content _da .Content )*QueryBuilder {if _ad ._bf !=nil {return _ad ;};if _ad ._cea .ContentType !=""{_ad ._bf =ErrContentTypeDeclared ;return _ad ;};if content .ContentType ()==""{_ad ._bf =_ff .Errorf ("\u0065\u006d\u0070\u0074y\u0020\u0063\u0075\u0073\u0074\u006f\u006d\u0020\u0063\u006fn\u0074e\u006e\u0074\u0020\u0074\u0079\u0070\u0065 \u0025\u0077",ErrContentType );
|
||||
return _ad ;};_ad ._cea .Data =content .Data ();_ad ._cea .ContentType =content .ContentType ();return _ad ;};
|
||||
|
||||
// PaperWidth sets up the PaperWidth (in cm) parameter for the query.
|
||||
func (_de *QueryBuilder )PaperWidth (paperWidth _fa .Length )*QueryBuilder {_de ._cea .PageParameters .PaperWidth =paperWidth ;return _de ;};
|
||||
|
||||
// PageSize sets up the PageSize parameter for the query.
|
||||
func (_gb *QueryBuilder )PageSize (pageSize _ecf .PageSize )*QueryBuilder {_gb ._gd .PageParameters .PageSize =&pageSize ;return _gb ;};
|
||||
func (_df *QueryBuilder )PageSize (pageSize _fa .PageSize )*QueryBuilder {if pageSize !=_fa .Undefined {_df ._cea .PageParameters .PageSize =&pageSize ;};return _df ;};
|
||||
|
||||
// Validate checks if the parameters are valid.
|
||||
func (_eg *PageParameters )Validate ()error {if _eg .PaperWidth !=nil {if _eg .PaperWidth .Millimeters ()< 0{return _aa .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u0050\u0061\u0070\u0065\u0072\u0057id\u0074\u0068");
|
||||
};};if _eg .PaperHeight !=nil {if _eg .PaperHeight .Millimeters ()< 0{return _aa .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u0050\u0061\u0070\u0065\u0072\u0048\u0065\u0069\u0067\u0068\u0074");
|
||||
};};if _eg .MarginTop !=nil {if _eg .MarginTop .Millimeters ()< 0{return _aa .New ("\u006e\u0065\u0067\u0061t\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020f\u006fr\u0020\u004d\u0061\u0072\u0067\u0069\u006eT\u006f\u0070");};};if _eg .MarginBottom !=nil {if _eg .MarginBottom .Millimeters ()< 0{return _aa .New ("\u006e\u0065\u0067a\u0074\u0069\u0076\u0065 \u0076\u0061\u006c\u0075\u0065\u0020\u0066o\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006e\u0042\u006f\u0074\u0074\u006f\u006d");
|
||||
};};if _eg .MarginLeft !=nil {if _eg .MarginLeft .Millimeters ()< 0{return _aa .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006eLe\u0066\u0074");};};
|
||||
if _eg .MarginRight !=nil {if _eg .MarginRight .Millimeters ()< 0{return _aa .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u004d\u0061\u0072\u0067\u0069\u006e\u0052\u0069\u0067\u0068\u0074");
|
||||
};};if _eg .PageSize !=nil &&!_eg .PageSize .IsAPageSize (){return _aa .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;};
|
||||
|
||||
// ConvertHTML converts provided Query input into PDF file data.
|
||||
// Implements creator.HTMLConverter interface.
|
||||
func (_ce *Client )ConvertHTML (ctx _bc .Context ,q *Query )(*PDFResponse ,error ){if _cb :=q .Validate ();_cb !=nil {return nil ,_cb ;};_bb ,_bg :=_ce .getRequest (ctx ,q );if _bg !=nil {return nil ,_bg ;};_e .Log .Trace ("\u0052\u0065\u0071\u0075\u0065\u0073\u0074 \u002d\u0020\u0025s\u0020\u002d\u0020\u0025s\u0025\u0073\u002c\u0020\u0048\u0065\u0061\u0064\u0065\u0072\u0073\u003a\u0020\u0025\u0076\u002c\u0020\u0051\u0075\u0065\u0072\u0079\u003a\u0020\u0025\u0076",_bb .Method ,_bb .URL .Hostname (),_bb .URL .Path ,_bb .Header ,_bb .URL .Query ());
|
||||
_ea ,_bg :=_ce .Client .Do (_bb );if _bg !=nil {return nil ,_bg ;};var _dcc error ;switch _ea .StatusCode {case _ba .StatusNotFound :_dcc =ErrNotFound ;case _ba .StatusBadRequest :_dcc =ErrBadRequest ;case _ba .StatusNotImplemented :_dcc =ErrNotImplemented ;
|
||||
case _ba .StatusCreated :default:_dcc =ErrInternalError ;};_gg :=_ea .Body ;switch _ea .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"){case "\u0067\u007a\u0069\u0070":_gg ,_bg =_f .NewReader (_ea .Body );
|
||||
if _bg !=nil {return nil ,_bg ;};case "\u0064e\u0066\u006c\u0061\u0074\u0065":_gg =_d .NewReader (_ea .Body );case "":default:return nil ,_dcd .Errorf ("\u0075\u006e\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0064\u0020\u0043o\u006e\u0074\u0065\u006e\u0074\u002dE\u006e\u0063\u006f\u0064\u0069\u006e\u0067\u003a\u0020\u0025\u0073\u0020\u0068e\u0061\u0064\u0065\u0072",_ea .Header .Get ("\u0043\u006fn\u0074\u0065\u006et\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067"));
|
||||
};_dcg ,_bg :=_a .ReadAll (_gg );if _bg !=nil &&_dcc ==nil {return nil ,_bg ;};_e .Log .Trace ("\u005b\u0025\u0064]\u0020\u0025\u0073\u0020\u0025\u0073\u0025\u0073",_ea .StatusCode ,_bb .Method ,_bb .URL .Host ,_bb .URL .Path );if _dcc !=nil {return nil ,_dcd .Errorf ("\u0025\u0073\u0020%\u0077",string (_dcg ),_dcc );
|
||||
};_dg :=_ea .Header .Get ("\u0058\u002d\u004a\u006f\u0062\u002d\u0049\u0044");_e .Log .Trace ("\u0052\u0065\u0073\u0070\u006f\u006e\u0073\u0065\u0020I\u0044\u0020\u0025\u0073",_dg );return &PDFResponse {ID :_dg ,Data :_dcg },nil ;};var (ErrMissingData =_aa .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061");
|
||||
ErrContentType =_aa .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065");ErrContentTypeDeclared =_aa .New ("\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u0020\u0074\u0079\u0070\u0065\u0020\u0069\u0073 \u0061l\u0072\u0065\u0061\u0064\u0079\u0020\u0064\u0065\u0063\u006c\u0061\u0072\u0065\u0064");
|
||||
);
|
||||
|
||||
// HealthCheck connects to the server and check the health status of the server.
|
||||
func (_ac *Client )HealthCheck (ctx _bc .Context )error {_dca :=_ac .Options .Addr ();_dca =_dcd .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_dca );_ag ,_bd :=_ba .NewRequest ("\u0047\u0045\u0054",_dca ,nil );if _bd !=nil {return _bd ;};_ag =_ag .WithContext (ctx );
|
||||
_cf ,_bd :=_ac .Client .Do (_ag );if _bd !=nil {return _bd ;};switch _cf .StatusCode {case _ba .StatusOK :return nil ;case _ba .StatusNotFound :return ErrNotFound ;case _ba .StatusInternalServerError :return ErrInternalError ;case _ba .StatusBadGateway :return ErrBadGateway ;
|
||||
default:return ErrNotImplemented ;};};
|
||||
|
||||
// WithHostname sets the Hostname option for the client options.
|
||||
func WithHostname (option string )Option {return func (_afb *Options ){_afb .Hostname =option }};
|
||||
|
||||
// Validate checks if the QueryBuilder had no errors during composition and creation.
|
||||
func (_aab *QueryBuilder )Validate ()error {if _aab ._bf !=nil {return _aab ._bf ;};return _aab ._cea .Validate ();};
|
||||
|
||||
// Addr gets the HTTP address URI used by the http.Client.
|
||||
func (_fe *Options )Addr ()string {_dce :=_ae .Builder {};_dce .WriteString ("\u0068\u0074\u0074\u0070");if _fe .HTTPS {_dce .WriteRune ('s');};_dce .WriteString ("\u003a\u002f\u002f");_dce .WriteString (_fe .Hostname );_dce .WriteRune (':');_dce .WriteString (_bcb .Itoa (_fe .Port ));
|
||||
if _fe .Prefix !=""{_dce .WriteString (_fe .Prefix );};return _dce .String ();};
|
||||
|
||||
// WithPort sets the Port option for the client options.
|
||||
func WithPort (option int )Option {return func (_ggg *Options ){_ggg .Port =option }};
|
||||
|
||||
// MarginTop sets up the MarginTop parameter for the query.
|
||||
func (_ead *QueryBuilder )MarginTop (marginTop _fa .Length )*QueryBuilder {_ead ._cea .PageParameters .MarginTop =marginTop ;return _ead ;};
|
||||
|
||||
// MarginLeft sets up the MarginLeft parameter for the query.
|
||||
func (_eb *QueryBuilder )MarginLeft (marginLeft _fa .Length )*QueryBuilder {_eb ._cea .PageParameters .MarginLeft =marginLeft ;return _eb ;};
|
||||
|
||||
// Query gets the Query from provided query builder. If some error occurred during build process
|
||||
// or the input is not valid the function would return an error.
|
||||
func (_bce *QueryBuilder )Query ()(*Query ,error ){if _ceg :=_bce .Validate ();_ceg !=nil {return nil ,_ceg ;};return &_bce ._gd ,nil ;};
|
||||
|
||||
// PaperWidth sets up the PaperWidth (in cm) parameter for the query.
|
||||
func (_fabd *QueryBuilder )PaperWidth (paperWidth _ecf .Length )*QueryBuilder {_fabd ._gd .PageParameters .PaperWidth =paperWidth ;return _fabd ;};var (ErrNotFound =_g .New ("\u006eo\u0074\u0020\u0066\u006f\u0075\u006ed");ErrBadRequest =_g .New ("b\u0061\u0064\u0020\u0072\u0065\u0071\u0075\u0065\u0073\u0074");ErrNotImplemented =_g .New ("\u006eo\u0074 \u0069\u006d\u0070\u006c\u0065\u006d\u0065\u006e\u0074\u0065\u0064");ErrInternalError =_g .New ("i\u006e\u0074\u0065\u0072na\u006c \u0073\u0065\u0072\u0076\u0065r\u0020\u0065\u0072\u0072\u006f\u0072");ErrBadGateway =_g .New ("b\u0061\u0064\u0020\u0067\u0061\u0074\u0065\u0077\u0061\u0079"););
|
||||
|
||||
// ParseOptions parses options for the Client.
|
||||
func ParseOptions (connectPath string )(Options ,error ){if !_ee .HasPrefix (connectPath ,"\u0068\u0074\u0074\u0070"){connectPath ="\u0068t\u0074\u0070\u003a\u002f\u002f"+connectPath ;};_c ,_cb :=_b .Parse (connectPath );if _cb !=nil {return Options {},_f .Errorf ("p\u0072\u006f\u0076\u0069\u0064\u0065d\u0020\u0069\u006e\u0076\u0061\u006ci\u0064\u0020\u0075\u006e\u0069\u0068\u0074m\u006c\u002d\u0073\u0065\u0072\u0076\u0065\u0072\u0020\u0075r\u006c");};var _fg int ;if _c .Port ()!=""{_fg ,_cb =_dc .Atoi (_c .Port ());if _cb !=nil {return Options {},_f .Errorf ("\u0070\u0061\u0072si\u006e\u0067\u0020\u0070\u006f\u0072\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_cb );};};return Options {Hostname :_c .Hostname (),Port :_fg ,HTTPS :_c .Scheme =="\u0068\u0074\u0074p\u0073",Prefix :_c .Path },nil ;};
|
||||
|
||||
// HealthCheck connects to the server and check the health status of the server.
|
||||
func (_be *Client )HealthCheck (ctx _e .Context )error {_de :=_be .Options .Addr ();_de =_ge .Sprintf ("\u0025s\u002f\u0068\u0065\u0061\u006c\u0074h",_de );_aa ,_gca :=_gf .NewRequest ("\u0047\u0045\u0054",_de ,nil );if _gca !=nil {return _gca ;};_aa =_aa .WithContext (ctx );_bc ,_gca :=_be .Client .Do (_aa );if _gca !=nil {return _gca ;};switch _bc .StatusCode {case _gf .StatusOK :return nil ;case _gf .StatusNotFound :return ErrNotFound ;case _gf .StatusInternalServerError :return ErrInternalError ;case _gf .StatusBadGateway :return ErrBadGateway ;default:return ErrNotImplemented ;};};
|
||||
|
||||
// WithPort sets the Port option for the client options.
|
||||
func WithPort (option int )Option {return func (_da *Options ){_da .Port =option }};
|
||||
|
||||
// Addr gets the HTTP address URI used by the http.Client.
|
||||
func (_ac *Options )Addr ()string {_efc :=_ee .Builder {};_efc .WriteString ("\u0068\u0074\u0074\u0070");if _ac .HTTPS {_efc .WriteRune ('s');};_efc .WriteString ("\u003a\u002f\u002f");_efc .WriteString (_ac .Hostname );_efc .WriteRune (':');_efc .WriteString (_dc .Itoa (_ac .Port ));if _ac .Prefix !=""{_efc .WriteString (_ac .Prefix );};return _efc .String ();};
|
||||
|
||||
// Orientation sets the page orientation for the Query.
|
||||
func (_fgb *QueryBuilder )Orientation (orientation _ecf .Orientation )*QueryBuilder {_fgb ._gd .PageParameters .Orientation =orientation ;return _fgb ;};
|
||||
|
||||
// Validate checks if the QueryBuilder had no errors during composition and creation.
|
||||
func (_baf *QueryBuilder )Validate ()error {if _baf ._eec !=nil {return _baf ._eec ;};return _baf ._gd .Validate ();};var (ErrMissingData =_g .New ("\u006di\u0073s\u0069\u006e\u0067\u0020\u0069n\u0070\u0075t\u0020\u0064\u0061\u0074\u0061");ErrContentType =_g .New ("i\u006ev\u0061\u006c\u0069\u0064\u0020\u0063\u006f\u006et\u0065\u006e\u0074\u0020ty\u0070\u0065");ErrContentTypeDeclared =_g .New ("\u0063\u006f\u006e\u0074\u0065\u006e\u0074\u0020\u0074\u0079\u0070\u0065\u0020\u0069\u0073 \u0061l\u0072\u0065\u0061\u0064\u0079\u0020\u0064\u0065\u0063\u006c\u0061\u0072\u0065\u0064"););
|
||||
|
||||
// Client is a structure that is a HTTP client for the unihtml server.
|
||||
type Client struct{Options Options ;Client *_gf .Client ;};
|
||||
|
||||
// Query is a structure that contains query parameters and the content used for the HTMLConverter conversion process.
|
||||
type Query struct{Data []byte ;ContentType string ;PageParameters PageParameters ;};
|
||||
|
||||
// Landscape sets up the landscape portrait orientation.
|
||||
func (_db *QueryBuilder )Landscape ()*QueryBuilder {_db ._gd .PageParameters .Orientation =_ecf .Landscape ;return _db ;};
|
||||
|
||||
// Option is a function that changes client options.
|
||||
type Option func (_cf *Options );func (_ba *Client )getRequest (_eb _e .Context ,_ef *Query )(*_gf .Request ,error ){_cd :=_ba .Options .Addr ();_cd =_ge .Sprintf ("\u0025\u0073\u002f\u0070\u0064\u0066",_cd );_fd ,_fdb :=_gf .NewRequest ("\u0050\u004f\u0053\u0054",_cd ,_ec .NewReader (_ef .Data ));if _fdb !=nil {return nil ,_fdb ;};_fd .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065",_ef .ContentType );_fd =_fd .WithContext (_eb );_eba :=_fd .URL .Query ();_ccb :=_ef .PageParameters ;if _ccb .PageSize !=nil {_eba .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_ccb .PageSize .String ());};if _ccb .PaperHeight !=nil {_eba .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_ccb .PaperHeight .String ());};if _ccb .PaperWidth !=nil {_eba .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_ccb .PaperWidth .String ());};if _ccb .MarginTop !=nil {_eba .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_ccb .MarginTop .String ());};if _ccb .MarginBottom !=nil {_eba .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_ccb .MarginBottom .String ());};if _ccb .MarginRight !=nil {_eba .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_ccb .MarginRight .String ());};if _ccb .MarginLeft !=nil {_eba .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_ccb .MarginLeft .String ());};if _ccb .Orientation ==_ecf .Landscape {_eba .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_ccb .Orientation .String ());};_fd .URL .RawQuery =_eba .Encode ();return _fd ,nil ;};
|
||||
|
||||
// MarginLeft sets up the MarginLeft parameter for the query.
|
||||
func (_fb *QueryBuilder )MarginLeft (marginLeft _ecf .Length )*QueryBuilder {_fb ._gd .PageParameters .MarginLeft =marginLeft ;return _fb ;};
|
||||
|
||||
// WithHTTPS sets the TLS option for the client options.
|
||||
func WithHTTPS (useHTTPS bool )Option {return func (_bfd *Options ){_bfd .HTTPS =useHTTPS }};
|
||||
|
||||
// Options are the client options used by the HTTP client.
|
||||
type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _gc .Duration ;Prefix string ;};
|
||||
|
||||
// WithPrefix sets the client prefix.
|
||||
func WithPrefix (prefix string )Option {return func (_bea *Options ){_bea .Prefix =prefix }};
|
||||
func (_cd *QueryBuilder )Query ()(*Query ,error ){if _dcf :=_cd .Validate ();_dcf !=nil {return nil ,_dcf ;};return &_cd ._cea ,nil ;};func (_fb *Client )getRequest (_baa _bc .Context ,_dcgc *Query )(*_ba .Request ,error ){_bcc :=_fb .Options .Addr ();
|
||||
_bcc =_dcd .Sprintf ("\u0025\u0073\u002f\u0070\u0064\u0066",_bcc );_gf ,_ef :=_ba .NewRequest ("\u0050\u004f\u0053\u0054",_bcc ,_dc .NewReader (_dcgc .Data ));if _ef !=nil {return nil ,_ef ;};_gf .Header .Set ("\u0043\u006f\u006et\u0065\u006e\u0074\u002d\u0054\u0079\u0070\u0065",_dcgc .ContentType );
|
||||
_gf .Header .Set ("\u0041c\u0063e\u0070\u0074\u002d\u0045\u006e\u0063\u006f\u0064\u0069\u006e\u0067","\u0064\u0065\u0066\u006ca\u0074\u0065\u002c\u0020\u0067\u007a\u0069\u0070\u003b\u0071=\u0031.\u0030\u002c\u0020\u002a\u003b\u0071\u003d0\u002e\u0035");
|
||||
_gf =_gf .WithContext (_baa );_bga :=_gf .URL .Query ();_bbd :=_dcgc .PageParameters ;if _bbd .PageSize !=nil {_bga .Set ("\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae",_bbd .PageSize .String ());};if _bbd .PaperHeight !=nil {_bga .Set ("\u0070\u0061\u0070e\u0072\u002d\u0068\u0065\u0069\u0067\u0068\u0074",_bbd .PaperHeight .String ());
|
||||
};if _bbd .PaperWidth !=nil {_bga .Set ("p\u0061\u0070\u0065\u0072\u002d\u0077\u0069\u0064\u0074\u0068",_bbd .PaperWidth .String ());};if _bbd .MarginTop !=nil {_bga .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0074\u006f\u0070",_bbd .MarginTop .String ());
|
||||
};if _bbd .MarginBottom !=nil {_bga .Set ("\u006d\u0061\u0072\u0067\u0069\u006e\u002d\u0062\u006f\u0074\u0074\u006f\u006d",_bbd .MarginBottom .String ());};if _bbd .MarginRight !=nil {_bga .Set ("\u006d\u0061\u0072g\u0069\u006e\u002d\u0072\u0069\u0067\u0068\u0074",_bbd .MarginRight .String ());
|
||||
};if _bbd .MarginLeft !=nil {_bga .Set ("m\u0061\u0072\u0067\u0069\u006e\u002d\u006c\u0065\u0066\u0074",_bbd .MarginLeft .String ());};if _bbd .Orientation ==_fa .Landscape {_bga .Set ("o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e",_bbd .Orientation .String ());
|
||||
};_gf .URL .RawQuery =_bga .Encode ();return _gf ,nil ;};
|
||||
|
||||
// WithDefaultTimeout sets the DefaultTimeout option for the client options.
|
||||
func WithDefaultTimeout (option _gc .Duration )Option {return func (_caa *Options ){_caa .DefaultTimeout =option };};
|
||||
|
||||
// MarginRight sets up the MarginRight parameter for the query.
|
||||
func (_eef *QueryBuilder )MarginRight (marginRight _ecf .Length )*QueryBuilder {_eef ._gd .PageParameters .MarginRight =marginRight ;return _eef ;};
|
||||
|
||||
// Validate checks if provided Query is valid.
|
||||
func (_aad *Query )Validate ()error {if len (_aad .Data )==0{return ErrMissingData ;};if _aad .ContentType ==""{return ErrContentType ;};if _ga :=_aad .PageParameters .Validate ();_ga !=nil {return _ga ;};return nil ;};
|
||||
|
||||
// Portrait sets up the portrait page orientation.
|
||||
func (_bd *QueryBuilder )Portrait ()*QueryBuilder {_bd ._gd .PageParameters .Orientation =_ecf .Portrait ;return _bd ;};
|
||||
|
||||
// Validate checks if the parameters are valid.
|
||||
func (_fbb *PageParameters )Validate ()error {if _fbb .PaperWidth !=nil {if _fbb .PaperWidth .Millimeters ()< 0{return _g .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u0050\u0061\u0070\u0065\u0072\u0057id\u0074\u0068");};};if _fbb .PaperHeight !=nil {if _fbb .PaperHeight .Millimeters ()< 0{return _g .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u0050\u0061\u0070\u0065\u0072\u0048\u0065\u0069\u0067\u0068\u0074");};};if _fbb .MarginTop !=nil {if _fbb .MarginTop .Millimeters ()< 0{return _g .New ("\u006e\u0065\u0067\u0061t\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020f\u006fr\u0020\u004d\u0061\u0072\u0067\u0069\u006eT\u006f\u0070");};};if _fbb .MarginBottom !=nil {if _fbb .MarginBottom .Millimeters ()< 0{return _g .New ("\u006e\u0065\u0067a\u0074\u0069\u0076\u0065 \u0076\u0061\u006c\u0075\u0065\u0020\u0066o\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006e\u0042\u006f\u0074\u0074\u006f\u006d");};};if _fbb .MarginLeft !=nil {if _fbb .MarginLeft .Millimeters ()< 0{return _g .New ("\u006e\u0065g\u0061\u0074\u0069\u0076\u0065\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0066\u006f\u0072\u0020\u004d\u0061\u0072\u0067\u0069\u006eLe\u0066\u0074");};};if _fbb .MarginRight !=nil {if _fbb .MarginRight .Millimeters ()< 0{return _g .New ("\u006e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0076a\u006c\u0075\u0065\u0020\u0066\u006f\u0072 \u004d\u0061\u0072\u0067\u0069\u006e\u0052\u0069\u0067\u0068\u0074");};};if _fbb .PageSize !=nil &&!_fbb .PageSize .IsAPageSize (){return _g .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065 \u0073\u0069\u007a\u0065");};return nil ;};
|
||||
|
||||
// WithHostname sets the Hostname option for the client options.
|
||||
func WithHostname (option string )Option {return func (_deg *Options ){_deg .Hostname =option }};
|
||||
|
||||
// QueryBuilder is the query that converts HTMLConverter defined data
|
||||
type QueryBuilder struct{_gd Query ;_eec error ;};
|
||||
|
||||
// SetContent sets custom data with it's content type.
|
||||
func (_dbd *QueryBuilder )SetContent (content _gfc .Content )*QueryBuilder {if _dbd ._eec !=nil {return _dbd ;};if _dbd ._gd .ContentType !=""{_dbd ._eec =ErrContentTypeDeclared ;return _dbd ;};if content .ContentType ()==""{_dbd ._eec =_f .Errorf ("\u0065\u006d\u0070\u0074y\u0020\u0063\u0075\u0073\u0074\u006f\u006d\u0020\u0063\u006fn\u0074e\u006e\u0074\u0020\u0074\u0079\u0070\u0065 \u0025\u0077",ErrContentType );return _dbd ;};_dbd ._gd .Data =content .Data ();_dbd ._gd .ContentType =content .ContentType ();return _dbd ;};
|
||||
|
||||
// DefaultPageParameters creates default parameters.
|
||||
func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_ecf .Portrait }};
|
||||
func WithDefaultTimeout (option _c .Duration )Option {return func (_efd *Options ){_efd .DefaultTimeout =option };};
|
||||
|
||||
// PageParameters are the query parameters used in the PDF generation.
|
||||
type PageParameters struct{
|
||||
|
||||
// PaperWidth sets the width of the paper.
|
||||
PaperWidth _ecf .Length `schema:"paper-width" json:"paperWidth"`;
|
||||
PaperWidth _fa .Length `schema:"paper-width" json:"paperWidth"`;
|
||||
|
||||
// PaperHeight is the height of the output paper.
|
||||
PaperHeight _ecf .Length `schema:"paper-height" json:"paperHeight"`;
|
||||
PaperHeight _fa .Length `schema:"paper-height" json:"paperHeight"`;
|
||||
|
||||
// PageSize is the page size string.
|
||||
PageSize *_ecf .PageSize `schema:"page-size" json:"pageSize"`;
|
||||
PageSize *_fa .PageSize `schema:"page-size" json:"pageSize"`;
|
||||
|
||||
// Orientation defines if the output should be in a landscape format.
|
||||
Orientation _ecf .Orientation `schema:"orientation" json:"orientation"`;
|
||||
Orientation _fa .Orientation `schema:"orientation" json:"orientation"`;
|
||||
|
||||
// MarginTop sets up the Top Margin for the output.
|
||||
MarginTop _ecf .Length `schema:"margin-top" json:"marginTop"`;
|
||||
MarginTop _fa .Length `schema:"margin-top" json:"marginTop"`;
|
||||
|
||||
// MarginBottom sets up the Bottom Margin for the output.
|
||||
MarginBottom _ecf .Length `schema:"margin-bottom" json:"marginBottom"`;
|
||||
MarginBottom _fa .Length `schema:"margin-bottom" json:"marginBottom"`;
|
||||
|
||||
// MarginLeft sets up the Left Margin for the output.
|
||||
MarginLeft _ecf .Length `schema:"margin-left" json:"marginLeft"`;
|
||||
MarginLeft _fa .Length `schema:"margin-left" json:"marginLeft"`;
|
||||
|
||||
// MarginRight sets up the Right Margin for the output.
|
||||
MarginRight _ecf .Length `schema:"margin-right" json:"marginRight"`;};
|
||||
MarginRight _fa .Length `schema:"margin-right" json:"marginRight"`;};
|
||||
|
||||
// PDFResponse is the response used by the HTMLConverter.
|
||||
type PDFResponse struct{ID string `json:"id"`;Data []byte `json:"data"`;};
|
||||
// PaperHeight sets up the PaperHeight (in cm) parameter for the query.
|
||||
func (_cdc *QueryBuilder )PaperHeight (paperHeight _fa .Length )*QueryBuilder {_cdc ._cea .PageParameters .PaperHeight =paperHeight ;return _cdc ;};
|
||||
|
||||
// DefaultPageParameters creates default parameters.
|
||||
func DefaultPageParameters ()PageParameters {return PageParameters {Orientation :_fa .Portrait }};
|
||||
|
||||
// Query is a structure that contains query parameters and the content used for the HTMLConverter conversion process.
|
||||
type Query struct{Data []byte ;ContentType string ;PageParameters PageParameters ;};
|
||||
|
||||
// MarginBottom sets up the MarginBottom parameter for the query.
|
||||
func (_cbb *QueryBuilder )MarginBottom (marginBottom _fa .Length )*QueryBuilder {_cbb ._cea .PageParameters .MarginBottom =marginBottom ;return _cbb ;};
|
||||
|
||||
// Option is a function that changes client options.
|
||||
type Option func (_ffg *Options );
|
||||
|
||||
// WithHTTPS sets the TLS option for the client options.
|
||||
func WithHTTPS (useHTTPS bool )Option {return func (_cfe *Options ){_cfe .HTTPS =useHTTPS }};
|
||||
|
||||
// Client is a structure that is a HTTP client for the unihtml server.
|
||||
type Client struct{Options Options ;Client *_ba .Client ;};
|
||||
|
||||
// Validate checks if provided Query is valid.
|
||||
func (_acd *Query )Validate ()error {if len (_acd .Data )==0{return ErrMissingData ;};if _acd .ContentType ==""{return ErrContentType ;};if _baag :=_acd .PageParameters .Validate ();_baag !=nil {return _baag ;};return nil ;};
|
||||
|
||||
// Options are the client options used by the HTTP client.
|
||||
type Options struct{HTTPS bool ;Hostname string ;Port int ;DefaultTimeout _c .Duration ;Prefix string ;};
|
||||
|
||||
// Portrait sets up the portrait page orientation.
|
||||
func (_cfd *QueryBuilder )Portrait ()*QueryBuilder {_cfd ._cea .PageParameters .Orientation =_fa .Portrait ;return _cfd ;};
|
@ -10,7 +10,8 @@
|
||||
// terms that can be accessed at https://unidoc.io/eula/
|
||||
|
||||
// Package common contains common properties used by the subpackages.
|
||||
package common ;import _c "time";const _a =2021;const _ab =2;
|
||||
package common ;import _a "time";const _c ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";const _bd =22;const Version ="\u0030\u002e\u0032.\u0030";const _ce =12;const _bdc =20;
|
||||
var ReleasedAt =_a .Date (_b ,_cd ,_bd ,_ce ,_bdc ,0,0,_a .UTC );
|
||||
|
||||
// UtcTimeFormat returns a formatted string describing a UTC timestamp.
|
||||
func UtcTimeFormat (t _c .Time )string {return t .Format (_b )+"\u0020\u0055\u0054\u0043"};const _bf =8;const Version ="\u0030\u002e\u0031.\u0030";const _aa =12;const _b ="\u0032\u0020\u004aan\u0075\u0061\u0072\u0079\u0020\u0032\u0030\u0030\u0036\u0020\u0061\u0074\u0020\u0031\u0035\u003a\u0030\u0034";var ReleasedAt =_c .Date (_a ,_ab ,_bf ,_aa ,_ag ,0,0,_c .UTC );const _ag =20;
|
||||
func UtcTimeFormat (t _a .Time )string {return t .Format (_c )+"\u0020\u0055\u0054\u0043"};const _b =2021;const _cd =2;
|
@ -9,35 +9,41 @@
|
||||
// Use of this source code is governed by the UniDoc End User License Agreement
|
||||
// terms that can be accessed at https://unidoc.io/eula/
|
||||
|
||||
package content ;import (_c "archive/zip";_fb "bytes";_f "encoding/json";_e "golang.org/x/xerrors";_ac "io/ioutil";_cd "net/url";_a "os";_g "strings";);
|
||||
package content ;import (_e "archive/zip";_ba "bytes";_de "encoding/json";_db "golang.org/x/xerrors";_a "io/ioutil";_b "net/url";_eb "os";_eg "strings";);type zipDirectory struct{_bdd _ba .Buffer ;_dc *_e .Writer ;};
|
||||
|
||||
// ContentType implements Content interface.
|
||||
func (_cdd *webURL )ContentType ()string {return "\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e";};
|
||||
// NewHTMLFile creates new Content htmFile for provided input path.
|
||||
func NewHTMLFile (path string )(Content ,error ){_f ,_bf :=_eb .Open (path );if _bf !=nil {return nil ,_bf ;};_bc :=&htmFile {_g :_ba .Buffer {}};if _ ,_bf =_bc ._g .ReadFrom (_f );_bf !=nil {return nil ,_bf ;};return _bc ,nil ;};
|
||||
|
||||
// Data implements Content interface.
|
||||
func (_ga *zipDirectory )Data ()[]byte {return _ga ._bf .Bytes ()};
|
||||
func (_ga *webURL )Data ()[]byte {return _ga ._bd };type htmFile struct{_g _ba .Buffer };
|
||||
|
||||
// ContentType implements Content interface.
|
||||
func (_ae *htmFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
|
||||
|
||||
// ContentType implements Content interface.
|
||||
func (_bab *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};type webURL struct{_bg string ;_bd []byte ;};
|
||||
|
||||
// NewWebURL creates new Content webURL for provided input URL path.
|
||||
func NewWebURL (path string )(Content ,error ){if _ ,_ff :=_cd .Parse (path );_ff !=nil {return nil ,_ff ;};type urlOutput struct{URL string `json:"url"`;};_eb :=urlOutput {URL :path };_ae ,_fff :=_f .Marshal (_eb );if _fff !=nil {return nil ,_fff ;};return &webURL {_dd :path ,_cf :_ae },nil ;};
|
||||
|
||||
// ContentType implements Content interface.
|
||||
func (_ab *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};func (_ca *zipDirectory )zipBasePaths (_ge _a .FileInfo ,_ega ,_eeb string ,_bfa bool ,_gg *_g .Builder )(string ,string ){_gg .WriteString (_ega );if !_g .HasSuffix (_ega ,"\u002f"){_gg .WriteRune ('/');};_gg .WriteString (_ge .Name ());if _bfa {_gg .WriteRune ('/');};_ged :=_gg .String ();_gg .Reset ();_gg .WriteString (_eeb );_gg .WriteString (_ge .Name ());if _bfa {_gg .WriteRune ('/');};_ad :=_gg .String ();_gg .Reset ();return _ged ,_ad ;};
|
||||
func NewWebURL (path string )(Content ,error ){if _ ,_dec :=_b .Parse (path );_dec !=nil {return nil ,_dec ;};type urlOutput struct{URL string `json:"url"`;};_ac :=urlOutput {URL :path };_bad ,_ab :=_de .Marshal (_ac );if _ab !=nil {return nil ,_ab ;};
|
||||
return &webURL {_bg :path ,_bd :_bad },nil ;};
|
||||
|
||||
// Data implements Content interface.
|
||||
func (_acc *webURL )Data ()[]byte {return _acc ._cf };
|
||||
func (_ef *zipDirectory )Data ()[]byte {return _ef ._bdd .Bytes ()};func (_eaf *zipDirectory )zipBasePaths (_gb _eb .FileInfo ,_bdg ,_dae string ,_ad bool ,_dcd *_eg .Builder )(string ,string ){_dcd .WriteString (_bdg );if !_eg .HasSuffix (_bdg ,"\u002f"){_dcd .WriteRune ('/');
|
||||
};_dcd .WriteString (_gb .Name ());if _ad {_dcd .WriteRune ('/');};_gacc :=_dcd .String ();_dcd .Reset ();_dcd .WriteString (_dae );_dcd .WriteString (_gb .Name ());if _ad {_dcd .WriteRune ('/');};_fe :=_dcd .String ();_dcd .Reset ();return _gacc ,_fe ;
|
||||
};
|
||||
|
||||
// Data implements Content interface.
|
||||
func (_da *htmFile )Data ()[]byte {return _da ._g .Bytes ()};
|
||||
|
||||
// Content is an interface used for putting the content into Client Query.
|
||||
type Content interface{ContentType ()string ;Data ()[]byte ;};
|
||||
|
||||
// ContentType implements Content interface.
|
||||
func (_da *htmFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
|
||||
func (_fdb *webURL )ContentType ()string {return "\u0061\u0070p\u006c\u0069\u0063a\u0074\u0069\u006f\u006e\u002f\u006a\u0073\u006f\u006e";};
|
||||
|
||||
// NewZipDirectory creates new zip compressed file that recursively reads the directory at the 'dirPath'
|
||||
// and stores in it's in-memory buffer.
|
||||
func NewZipDirectory (dirPath string )(Content ,error ){_gbb :=&zipDirectory {_bf :_fb .Buffer {}};_gbb ._fe =_c .NewWriter (&_gbb ._bf );if _ee :=_gbb .zipPath (dirPath ,"");_ee !=nil {return nil ,_ee ;};if _dc :=_gbb ._fe .Close ();_dc !=nil {return nil ,_dc ;};return _gbb ,nil ;};type webURL struct{_dd string ;_cf []byte ;};
|
||||
|
||||
// Data implements Content interface.
|
||||
func (_gb *htmFile )Data ()[]byte {return _gb ._d .Bytes ()};func (_eg *zipDirectory )zipPath (_cc ,_gaa string )error {_de ,_cfb :=_ac .ReadDir (_cc );if _cfb !=nil {return _e .Errorf ("\u0072\u0065\u0061di\u006e\u0067\u0020\u0064\u0069\u0072\u0065\u0063\u0074o\u0072y\u003a \u0027%\u0073\u0027\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_cc ,_cfb );};_fc :=&_g .Builder {};for _ ,_ce :=range _de {_df ,_gf :=_eg .zipBasePaths (_ce ,_cc ,_gaa ,_ce .IsDir (),_fc );if _ce .IsDir (){if _acd :=_eg .zipPath (_df ,_gf );_acd !=nil {return _acd ;};continue ;};_fcd ,_beg :=_ac .ReadFile (_df );if _beg !=nil {return _beg ;};_ebg ,_beg :=_eg ._fe .Create (_gf );if _beg !=nil {return _beg ;};if _ ,_beg =_ebg .Write (_fcd );_beg !=nil {return _beg ;};};return nil ;};type htmFile struct{_d _fb .Buffer };
|
||||
|
||||
// NewHTMLFile creates new Content htmFile for provided input path.
|
||||
func NewHTMLFile (path string )(Content ,error ){_aa ,_be :=_a .Open (path );if _be !=nil {return nil ,_be ;};_af :=&htmFile {_d :_fb .Buffer {}};if _ ,_be =_af ._d .ReadFrom (_aa );_be !=nil {return nil ,_be ;};return _af ,nil ;};type zipDirectory struct{_bf _fb .Buffer ;_fe *_c .Writer ;};
|
||||
func NewZipDirectory (dirPath string )(Content ,error ){_ea :=&zipDirectory {_bdd :_ba .Buffer {}};_ea ._dc =_e .NewWriter (&_ea ._bdd );if _fb :=_ea .zipPath (dirPath ,"");_fb !=nil {return nil ,_fb ;};if _aa :=_ea ._dc .Close ();_aa !=nil {return nil ,_aa ;
|
||||
};return _ea ,nil ;};func (_bb *zipDirectory )zipPath (_ebf ,_c string )error {_cg ,_gaa :=_a .ReadDir (_ebf );if _gaa !=nil {return _db .Errorf ("\u0072\u0065\u0061di\u006e\u0067\u0020\u0064\u0069\u0072\u0065\u0063\u0074o\u0072y\u003a \u0027%\u0073\u0027\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u003a\u0020\u0025\u0077",_ebf ,_gaa );
|
||||
};_gf :=&_eg .Builder {};for _ ,_gc :=range _cg {_ebb ,_gac :=_bb .zipBasePaths (_gc ,_ebf ,_c ,_gc .IsDir (),_gf );if _gc .IsDir (){if _fg :=_bb .zipPath (_ebb ,_gac );_fg !=nil {return _fg ;};continue ;};_eag ,_fa :=_a .ReadFile (_ebb );if _fa !=nil {return _fa ;
|
||||
};_cd ,_fa :=_bb ._dc .Create (_gac );if _fa !=nil {return _fa ;};if _ ,_fa =_cd .Write (_eag );_fa !=nil {return _fa ;};};return nil ;};
|
3
go.mod
3
go.mod
@ -4,9 +4,8 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/spf13/cobra v1.1.1
|
||||
github.com/spf13/viper v1.7.1
|
||||
github.com/unidoc/unipdf/v3 v3.18.0
|
||||
github.com/unidoc/unipdf/v3 v3.19.1
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
|
||||
)
|
||||
|
350
go.sum
Normal file
350
go.sum
Normal file
@ -0,0 +1,350 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/adrg/strutil v0.1.0 h1:IOQnSOAjbE17+7l1lw4rXgX6JuSeJGdZa7BucTMV3Qg=
|
||||
github.com/adrg/strutil v0.1.0/go.mod h1:pXRr2+IyX5AEPAF5icj/EeTaiflPSD2hvGjnguilZgE=
|
||||
github.com/adrg/sysfont v0.1.1 h1:l9WKJNHsIpsfOhYIm1oSj+77837r/vls1MH17SH6gp0=
|
||||
github.com/adrg/sysfont v0.1.1/go.mod h1:19nTHzfIn/HbngFMet+yNAvwSQYtOJYMI7vWexLWyNw=
|
||||
github.com/adrg/xdg v0.2.1 h1:VSVdnH7cQ7V+B33qSJHTCRlNgra1607Q8PzEmnvb2Ic=
|
||||
github.com/adrg/xdg v0.2.1/go.mod h1:ZuOshBmzV4Ta+s23hdfFZnBsdzmoR3US0d7ErpqSbTQ=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q=
|
||||
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
|
||||
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
|
||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
|
||||
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/unidoc/pkcs7 v0.0.0-20200411230602-d883fd70d1df h1:1RV3lxQ6L6xGFNhngpP9iMjJPSwvH3p17JNbK9u5274=
|
||||
github.com/unidoc/pkcs7 v0.0.0-20200411230602-d883fd70d1df/go.mod h1:UEzOZUEpJfDpywVJMUT8QiugqEZC29pDq7kdIZhWCr8=
|
||||
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a h1:RLtvUhe4DsUDl66m7MJ8OqBjq8jpWBXPK6/RKtqeTkc=
|
||||
github.com/unidoc/timestamp v0.0.0-20200412005513-91597fd3793a/go.mod h1:j+qMWZVpZFTvDey3zxUkSgPJZEX33tDgU/QIA0IzCUw=
|
||||
github.com/unidoc/unipdf/v3 v3.19.0 h1:DGa6xAMSXfRhcK4TPVzrSmSh0MvJ8aoB0Kcv8waCGTM=
|
||||
github.com/unidoc/unipdf/v3 v3.19.0/go.mod h1:WdRz3hVhi/M0jFGXhsT5/9FDyRfga6KgI2ZQqjiOXaM=
|
||||
github.com/unidoc/unipdf/v3 v3.19.1 h1:YCiKtYek7aHHsc3gx6ls6NlxY0+CfXy3KY4cCvyjqgY=
|
||||
github.com/unidoc/unipdf/v3 v3.19.1/go.mod h1:WdRz3hVhi/M0jFGXhsT5/9FDyRfga6KgI2ZQqjiOXaM=
|
||||
github.com/unidoc/unitype v0.2.1 h1:x0jMn7pB/tNrjEVjy3Ukpxo++HOBQaTCXcTYFA6BH3w=
|
||||
github.com/unidoc/unitype v0.2.1/go.mod h1:mafyug7zYmDOusqa7G0dJV45qp4b6TDAN+pHN7ZUIBU=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE=
|
||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY=
|
||||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
|
||||
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
274
sizes/sizes.go
274
sizes/sizes.go
@ -12,163 +12,181 @@
|
||||
// Package sizes defines basic types that determines the size units i.e. lengths.
|
||||
//
|
||||
//
|
||||
package sizes ;import (_c "encoding/json";_d "flag";_ee "fmt";_fb "github.com/pkg/errors";_e "strconv";_a "strings";);
|
||||
package sizes ;import (_fg "encoding/json";_a "flag";_g "fmt";_cb "strconv";_c "strings";);var _ _a .Value =(*Point )(nil );
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_fab PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"};
|
||||
// Millimeters converts the inches value to the millimeters.
|
||||
func (_fd Inch )Millimeters ()Millimeter {return Millimeter (float64 (_fd )*_ca )};
|
||||
|
||||
// UnmarshalPageSize unmarshals the page size from the string.
|
||||
func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _cb PageSize ;if _ecf :=(&_cb ).UnmarshalText ([]byte (pageSize ));_ecf !=nil {return 0,_fb .Wrap (_ecf ,"\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065\u0020s\u0069\u007a\u0065");};return _cb ,nil ;};
|
||||
// Point is a unit of Length commonly used to measure the height of fonts.
|
||||
type Point float64 ;
|
||||
|
||||
// PageSizeString retrieves an enum value from the enum constants string name.
|
||||
// Throws an error if the param is not part of the enum.
|
||||
func PageSizeString (s string )(PageSize ,error ){if _dcb ,_aafe :=_bd [s ];_aafe {return _dcb ,nil ;};return 0,_ee .Errorf ("\u0025\u0073 \u0064\u006f\u0065\u0073 \u006e\u006ft\u0020\u0062\u0065\u006c\u006f\u006e\u0067\u0020t\u006f\u0020\u0050\u0061\u0067\u0065\u0053\u0069\u007a\u0065\u0020\u0076a\u006c\u0075\u0065\u0073",s );};const (Portrait =Orientation (false );Landscape =Orientation (true ););
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_ba Inch )String ()string {_gfe :=_c .Builder {};_gfe .WriteString (_cb .FormatFloat (float64 (_ba ),'f',1,64));_gfe .WriteString ("\u0069\u006e");return _gfe .String ();};
|
||||
|
||||
// Set implements flag.Value interface.
|
||||
func (_fde *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_fde =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_fde =Landscape ;default:return _ee .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s );};return nil ;};
|
||||
// HasChanged implements viper.FlagValue interface.
|
||||
func (_ge *Point )HasChanged ()bool {return _ge !=nil };
|
||||
|
||||
// Inch is a unit that
|
||||
type Inch float64 ;
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_ae *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};func _bce (_ga string )(Inch ,error ){_ga =_a .TrimSpace (_a .Trim (_ga ,"\u0069\u006e"));_ddg ,_be :=_e .ParseFloat (_ga ,64);if _be !=nil {return 0,_fb .Wrap (_be ,"\u0069n\u0076a\u006c\u0069\u0064\u0020\u0069n\u0063\u0068 \u0076\u0061\u006c\u0075\u0065");};return Inch (_ddg ),nil ;};var _ Length =Inch (0);
|
||||
|
||||
// Set implements flag.Value interface.
|
||||
func (_gbb *Point )Set (s string )error {_ad ,_aa :=_e .ParseFloat (s ,64);if _aa !=nil {return _fb .Wrap (_aa ,"\u0069n\u0076a\u006c\u0069\u0064\u0020\u0069n\u0063\u0068 \u0076\u0061\u006c\u0075\u0065");};*_gbb =Point (_ad );return nil ;};
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_dec Point )String ()string {_af :=_a .Builder {};_af .WriteString (_e .FormatFloat (float64 (_dec ),'f',1,64));_af .WriteString ("\u0070\u0074");return _af .String ();};var _ _d .Value =(*Orientation )(nil );
|
||||
|
||||
// Inches gets the inch value. Implements Length interface.
|
||||
func (_fc Inch )Inches ()Inch {return _fc };
|
||||
|
||||
// Point is a unit of Length commonly used to measure the height of fonts.
|
||||
type Point float64 ;
|
||||
|
||||
// Millimeter is the dimension unit that defines a millimeter.
|
||||
type Millimeter float64 ;
|
||||
|
||||
// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise
|
||||
func (_gbe PageSize )IsAPageSize ()bool {for _ ,_gc :=range _eeb {if _gbe ==_gc {return true ;};};return false ;};
|
||||
|
||||
// MarshalUnit marshals the unit into the string.
|
||||
func MarshalUnit (unit Length )(string ,error ){switch _aaf :=unit .(type ){case Millimeter :return _ee .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_aaf ),nil ;case Inch :return _ee .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_aaf ),nil ;case Point :return _ee .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_aaf ),nil ;default:return "",_ee .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};};
|
||||
|
||||
// Set implements pflag.Value interface.
|
||||
func (_dfb *PageSize )Set (s string )error {_cad ,_bcg :=UnmarshalPageSize (s );if _bcg !=nil {return _bcg ;};*_dfb =_cad ;return nil ;};
|
||||
|
||||
// Points implements Length interface.
|
||||
func (_ebf Millimeter )Points ()Point {return Point (_ebf *_db )};
|
||||
|
||||
// Name implements viper.FlagValue interface.
|
||||
func (_dc Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};
|
||||
|
||||
// UnmarshalLength unmarshalls string value into Length.
|
||||
func UnmarshalLength (length string )(Length ,error ){if _a .HasSuffix (length ,"\u006d\u006d"){return _faf (length );};if _a .HasSuffix (length ,"\u0069\u006e"){return _bce (length );};if _a .HasSuffix (length ,"\u0070\u0074"){return _ggb (length );};return nil ,_ee .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length );};func _ggb (_afg string )(Point ,error ){_afg =_a .TrimSpace (_a .Trim (_afg ,"\u0070\u0074"));_bb ,_cf :=_e .ParseFloat (_afg ,64);if _cf !=nil {return 0,_cf ;};return Point (_bb ),nil ;};
|
||||
|
||||
// Dimensions gets the dimensions of the given page size.
|
||||
// If provided page size is not valid than the function returns 0 values.
|
||||
func (_gf PageSize )Dimensions ()(_eaa ,_dbad Millimeter ){switch _gf {case A0 :return 841,1189;case A1 :return 594,841;case A2 :return 420,594;case A3 :return 297,420;case A4 :return 210,297;case A5 :return 148,210;case A6 :return 105,148;case A7 :return 74,105;case A8 :return 52,74;case A9 :return 37,52;case A10 :return 26,37;case B0 :return 1000,1414;case B1 :return 707,1000;case B2 :return 500,707;case B3 :return 353,500;case B4 :return 250,353;case B5 :return 176,250;case B6 :return 125,176;case B7 :return 88,125;case B8 :return 66,88;case B9 :return 44,62;case B10 :return 31,44;case Letter :return 215.9,279.4;};return _eaa ,_dbad ;};
|
||||
|
||||
// String gets the string value for given flag.
|
||||
func (_fa *LengthFlag )String ()string {if _fa .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _fa .Length .String ();};
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_aee Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};var _ce =[...]uint8 {0,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38,40,42,44,46,48,50,52,55,61};
|
||||
|
||||
// Inches gets the inches equivalent from provided millimeter value.
|
||||
func (_ccf Millimeter )Inches ()Inch {return Inch (float64 (_ccf )*_de )};
|
||||
|
||||
// Millimeters converts the inches value to the millimeters.
|
||||
func (_ggc Point )Millimeters ()Millimeter {return Millimeter (float64 (_ggc )*_da )};
|
||||
|
||||
// ValueString implements pflag.Value interface.
|
||||
func (_dba Inch )ValueString ()string {return _dba .String ()};
|
||||
|
||||
// HasChanged implements pflag.Value interface.
|
||||
func (_ca *Inch )HasChanged ()bool {return _ca !=nil };const (_de =float64 (1)/float64 (25.4);_g =25.4;_gd =0.0139;_da =0.3528;_eb =1/64;_db =1/_da ;);
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_bc Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};var _bd =map[string ]PageSize {_dbe [0:9]:0,_dbe [9:11]:1,_dbe [11:13]:2,_dbe [13:15]:3,_dbe [15:17]:4,_dbe [17:19]:5,_dbe [19:21]:6,_dbe [21:23]:7,_dbe [23:25]:8,_dbe [25:27]:9,_dbe [27:29]:10,_dbe [29:32]:11,_dbe [32:34]:12,_dbe [34:36]:13,_dbe [36:38]:14,_dbe [38:40]:15,_dbe [40:42]:16,_dbe [42:44]:17,_dbe [44:46]:18,_dbe [46:48]:19,_dbe [48:50]:20,_dbe [50:52]:21,_dbe [52:55]:22,_dbe [55:61]:23};const (Undefined PageSize =iota ;A0 ;A1 ;A2 ;A3 ;A4 ;A5 ;A6 ;A7 ;A8 ;A9 ;A10 ;B0 ;B1 ;B2 ;B3 ;B4 ;B5 ;B6 ;B7 ;B8 ;B9 ;B10 ;Letter ;);
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_fd Millimeter )String ()string {_fe :=_a .Builder {};_fe .WriteString (_e .FormatFloat (float64 (_fd ),'f',1,64));_fe .WriteString ("\u006d\u006d");return _fe .String ();};
|
||||
|
||||
// Points implements Length interface.
|
||||
func (_gdc Point )Points ()Point {return _gdc };
|
||||
|
||||
// ValueType implements viper.FlagValue interface.
|
||||
func (_ec Point )ValueType ()string {return _ec .Type ()};
|
||||
|
||||
// UnmarshalInch unmarshalls provided string into unit.
|
||||
func UnmarshalInch (unit string )(Inch ,error ){if _a .HasSuffix (unit ,"\u006d\u006d"){_aed ,_aec :=_faf (unit );if _aec !=nil {return 0,_aec ;};return _aed .Inches (),nil ;};if _a .HasSuffix (unit ,"\u0069\u006e"){return _bce (unit );};return 0,_ee .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit );};const _dbe ="U\u006e\u0064\u0065\u0066\u0069\u006e\u0065\u0064\u0041\u0030\u0041\u0031\u0041\u0032\u0041\u0033\u0041\u0034\u0041\u0035\u0041\u0036\u0041\u0037\u0041\u0038A\u0039A\u0031\u0030\u0042\u0030B\u0031\u00422\u0042\u0033\u0042\u0034\u0042\u0035\u0042\u0036\u0042\u0037\u0042\u0038\u0042\u0039\u0042\u0031\u0030\u004c\u0065\u0074\u0074\u0065\u0072";
|
||||
|
||||
// MarshalText implements the encoding.TextMarshaler interface for PageSize
|
||||
func (_fcf PageSize )MarshalText ()([]byte ,error ){return []byte (_fcf .String ()),nil };
|
||||
|
||||
// Set sets the unit value.
|
||||
// Implements pflag.Value interface.
|
||||
func (_b *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_b .Length =nil ;return nil ;};_gb ,_cc :=UnmarshalLength (s );if _cc !=nil {return _cc ;};_b .Length =_gb ;return nil ;};
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_cg Orientation )String ()string {if _cg ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";};
|
||||
|
||||
// MarshalPageSize marshals the page size into string.
|
||||
func MarshalPageSize (p PageSize )(string ,error ){_adg ,_ece :=p .MarshalText ();if _ece !=nil {return "",_ece ;};return string (_adg ),nil ;};
|
||||
|
||||
// PageSize is the enum used for defining the page size.
|
||||
type PageSize int ;
|
||||
|
||||
// Inches gets the inch value. Implements Length interface.
|
||||
func (_bg Point )Inches ()Inch {return Inch (float64 (_bg )*_gd )};
|
||||
func (_gd Orientation )Type ()string {return "o\u0072\u0069\u0065\u006e\u0074\u0061\u0074\u0069\u006f\u006e";};
|
||||
|
||||
// Orientation is the page orientation type wrapper.
|
||||
type Orientation bool ;
|
||||
|
||||
// Points implements Length interface.
|
||||
func (_bfeg Inch )Points ()Point {return Point (float64 (_bfeg )*_eb )};
|
||||
// Set sets the unit value.
|
||||
// Implements pflag.Value interface.
|
||||
func (_gf *LengthFlag )Set (s string )error {if s =="\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d"{_gf .Length =nil ;return nil ;};_df ,_ec :=UnmarshalLength (s );if _ec !=nil {return _ec ;};_gf .Length =_df ;return nil ;};
|
||||
|
||||
// Name implements pflag.Value interface.
|
||||
func (_bcc Inch )Name ()string {return "\u0069\u006e\u0063\u0068"};
|
||||
func (_eg Inch )Name ()string {return "\u0069\u006e\u0063\u0068"};
|
||||
|
||||
// HasChanged implements viper.FlagValue interface.
|
||||
func (_ef *Point )HasChanged ()bool {return _ef !=nil };
|
||||
// Name implements viper.FlagValue interface.
|
||||
func (_de Point )Name ()string {return "\u0070\u006f\u0069n\u0074"};
|
||||
|
||||
// ValueType implements pflag.Value interface.
|
||||
func (_ge Inch )ValueType ()string {return _ge .Type ()};
|
||||
|
||||
// ValueString implements viper.FlagValue interface.
|
||||
func (_adf Point )ValueString ()string {return _adf .String ()};
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface for PageSize
|
||||
func (_fbe PageSize )MarshalJSON ()([]byte ,error ){return _c .Marshal (_fbe .String ())};var (_ Length =Millimeter (0););
|
||||
// IsAPageSize returns "true" if the value is listed in the enum definition. "false" otherwise
|
||||
func (_fdg PageSize )IsAPageSize ()bool {for _ ,_ffb :=range _da {if _fdg ==_ffb {return true ;};};return false ;};
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_bf Inch )String ()string {_ebb :=_a .Builder {};_ebb .WriteString (_e .FormatFloat (float64 (_bf ),'f',1,64));_ebb .WriteString ("\u0069\u006e");return _ebb .String ();};func _faf (_dcf string )(Millimeter ,error ){_dcf =_a .TrimSpace (_a .TrimSuffix (_dcf ,"\u006d\u006d"));_gea ,_ed :=_e .ParseFloat (_dcf ,64);if _ed !=nil {return 0,_fb .Wrap (_ed ,"\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006d\u0069\u006c\u006c\u0069m\u0065\u0074\u0065\u0072\u0020\u0076\u0061\u006c\u0075\u0065");};return Millimeter (_gea ),nil ;};
|
||||
func (_ecb Millimeter )String ()string {_ag :=_c .Builder {};_ag .WriteString (_cb .FormatFloat (float64 (_ecb ),'f',1,64));_ag .WriteString ("\u006d\u006d");return _ag .String ();};
|
||||
|
||||
// Millimeters converts the inches value to the millimeters.
|
||||
func (_bfe Inch )Millimeters ()Millimeter {return Millimeter (float64 (_bfe )*_g )};
|
||||
// Type implements pflag.Value interface.
|
||||
func (_bb Inch )Type ()string {return "\u0069\u006e\u0063\u0068"};
|
||||
|
||||
// Set implements flag.Value interface.
|
||||
func (_dg *Orientation )Set (s string )error {switch s {case "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074":*_dg =Portrait ;case "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e":*_dg =Landscape ;default:return _g .Errorf ("\u0069n\u0076\u0061\u006c\u0069d\u0020\u006f\u0072\u0069\u0065n\u0074a\u0074i\u006f\u006e\u003a\u0020\u0027\u0025\u0073'",s );
|
||||
};return nil ;};
|
||||
|
||||
// ValueType implements pflag.Value interface.
|
||||
func (_fee Inch )ValueType ()string {return _fee .Type ()};
|
||||
|
||||
// Set implements pflag.Value interface.
|
||||
func (_dd *Inch )Set (s string )error {_ab ,_daf :=_e .ParseFloat (s ,64);if _daf !=nil {return _fb .Wrap (_daf ,"\u0069n\u0076a\u006c\u0069\u0064\u0020\u0069n\u0063\u0068 \u0076\u0061\u006c\u0075\u0065");};*_dd =Inch (_ab );return nil ;};
|
||||
func (_fgd *PageSize )Set (s string )error {_cf ,_efe :=UnmarshalPageSize (s );if _efe !=nil {return _efe ;};*_fgd =_cf ;return nil ;};
|
||||
|
||||
// PageSizeString retrieves an enum value from the enum constants string name.
|
||||
// Throws an error if the param is not part of the enum.
|
||||
func PageSizeString (s string )(PageSize ,error ){if _cgc ,_fcd :=_ada [s ];_fcd {return _cgc ,nil ;};return 0,_g .Errorf ("\u0025\u0073 \u0064\u006f\u0065\u0073 \u006e\u006ft\u0020\u0062\u0065\u006c\u006f\u006e\u0067\u0020t\u006f\u0020\u0050\u0061\u0067\u0065\u0053\u0069\u007a\u0065\u0020\u0076a\u006c\u0075\u0065\u0073",s );
|
||||
};
|
||||
|
||||
// Millimeters gets the float64 millimeter value.
|
||||
func (_ea Millimeter )Millimeters ()Millimeter {return _ea };
|
||||
|
||||
// PageSizeValues returns all values of the enum
|
||||
func PageSizeValues ()[]PageSize {return _da };var _da =[]PageSize {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
|
||||
|
||||
// UnmarshalPageSize unmarshals the page size from the string.
|
||||
func UnmarshalPageSize (pageSize string )(PageSize ,error ){var _bd PageSize ;if _ecg :=(&_bd ).UnmarshalText ([]byte (pageSize ));_ecg !=nil {return 0,_g .Errorf ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u0070a\u0067\u0065\u0020\u0073\u0069\u007a\u0065\u003a\u0020\u0025\u0077",_ecg );
|
||||
};return _bd ,nil ;};var (_ Length =Millimeter (0););var _ada =map[string ]PageSize {_ace [0:9]:0,_ace [9:11]:1,_ace [11:13]:2,_ace [13:15]:3,_ace [15:17]:4,_ace [17:19]:5,_ace [19:21]:6,_ace [21:23]:7,_ace [23:25]:8,_ace [25:27]:9,_ace [27:29]:10,_ace [29:32]:11,_ace [32:34]:12,_ace [34:36]:13,_ace [36:38]:14,_ace [38:40]:15,_ace [40:42]:16,_ace [42:44]:17,_ace [44:46]:18,_ace [46:48]:19,_ace [48:50]:20,_ace [50:52]:21,_ace [52:55]:22,_ace [55:61]:23};
|
||||
func _cbab (_dc string )(Inch ,error ){_dc =_c .TrimSpace (_c .Trim (_dc ,"\u0069\u006e"));_cg ,_ed :=_cb .ParseFloat (_dc ,64);if _ed !=nil {return 0,_g .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_ed );
|
||||
};return Inch (_cg ),nil ;};
|
||||
|
||||
// Set implements flag.Value interface.
|
||||
func (_bae *Point )Set (s string )error {_fec ,_ab :=_cb .ParseFloat (s ,64);if _ab !=nil {return _g .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_ab );};*_bae =Point (_fec );
|
||||
return nil ;};
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_ae Point )String ()string {_cbfc :=_c .Builder {};_cbfc .WriteString (_cb .FormatFloat (float64 (_ae ),'f',1,64));_cbfc .WriteString ("\u0070\u0074");return _cbfc .String ();};
|
||||
|
||||
// MarshalUnit marshals the unit into the string.
|
||||
func MarshalUnit (unit Length )(string ,error ){switch _ac :=unit .(type ){case Millimeter :return _g .Sprintf ("\u0025\u002e\u0030\u0066\u006d\u006d",_ac ),nil ;case Inch :return _g .Sprintf ("\u0025\u002e\u0030\u0066\u0069\u006e",_ac ),nil ;case Point :return _g .Sprintf ("\u0025\u002e\u0030\u0066\u0070\u0074",_ac ),nil ;
|
||||
default:return "",_g .Errorf ("i\u006e\u0076\u0061\u006cid\u0020u\u006e\u0069\u0074\u0020\u0074y\u0070\u0065\u003a\u0020\u0025\u0054",unit );};};var _ _a .Value =(*Orientation )(nil );
|
||||
|
||||
// String gets the string value for given flag.
|
||||
func (_e *LengthFlag )String ()string {if _e .Length ==nil {return "\u0075n\u0064\u0065\u0066\u0069\u006e\u0065d";};return _e .Length .String ();};
|
||||
|
||||
// Points implements Length interface.
|
||||
func (_ef Point )Points ()Point {return _ef };
|
||||
|
||||
// Millimeters converts the inches value to the millimeters.
|
||||
func (_agc Point )Millimeters ()Millimeter {return Millimeter (float64 (_agc )*_dd )};
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface for PageSize
|
||||
func (_aeg PageSize )MarshalJSON ()([]byte ,error ){return _fg .Marshal (_aeg .String ())};func (_gc PageSize )String ()string {if _gc < 0||_gc >=PageSize (len (_aa )-1){return _g .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_gc );
|
||||
};return _ace [_aa [_gc ]:_aa [_gc +1]];};
|
||||
|
||||
// LengthFlag is a pflag wrapper for the Length value.
|
||||
type LengthFlag struct{Length Length ;};
|
||||
|
||||
// UnmarshalInch unmarshalls provided string into unit.
|
||||
func UnmarshalInch (unit string )(Inch ,error ){if _c .HasSuffix (unit ,"\u006d\u006d"){_fca ,_eca :=_bg (unit );if _eca !=nil {return 0,_eca ;};return _fca .Inches (),nil ;};if _c .HasSuffix (unit ,"\u0069\u006e"){return _cbab (unit );};return 0,_g .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020%\u0073",unit );
|
||||
};
|
||||
|
||||
// MarshalText implements the encoding.TextMarshaler interface for PageSize
|
||||
func (_aed PageSize )MarshalText ()([]byte ,error ){return []byte (_aed .String ()),nil };
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_cba *LengthFlag )Type ()string {return "\u0075\u006e\u0069\u0074"};
|
||||
|
||||
// Millimeter is the dimension unit that defines a millimeter.
|
||||
type Millimeter float64 ;const (Portrait =Orientation (false );Landscape =Orientation (true ););
|
||||
|
||||
// MarshalPageSize marshals the page size into string.
|
||||
func MarshalPageSize (p PageSize )(string ,error ){_adb ,_ee :=p .MarshalText ();if _ee !=nil {return "",_ee ;};return string (_adb ),nil ;};
|
||||
|
||||
// Points implements Length interface.
|
||||
func (_fef Inch )Points ()Point {return Point (float64 (_fef )*_cbf )};
|
||||
|
||||
// String implements fmt.Stringer interface.
|
||||
func (_baa Orientation )String ()string {if _baa ==Portrait {return "\u0070\u006f\u0072\u0074\u0072\u0061\u0069\u0074";};return "\u006ca\u006e\u0064\u0073\u0063\u0061\u0070e";};const (Undefined PageSize =iota ;A0 ;A1 ;A2 ;A3 ;A4 ;A5 ;A6 ;A7 ;A8 ;A9 ;A10 ;
|
||||
B0 ;B1 ;B2 ;B3 ;B4 ;B5 ;B6 ;B7 ;B8 ;B9 ;B10 ;Letter ;);
|
||||
|
||||
// ValueType implements viper.FlagValue interface.
|
||||
func (_ecc Point )ValueType ()string {return _ecc .Type ()};
|
||||
|
||||
// Inches gets the inch value. Implements Length interface.
|
||||
func (_feef Point )Inches ()Inch {return Inch (float64 (_feef )*_d )};
|
||||
|
||||
// Dimensions gets the dimensions of the given page size.
|
||||
// If provided page size is not valid than the function returns 0 values.
|
||||
func (_adc PageSize )Dimensions ()(_cgf ,_bbe Millimeter ){switch _adc {case A0 :return 841,1189;case A1 :return 594,841;case A2 :return 420,594;case A3 :return 297,420;case A4 :return 210,297;case A5 :return 148,210;case A6 :return 105,148;case A7 :return 74,105;
|
||||
case A8 :return 52,74;case A9 :return 37,52;case A10 :return 26,37;case B0 :return 1000,1414;case B1 :return 707,1000;case B2 :return 500,707;case B3 :return 353,500;case B4 :return 250,353;case B5 :return 176,250;case B6 :return 125,176;case B7 :return 88,125;
|
||||
case B8 :return 66,88;case B9 :return 44,62;case B10 :return 31,44;case Letter :return 215.9,279.4;};return _cgf ,_bbe ;};const _ace ="U\u006e\u0064\u0065\u0066\u0069\u006e\u0065\u0064\u0041\u0030\u0041\u0031\u0041\u0032\u0041\u0033\u0041\u0034\u0041\u0035\u0041\u0036\u0041\u0037\u0041\u0038A\u0039A\u0031\u0030\u0042\u0030B\u0031\u00422\u0042\u0033\u0042\u0034\u0042\u0035\u0042\u0036\u0042\u0037\u0042\u0038\u0042\u0039\u0042\u0031\u0030\u004c\u0065\u0074\u0074\u0065\u0072";
|
||||
|
||||
|
||||
// UnmarshalLength unmarshalls string value into Length.
|
||||
func UnmarshalLength (length string )(Length ,error ){if _c .HasSuffix (length ,"\u006d\u006d"){return _bg (length );};if _c .HasSuffix (length ,"\u0069\u006e"){return _cbab (length );};if _c .HasSuffix (length ,"\u0070\u0074"){return _ddc (length );};
|
||||
return nil ,_g .Errorf ("\u0069n\u0076\u0061\u006c\u0069\u0064\u0020\u006c\u0065\u006e\u0067\u0074h\u0020\u0069\u006e\u0070\u0075\u0074\u003a\u0020\u0025\u0073",length );};
|
||||
|
||||
// ValueString implements pflag.Value interface.
|
||||
func (_be Inch )ValueString ()string {return _be .String ()};
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_aec Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};func _bg (_bf string )(Millimeter ,error ){_bf =_c .TrimSpace (_c .TrimSuffix (_bf ,"\u006d\u006d"));_fcg ,_cdd :=_cb .ParseFloat (_bf ,64);if _cdd !=nil {return 0,_g .Errorf ("\u0069\u006e\u0076\u0061l\u0069\u0064\u0020\u006d\u0069\u006c\u006c\u0069\u006d\u0065t\u0065r\u0020\u0076\u0061\u006c\u0075\u0065\u003a \u0025\u0077",_cdd );
|
||||
};return Millimeter (_fcg ),nil ;};
|
||||
|
||||
// ValueString implements viper.FlagValue interface.
|
||||
func (_fae Point )ValueString ()string {return _fae .String ()};
|
||||
|
||||
// Points implements Length interface.
|
||||
func (_fa Millimeter )Points ()Point {return Point (_fa *_b )};
|
||||
|
||||
// Inches gets the inch value. Implements Length interface.
|
||||
func (_egf Inch )Inches ()Inch {return _egf };
|
||||
|
||||
// Length is it the default dimension unit.
|
||||
type Length interface{Millimeters ()Millimeter ;Inches ()Inch ;Points ()Point ;String ()string ;};
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface for PageSize
|
||||
func (_abb *PageSize )UnmarshalJSON (data []byte )error {var _ddb string ;if _ag :=_c .Unmarshal (data ,&_ddb );_ag !=nil {return _ee .Errorf ("P\u0061\u0067\u0065\u0053\u0069\u007ae\u0020\u0073\u0068\u006f\u0075\u006cd\u0020\u0062\u0065\u0020\u0061\u0020\u0073t\u0072\u0069\u006e\u0067\u002c\u0020\u0067\u006f\u0074\u0020%\u0073",data );};var _aba error ;*_abb ,_aba =PageSizeString (_ddb );return _aba ;};
|
||||
// Inches gets the inches equivalent from provided millimeter value.
|
||||
func (_fe Millimeter )Inches ()Inch {return Inch (float64 (_fe )*_cd )};
|
||||
|
||||
// PageSizeValues returns all values of the enum
|
||||
func PageSizeValues ()[]PageSize {return _eeb };
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface for PageSize
|
||||
func (_dcd *PageSize )UnmarshalJSON (data []byte )error {var _cc string ;if _cde :=_fg .Unmarshal (data ,&_cc );_cde !=nil {return _g .Errorf ("P\u0061\u0067\u0065\u0053\u0069\u007ae\u0020\u0073\u0068\u006f\u0075\u006cd\u0020\u0062\u0065\u0020\u0061\u0020\u0073t\u0072\u0069\u006e\u0067\u002c\u0020\u0067\u006f\u0074\u0020%\u0073",data );
|
||||
};var _gff error ;*_dcd ,_gff =PageSizeString (_cc );return _gff ;};func _ddc (_abg string )(Point ,error ){_abg =_c .TrimSpace (_c .Trim (_abg ,"\u0070\u0074"));_ecbc ,_ad :=_cb .ParseFloat (_abg ,64);if _ad !=nil {return 0,_ad ;};return Point (_ecbc ),nil ;
|
||||
};var _aa =[...]uint8 {0,9,11,13,15,17,19,21,23,25,27,29,32,34,36,38,40,42,44,46,48,50,52,55,61};
|
||||
|
||||
// HasChanged implements pflag.Value interface.
|
||||
func (_bbc *Inch )HasChanged ()bool {return _bbc !=nil };
|
||||
|
||||
// Type implements pflag.Value interface.
|
||||
func (_gg Point )Type ()string {return "\u0070\u006f\u0069n\u0074"};var _ _d .Value =(*Point )(nil );
|
||||
|
||||
// LengthFlag is a pflag wrapper for the Length value.
|
||||
type LengthFlag struct{Length Length ;};var _eeb =[]PageSize {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
|
||||
func (_deb PageSize )Type ()string {return "\u0070a\u0067\u0065\u002d\u0073\u0069\u007ae"};var _ Length =Inch (0);const (_cd =float64 (1)/float64 (25.4);_ca =25.4;_d =0.0139;_dd =0.3528;_cbf =1/64;_b =1/_dd ;);
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaler interface for PageSize
|
||||
func (_bef *PageSize )UnmarshalText (text []byte )error {var _ded error ;*_bef ,_ded =PageSizeString (string (text ));return _ded ;};func (_edc PageSize )String ()string {if _edc < 0||_edc >=PageSize (len (_ce )-1){return _ee .Sprintf ("\u0050\u0061\u0067e\u0053\u0069\u007a\u0065\u0028\u0025\u0064\u0029",_edc );};return _dbe [_ce [_edc ]:_ce [_edc +1]];};
|
||||
func (_fab *PageSize )UnmarshalText (text []byte )error {var _gee error ;*_fab ,_gee =PageSizeString (string (text ));return _gee ;};
|
||||
|
||||
// Millimeters gets the float64 millimeter value.
|
||||
func (_ea Millimeter )Millimeters ()Millimeter {return _ea };
|
||||
// PageSize is the enum used for defining the page size.
|
||||
type PageSize int ;
|
||||
|
||||
// Set implements pflag.Value interface.
|
||||
func (_fc *Inch )Set (s string )error {_ff ,_fed :=_cb .ParseFloat (s ,64);if _fed !=nil {return _g .Errorf ("\u0069\u006e\u0076\u0061li\u0064\u0020\u0069\u006e\u0063\u0068\u0020\u0076\u0061\u006c\u0075\u0065\u003a\u0020%\u0077",_fed );};*_fc =Inch (_ff );
|
||||
return nil ;};
|
119
unihtml.go
119
unihtml.go
@ -10,55 +10,16 @@
|
||||
// terms that can be accessed at https://unidoc.io/eula/
|
||||
|
||||
// Package unihtml contains a plugin for the UniDoc.
|
||||
package unihtml ;import (_b "bytes";_c "context";_fc "errors";_db "fmt";_g "github.com/unidoc/unihtml/client";_dce "github.com/unidoc/unihtml/content";_dc "github.com/unidoc/unihtml/sizes";_gg "github.com/unidoc/unipdf/v3/common/license";_dbf "github.com/unidoc/unipdf/v3/creator";_e "github.com/unidoc/unipdf/v3/model";_dg "net/url";_f "os";_fg "time";);func (_eb *Document )extract (_ge _c .Context ,_gf ,_ce _dc .Length ,_dfef margins )([]*_e .PdfPage ,error ){_cbg :=_g .BuildHTMLQuery ().SetContent (_eb ._df ).PageSize (_eb ._ec ).PaperWidth (_gf ).PaperHeight (_ce ).Orientation (_eb ._bda ).MarginLeft (_dfef .Left ).MarginRight (_dfef .Right ).MarginTop (_dfef .Top ).MarginBottom (_dfef .Bottom );_faa ,_fac :=_cbg .Query ();if _fac !=nil {return nil ,_fac ;};_ge ,_cbd :=_c .WithTimeout (_ge ,_fg .Second *15);defer _cbd ();_bfa ,_fac :=_ea .ConvertHTML (_ge ,_faa );if _fac !=nil {return nil ,_fac ;};_ffa :=_b .NewReader (_bfa .Data );_ebc ,_fac :=_e .NewPdfReader (_ffa );if _fac !=nil {return nil ,_fac ;};return _ebc .PageList ,nil ;};
|
||||
|
||||
// SetLandscapeOrientation sets document landscape page orientation.
|
||||
func (_beb *Document )SetLandscapeOrientation (){_beb ._bda =_dc .Landscape };
|
||||
|
||||
// GeneratePageBlocks implements creator.Drawable interface.
|
||||
func (_be *Document )GeneratePageBlocks (ctx _dbf .DrawContext )([]*_dbf .Block ,_dbf .DrawContext ,error ){if _dgg :=_be .validate ();_dgg !=nil {return nil ,ctx ,_dgg ;};var _ad []*_dbf .Block ;_cf :=_be .getMargins ();_eg ,_de :=_be ._dfc ,_be ._dd ;if _be ._dcc .IsRelative (){_eg ,_de =_dc .Point (ctx .Width ),_dc .Point (ctx .Height );};_bed ,_bf :=_be .extract (_c .Background (),_eg ,_de ,_cf );if _bf !=nil {return nil ,_dbf .DrawContext {},_bf ;};for _cdc ,_ffbe :=range _bed {_ecd ,_ae :=_dbf .NewBlockFromPage (_ffbe );if _ae !=nil {return nil ,_dbf .DrawContext {},_ae ;};_acf ,_acb ,_ae :=_ecd .GeneratePageBlocks (ctx );if _ae !=nil {return nil ,_dbf .DrawContext {},_ae ;};ctx =_acb ;if _cdc !=len (_bed )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ;ctx .Page ++;};_ad =append (_ad ,_acf ...);};return _ad ,ctx ,nil ;};var ErrNoClient =_fc .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");func (_gc *Document )getMargins ()margins {_cde :=_gc ._bg ;if _gc ._dcc .IsRelative (){_cde .Top =_dc .Millimeter (0);_cde .Left =_dc .Millimeter (0);_cde .Bottom =_dc .Millimeter (0);_cde .Right =_dc .Millimeter (0);return _cde ;};if _cde .Top ==nil {_cde .Top =_dc .Millimeter (10);};if _cde .Bottom ==nil {_cde .Bottom =_dc .Millimeter (10);};if _cde .Left ==nil {_cde .Left =_dc .Millimeter (10);};if _cde .Right ==nil {_cde .Right =_dc .Millimeter (10);};return _cde ;};
|
||||
|
||||
// GetPdfPages is a function that converts provided input content and
|
||||
func (_dde *Document )GetPdfPages (ctx _c .Context )([]*_e .PdfPage ,error ){if _cd :=_dde .validate ();_cd !=nil {return nil ,_cd ;};return _dde .extract (ctx ,_dde ._dfc ,_dde ._dd ,_dde .getMargins ());};type margins struct{Left ,Right ,Bottom ,Top _dc .Length ;};
|
||||
|
||||
// SetMargins sets the Document Margins.
|
||||
func (_bfc *Document )SetMargins (left ,right ,top ,bottom float64 ){_bfc ._bg .Left =_dc .Point (left );_bfc ._bg .Right =_dc .Point (right );_bfc ._bg .Top =_dc .Point (top );_bfc ._bg .Bottom =_dc .Point (bottom );_bfc ._dcc =_dbf .PositionAbsolute ;};
|
||||
package unihtml ;import (_cc "bytes";_d "context";_fc "errors";_ga "fmt";_dba "github.com/unidoc/unihtml/client";_ba "github.com/unidoc/unihtml/content";_df "github.com/unidoc/unihtml/sizes";_ff "github.com/unidoc/unipdf/v3/common";_gaa "github.com/unidoc/unipdf/v3/common/license";
|
||||
_fe "github.com/unidoc/unipdf/v3/creator";_fd "github.com/unidoc/unipdf/v3/model";_dc "github.com/unidoc/unipdf/v3/render";_db "image";_a "image/color";_c "math";_g "net/url";_e "os";_f "time";);var _ef *_dba .Client ;func (_bc *Document )getMargins ()margins {_fec :=_bc ._cce ;
|
||||
if _bc ._dg .IsRelative (){_fec .Top =_df .Millimeter (1);_fec .Left =_df .Millimeter (1);_fec .Bottom =_df .Millimeter (1);_fec .Right =_df .Millimeter (1);return _fec ;};if _fec .Top ==nil {_fec .Top =_df .Millimeter (10);};if _fec .Bottom ==nil {_fec .Bottom =_df .Millimeter (10);
|
||||
};if _fec .Left ==nil {_fec .Left =_df .Millimeter (10);};if _fec .Right ==nil {_fec .Right =_df .Millimeter (10);};return _fec ;};type margins struct{Left ,Right ,Bottom ,Top _df .Length ;};
|
||||
|
||||
// Document is HTML document wrapper that is used for extracting and converting HTML document into PDF pages.
|
||||
type Document struct{_df _dce .Content ;_bg margins ;_dcc _dbf .Positioning ;_ac ,_ff float64 ;_ec _dc .PageSize ;_dfc ,_dd _dc .Length ;_bda _dc .Orientation ;};
|
||||
|
||||
// SetMarginLeft sets the left margin.
|
||||
func (_fb *Document )SetMarginLeft (margin _dc .Length ){_fb ._bg .Left =margin };
|
||||
|
||||
// SetPos sets the absolute position. Changes object positioning to absolute.
|
||||
func (_ab *Document )SetPos (x ,y float64 ){_ab ._dcc =_dbf .PositionAbsolute ;_ab ._ac =x ;_ab ._ff =y };
|
||||
type Document struct{_dbc _ba .Content ;_cce margins ;_dg _fe .Positioning ;_eb ,_fcd float64 ;_gd _df .PageSize ;_ge ,_gec _df .Length ;_ggb _df .Orientation ;_ce bool ;};
|
||||
|
||||
// SetPageWidth sets the page width for given document.
|
||||
func (_cb *Document )SetPageWidth (pageWidth _dc .Length )error {_cb ._dfc =pageWidth ;_cb ._dcc =_dbf .PositionAbsolute ;return nil ;};
|
||||
|
||||
// SetMarginBottom sets the left margin.
|
||||
func (_egf *Document )SetMarginBottom (margin _dc .Length ){_egf ._bg .Bottom =margin };func _aa ()error {_fa :=_gg .GetLicenseKey ();if _fa ==nil {return _fc .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if !_fa .IsLicensed (){return _fc .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006f\u0072 \u006e\u006f\u0020\u006c\u0069\u0063\u0065n\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if !_fa .UniHTML {return _fc .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020l\u0069\u0063e\u006e\u0073\u0065\u0020\u0069\u0073 \u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069d\u0020\u0066\u006f\u0072\u0020\u0074\u0068\u0065\u0020U\u006e\u0069\u0048\u0054\u004d\u004c\u0020\u0065\u0078\u0074\u0065n\u0073\u0069\u006f\u006e.\u0020\u0056i\u0073i\u0074\u003a\u0020\u0068\u0074\u0074\u0070s\u003a/\u002f\u0077\u0077\u0077\u002e\u0075\u006e\u0069\u0064\u006f\u0063\u002e\u0069\u006f\u0020\u0061\u006ed\u0020c\u006f\u006e\u0074\u0061\u0063\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072t");};return nil ;};
|
||||
|
||||
// ChapterDraw implements creator.containerElement interface.
|
||||
func (_dfec *Document )ContainerComponent (container _dbf .Drawable )(_dbf .Drawable ,error ){switch container .(type ){case *_dbf .Chapter :default:return nil ,_db .Errorf ("\u0075\u006e\u0069\u0068t\u006d\u006c\u002e\u0044\u006f\u0063\u0075\u006d\u0065n\u0074\u0020\u0063\u0061\u006e\u0027\u0074\u0020\u0062\u0065\u0020\u0061\u0020\u0063\u006f\u006d\u0070\u006fn\u0065\u006e\u0074\u0020\u006ff\u0020\u0074\u0068\u0065\u0020\u0025\u0054\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0065\u0072",container );};return _dfec ,nil ;};
|
||||
|
||||
// ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server.
|
||||
func ConnectOptions (o Options )error {_ea =_g .New (_g .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_bc ,_a :=_c .WithTimeout (_c .Background (),_fg .Second *5);defer _a ();if _bd :=_ea .HealthCheck (_bc );_bd !=nil {return _bd ;};return nil ;};
|
||||
|
||||
// Connect creates UniHTML HTTP Client and tries to establish connection with the server.
|
||||
func Connect (path string )error {if _fd :=_aa ();_fd !=nil {return _fd ;};_fcg ,_fe :=_g .ParseOptions (path );if _fe !=nil {return _fe ;};_ea =_g .New (_fcg );_ee ,_eae :=_c .WithTimeout (_c .Background (),_fg .Second *5);defer _eae ();if _ba :=_ea .HealthCheck (_ee );_ba !=nil {return _ba ;};return nil ;};var ErrContentNotDefined =_fc .New ("\u0068\u0074\u006d\u006c\u0020\u0064o\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
|
||||
|
||||
// SetMarginTop sets the left margin.
|
||||
func (_cc *Document )SetMarginTop (margin _dc .Length ){_cc ._bg .Top =margin };var _ _dbf .Drawable =(*Document )(nil );
|
||||
|
||||
// SetMarginRight sets the left margin.
|
||||
func (_bb *Document )SetMarginRight (margin _dc .Length ){_bb ._bg .Right =margin };
|
||||
|
||||
// SetPageSize sets the page default size.
|
||||
func (_cfe *Document )SetPageSize (pageSize _dc .PageSize )error {if !pageSize .IsAPageSize (){return _fc .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065\u0020s\u0069\u007a\u0065");};_cfe ._ec =pageSize ;_cfe ._dcc =_dbf .PositionAbsolute ;return nil ;};
|
||||
|
||||
// NewDocument creates new HTML Document used as an input for the creator.Drawable.
|
||||
func NewDocument (path string )(*Document ,error ){_dfe :=&Document {};_ef ,_fce :=_dg .Parse (path );if _fce !=nil {return nil ,_fce ;};switch _ef .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_dfe ._df ,_fce =_dce .NewWebURL (path );if _fce !=nil {return nil ,_fce ;};return _dfe ,nil ;};_ffb ,_fce :=_f .Stat (path );if _fce !=nil {return nil ,_fce ;};if !_ffb .IsDir (){_dfe ._df ,_fce =_dce .NewHTMLFile (path );}else {_dfe ._df ,_fce =_dce .NewZipDirectory (path );};if _fce !=nil {return nil ,_fce ;};return _dfe ,nil ;};
|
||||
func (_af *Document )SetPageWidth (pageWidth _df .Length )error {_af ._ge =pageWidth ;_af ._dg =_fe .PositionAbsolute ;return nil ;};var _ _fe .Drawable =(*Document )(nil );
|
||||
|
||||
// Options are the HTML Client options used for establishing the connection.
|
||||
type Options struct{
|
||||
@ -73,7 +34,71 @@ Port int ;
|
||||
Secure bool ;
|
||||
|
||||
// Prefix is an option setting used when the server is working with the URI prefix. Default Value: ''.
|
||||
Prefix string ;};func (_ed *Document )validate ()error {if _ea ==nil {return ErrNoClient ;};if _ed ._df ==nil {return ErrContentNotDefined ;};return nil ;};var _ea *_g .Client ;
|
||||
Prefix string ;};func _gecf (_dff _db .Image )float64 {_eaa :=_dff .Bounds ();var (_fgeg int ;_aa _a .Color ;_ae ,_bbe ,_gcc uint32 ;);_agd ,_ada :=_eaa .Min .X ,_eaa .Max .Y -1;_caa :=_dff .At (_agd ,_ada );_ab ,_bd ,_egb ,_ :=_caa .RGBA ();_ebc :=_ab ==_c .MaxUint16 &&_bd ==_c .MaxUint16 &&_egb ==_c .MaxUint16 ;
|
||||
for _ada =_eaa .Max .Y -1;_ada >=_eaa .Min .Y ;_ada --{var _abe bool ;for _agd =_eaa .Min .X ;_agd < _eaa .Max .X ;_agd ++{_aa =_dff .At (_agd ,_ada );_ae ,_bbe ,_gcc ,_ =_aa .RGBA ();if (_ebc &&!(_ae ==_ab &&_bbe ==_bd &&_egb ==_gcc ))||(!_ebc &&(_c .Abs (float64 (_ae )-float64 (_ab ))/float64 (_c .MaxUint16 )> 0.03||_c .Abs (float64 (_bbe )-float64 (_bd ))/float64 (_c .MaxUint16 )> 0.03||_c .Abs (float64 (_gcc )-float64 (_egb ))/float64 (_c .MaxUint16 )> 0.03)){_abe =true ;
|
||||
break ;};};if _abe {break ;};_fgeg =_ada ;};return float64 (_eaa .Max .Y -_fgeg )/float64 (_eaa .Max .Y );};
|
||||
|
||||
// Connect creates UniHTML HTTP Client and tries to establish connection with the server.
|
||||
func Connect (path string )error {if _ee :=_eeb ();_ee !=nil {return _ee ;};_gb ,_cd :=_dba .ParseOptions (path );if _cd !=nil {return _cd ;};_ef =_dba .New (_gb );_ec ,_bg :=_d .WithTimeout (_d .Background (),_f .Second *5);defer _bg ();if _ea :=_ef .HealthCheck (_ec );
|
||||
_ea !=nil {return _ea ;};return nil ;};
|
||||
|
||||
// ChapterDraw implements creator.containerElement interface.
|
||||
func (_ac *Document )ContainerComponent (container _fe .Drawable )(_fe .Drawable ,error ){switch container .(type ){case *_fe .Chapter :default:return nil ,_ga .Errorf ("\u0075\u006e\u0069\u0068t\u006d\u006c\u002e\u0044\u006f\u0063\u0075\u006d\u0065n\u0074\u0020\u0063\u0061\u006e\u0027\u0074\u0020\u0062\u0065\u0020\u0061\u0020\u0063\u006f\u006d\u0070\u006fn\u0065\u006e\u0074\u0020\u006ff\u0020\u0074\u0068\u0065\u0020\u0025\u0054\u0020\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0065\u0072",container );
|
||||
};return _ac ,nil ;};var ErrNoClient =_fc .New ("\u0055n\u0069\u0048\u0054\u004d\u004c\u0020\u0063\u006c\u0069\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0066\u006f\u0075\u006e\u0064");
|
||||
|
||||
// GetPdfPages is a function that converts provided input content and
|
||||
func (_bb *Document )GetPdfPages (ctx _d .Context )([]*_fd .PdfPage ,error ){if _ca :=_bb .validate ();_ca !=nil {return nil ,_ca ;};return _bb .extract (ctx ,_bb ._ge ,_bb ._gec ,_bb .getMargins ());};
|
||||
|
||||
// SetPageHeight sets the page height for given document.
|
||||
func (_gd *Document )SetPageHeight (pageHeight _dc .Length )error {_gd ._dd =pageHeight ;_gd ._dcc =_dbf .PositionAbsolute ;return nil ;};
|
||||
func (_fed *Document )SetPageHeight (pageHeight _df .Length )error {_fed ._gec =pageHeight ;_fed ._dg =_fe .PositionAbsolute ;return nil ;};
|
||||
|
||||
// SetMarginLeft sets the left margin.
|
||||
func (_cdf *Document )SetMarginLeft (margin _df .Length ){_cdf ._cce .Left =margin };func (_abf *Document )validate ()error {if _ef ==nil {return ErrNoClient ;};if _abf ._dbc ==nil {return ErrContentNotDefined ;};return nil ;};func (_cffb *Document )extract (_gdf _d .Context ,_ebb ,_def _df .Length ,_ade margins )([]*_fd .PdfPage ,error ){_dbcf :=_dba .BuildHTMLQuery ().SetContent (_cffb ._dbc ).PageSize (_cffb ._gd ).PaperWidth (_ebb ).PaperHeight (_def ).Orientation (_cffb ._ggb ).MarginLeft (_ade .Left ).MarginRight (_ade .Right ).MarginTop (_ade .Top ).MarginBottom (_ade .Bottom );
|
||||
_dgde ,_fcf :=_dbcf .Query ();if _fcf !=nil {return nil ,_fcf ;};_gdf ,_gecg :=_d .WithTimeout (_gdf ,_f .Second *15);defer _gecg ();_agc ,_fcf :=_ef .ConvertHTML (_gdf ,_dgde );if _fcf !=nil {return nil ,_fcf ;};_dgg :=_cc .NewReader (_agc .Data );_cg ,_fcf :=_fd .NewPdfReader (_dgg );
|
||||
if _fcf !=nil {return nil ,_fcf ;};return _cg .PageList ,nil ;};
|
||||
|
||||
// SetMarginBottom sets the left margin.
|
||||
func (_feff *Document )SetMarginBottom (margin _df .Length ){_feff ._cce .Bottom =margin };
|
||||
|
||||
// GeneratePageBlocks implements creator.Drawable interface.
|
||||
func (_cb *Document )GeneratePageBlocks (ctx _fe .DrawContext )([]*_fe .Block ,_fe .DrawContext ,error ){if _bad :=_cb .validate ();_bad !=nil {return nil ,ctx ,_bad ;};var _gc []*_fe .Block ;_dbe :=_cb .getMargins ();_ad ,_bf :=_cb ._ge ,_cb ._gec ;if _cb ._dg .IsRelative (){_ad ,_bf =_df .Point (ctx .Width ),_df .Point (ctx .Height );
|
||||
ctx .X -=float64 (_dbe .Left .Points ());};_gee ,_geeg :=_cb .extract (_d .Background (),_ad ,_bf ,_dbe );if _geeg !=nil {return nil ,_fe .DrawContext {},_geeg ;};for _da ,_be :=range _gee {_fa ,_bbd :=_fe .NewBlockFromPage (_be );if _bbd !=nil {return nil ,_fe .DrawContext {},_bbd ;
|
||||
};var _dgd float64 ;if _cb ._ce &&_da ==len (_gee )-1{_eg :=_dc .NewImageDevice ();_fae ,_dab :=_eg .Render (_be );if _dab !=nil {return nil ,_fe .DrawContext {},_dab ;};_gf ,_dab :=_be .GetMediaBox ();if _dab !=nil {return nil ,_fe .DrawContext {},_dab ;
|
||||
};_gdb :=_f .Now ();_de :=_gecf (_fae );_dgd =_gf .Height ()*_de ;_ff .Log .Trace ("\u0054\u0072i\u006d\u006d\u0069\u006eg\u0020\u006ca\u0073\u0074\u0020\u0064\u006f\u0063\u0075\u006de\u006e\u0074\u0020\u0070\u0061\u0067\u0065\u0020\u0074\u0061\u006b\u0065n\u003a\u0020\u0025\u0076",_f .Since (_gdb ));
|
||||
if _cb ._cce .Bottom !=nil {_dgd -=float64 (_cb ._cce .Bottom .Points ());};if _dgd < 0{_dgd =0;};_ff .Log .Trace ("C\u0072\u006f\u0070\u0070\u0069\u006e\u0067\u0020\u0064\u006f\u0063\u0075\u006d\u0065\u006e\u0074\u0027\u0073\u0020\u0070\u0061\u0067\u0065\u0020\u0025\u002e2\u0066 \u0070\u006f\u0069\u006et\u0073\u0020o\u0066\u0066\u0020\u0062\u006f\u0074\u0074\u006f\u006d\u0020\u006f\u0066\u0020\u006d\u0065\u0064\u0069\u0061\u0020\u0062\u006f\u0078\u000a",_dgd );
|
||||
};_dbee ,_fge ,_bbd :=_fa .GeneratePageBlocks (ctx );if _bbd !=nil {return nil ,_fe .DrawContext {},_bbd ;};ctx =_fge ;ctx .Y -=_dgd ;if _da !=len (_gee )-1&&ctx .Y > (ctx .PageHeight -ctx .Margins .Bottom )*.95{ctx .X =ctx .Margins .Left ;ctx .Y =ctx .Margins .Top ;
|
||||
ctx .Page ++;};_gc =append (_gc ,_dbee ...);};return _gc ,ctx ,nil ;};func _eeb ()error {_gg :=_gaa .GetLicenseKey ();if _gg ==nil {return _fc .New ("\u006e\u006f\u0020\u006cic\u0065\u006e\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");
|
||||
};if !_gg .IsLicensed (){return _fc .New ("\u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u006f\u0072 \u006e\u006f\u0020\u006c\u0069\u0063\u0065n\u0073\u0065\u0020\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064");};if !_gg .UniHTML {return _fc .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020l\u0069\u0063e\u006e\u0073\u0065\u0020\u0069\u0073 \u006e\u006f\u0074\u0020\u0076\u0061\u006c\u0069d\u0020\u0066\u006f\u0072\u0020\u0074\u0068\u0065\u0020U\u006e\u0069\u0048\u0054\u004d\u004c\u0020\u0065\u0078\u0074\u0065n\u0073\u0069\u006f\u006e.\u0020\u0056i\u0073i\u0074\u003a\u0020\u0068\u0074\u0074\u0070s\u003a/\u002f\u0077\u0077\u0077\u002e\u0075\u006e\u0069\u0064\u006f\u0063\u002e\u0069\u006f\u0020\u0061\u006ed\u0020c\u006f\u006e\u0074\u0061\u0063\u0074\u0020\u0073\u0075\u0070\u0070\u006f\u0072t");
|
||||
};return nil ;};
|
||||
|
||||
// SetMarginTop sets the left margin.
|
||||
func (_eag *Document )SetMarginTop (margin _df .Length ){_eag ._cce .Top =margin };
|
||||
|
||||
// SetMarginRight sets the left margin.
|
||||
func (_cff *Document )SetMarginRight (margin _df .Length ){_cff ._cce .Right =margin };
|
||||
|
||||
// TrimLastPageContent trims the last page content so that next creator blocks are located just at the end of given block.
|
||||
func (_dfa *Document )TrimLastPageContent (){_dfa ._ce =true };
|
||||
|
||||
// SetMargins sets the Document Margins.
|
||||
func (_cea *Document )SetMargins (left ,right ,top ,bottom float64 ){_cea ._cce .Left =_df .Point (left );_cea ._cce .Right =_df .Point (right );_cea ._cce .Top =_df .Point (top );_cea ._cce .Bottom =_df .Point (bottom );_cea ._dg =_fe .PositionAbsolute ;
|
||||
};var ErrContentNotDefined =_fc .New ("\u0068\u0074\u006d\u006c\u0020\u0064o\u0063\u0075\u006d\u0065\u006e\u0074\u0020\u0063\u006f\u006e\u0074\u0065\u006et\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
|
||||
|
||||
// ConnectOptions creates UniHTML HTTP Client and tries to establish connection with the server.
|
||||
func ConnectOptions (o Options )error {_ef =_dba .New (_dba .Options {Hostname :o .Hostname ,Port :o .Port ,HTTPS :o .Secure });_fef ,_gaf :=_d .WithTimeout (_d .Background (),_f .Second *5);defer _gaf ();if _cf :=_ef .HealthCheck (_fef );_cf !=nil {return _cf ;
|
||||
};return nil ;};
|
||||
|
||||
// SetPageSize sets the page default size.
|
||||
func (_dcd *Document )SetPageSize (pageSize _df .PageSize )error {if !pageSize .IsAPageSize (){return _fc .New ("\u0070\u0072\u006f\u0076\u0069\u0064\u0065\u0064\u0020\u0069\u006ev\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0067\u0065\u0020s\u0069\u007a\u0065");
|
||||
};_dcd ._gd =pageSize ;_dcd ._dg =_fe .PositionAbsolute ;return nil ;};
|
||||
|
||||
// SetPos sets the absolute position. Changes object positioning to absolute.
|
||||
func (_dfd *Document )SetPos (x ,y float64 ){_dfd ._dg =_fe .PositionAbsolute ;_dfd ._eb =x ;_dfd ._fcd =y ;};
|
||||
|
||||
// NewDocument creates new HTML Document used as an input for the creator.Drawable.
|
||||
func NewDocument (path string )(*Document ,error ){_geb :=&Document {};_eba ,_ag :=_g .Parse (path );if _ag !=nil {return nil ,_ag ;};switch _eba .Scheme {case "\u0068\u0074\u0074\u0070","\u0068\u0074\u0074p\u0073":_geb ._dbc ,_ag =_ba .NewWebURL (path );
|
||||
if _ag !=nil {return nil ,_ag ;};return _geb ,nil ;};_ebd ,_ag :=_e .Stat (path );if _ag !=nil {return nil ,_ag ;};if !_ebd .IsDir (){_geb ._dbc ,_ag =_ba .NewHTMLFile (path );}else {_geb ._dbc ,_ag =_ba .NewZipDirectory (path );};if _ag !=nil {return nil ,_ag ;
|
||||
};return _geb ,nil ;};
|
||||
|
||||
// SetLandscapeOrientation sets document landscape page orientation.
|
||||
func (_aga *Document )SetLandscapeOrientation (){_aga ._ggb =_df .Landscape };
|
Loading…
x
Reference in New Issue
Block a user