mirror of
https://github.com/unidoc/unihtml.git
synced 2025-04-24 13:48:52 +08:00
72 lines
4.6 KiB
Go
72 lines
4.6 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// 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 (_b "archive/zip";_ab "bytes";_bd "fmt";_a "net/url";_d "os";_bc "strings";);
|
|
|
|
// Method gets the query method.
|
|
func (_bg *htmlFile )Method ()string {return "\u0068\u0074\u006d\u006c"};type htmlFile struct{_c _ab .Buffer };
|
|
|
|
// Content is an interface used for putting the content into Client Query.
|
|
type Content interface{ContentType ()string ;Method ()string ;Data ()[]byte ;};type webURL struct{_cd string };
|
|
|
|
// Data implements Content interface.
|
|
func (_bee *StringContent )Data ()[]byte {return []byte (_bee ._aca )};
|
|
|
|
// ContentType implements Content interface.
|
|
func (_bad *StringContent )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl";};
|
|
|
|
// Data implements Content interface.
|
|
func (_bgb *webURL )Data ()[]byte {return []byte (_bgb ._cd )};func (_af *zipDirectory )zipPath (_dcd ,_fa string )error {_abc ,_agf :=_d .ReadDir (_dcd );if _agf !=nil {return _bd .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",_dcd ,_agf );
|
|
};_de :=&_bc .Builder {};for _ ,_bae :=range _abc {_cc ,_faf :=_bae .Info ();if _faf !=nil {return _faf ;};_ee ,_eg :=_af .zipBasePaths (_cc ,_dcd ,_fa ,_bae .IsDir (),_de );if _bae .IsDir (){if _aag :=_af .zipPath (_ee ,_eg );_aag !=nil {return _aag ;
|
|
};continue ;};_gf ,_faf :=_d .ReadFile (_ee );if _faf !=nil {return _faf ;};_be ,_faf :=_af ._g .Create (_eg );if _faf !=nil {return _faf ;};if _ ,_faf =_be .Write (_gf );_faf !=nil {return _faf ;};};return nil ;};
|
|
|
|
// Method gets the zip directory method.
|
|
func (_ba *zipDirectory )Method ()string {return "\u0064\u0069\u0072"};
|
|
|
|
// NewWebURL creates new Content webURL for provided input URL path.
|
|
func NewWebURL (path string )(Content ,error ){if _ ,_cg :=_a .Parse (path );_cg !=nil {return nil ,_cg ;};return &webURL {_cd :path },nil ;};func (_dfe *zipDirectory )zipBasePaths (_gfa _d .FileInfo ,_gg ,_ffe string ,_ffed bool ,_gd *_bc .Builder )(string ,string ){_gd .WriteString (_gg );
|
|
if !_bc .HasSuffix (_gg ,"\u002f"){_gd .WriteRune ('/');};_gd .WriteString (_gfa .Name ());if _ffed {_gd .WriteRune ('/');};_ca :=_gd .String ();_gd .Reset ();_gd .WriteString (_ffe );_gd .WriteString (_gfa .Name ());if _ffed {_gd .WriteRune ('/');};_gbd :=_gd .String ();
|
|
_gd .Reset ();return _ca ,_gbd ;};
|
|
|
|
// Method gets the web url query method.
|
|
func (_ag *webURL )Method ()string {return "\u0077\u0065\u0062"};
|
|
|
|
// NewHTMLFile creates new Content htmFile for provided input path.
|
|
func NewHTMLFile (path string )(Content ,error ){_f ,_ff :=_d .Open (path );if _ff !=nil {return nil ,_ff ;};_bce :=&htmlFile {_c :_ab .Buffer {}};if _ ,_ff =_bce ._c .ReadFrom (_f );_ff !=nil {return nil ,_ff ;};return _bce ,nil ;};
|
|
|
|
// ContentType implements Content interface.
|
|
func (_aa *webURL )ContentType ()string {return "\u0074\u0065\u0078\u0074\u002f\u0070\u006c\u0061\u0069\u006e";};
|
|
|
|
// StringContent implements Content interface for an HTML string.
|
|
type StringContent struct{_aca string };
|
|
|
|
// ContentType implements Content interface.
|
|
func (_fg *zipDirectory )ContentType ()string {return "\u0061p\u0070l\u0069\u0063\u0061\u0074\u0069\u006f\u006e\u002f\u007a\u0069\u0070";};
|
|
|
|
// NewStringContent creates a new StringContent.
|
|
func NewStringContent (html string )(*StringContent ,error ){return &StringContent {_aca :html },nil };
|
|
|
|
// Data implements Content interface.
|
|
func (_ac *zipDirectory )Data ()[]byte {return _ac ._cbb .Bytes ()};
|
|
|
|
// ContentType implements Content interface.
|
|
func (_dc *htmlFile )ContentType ()string {return "\u0074e\u0078\u0074\u002f\u0068\u0074\u006dl"};
|
|
|
|
// 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 ){_df :=&zipDirectory {_cbb :_ab .Buffer {}};_df ._g =_b .NewWriter (&_df ._cbb );if _dca :=_df .zipPath (dirPath ,"");_dca !=nil {return nil ,_dca ;};if _cgd :=_df ._g .Close ();_cgd !=nil {return nil ,_cgd ;
|
|
};return _df ,nil ;};
|
|
|
|
// Data implements Content interface.
|
|
func (_cb *htmlFile )Data ()[]byte {return _cb ._c .Bytes ()};
|
|
|
|
// Method implements Content interface.
|
|
func (_ga *StringContent )Method ()string {return "\u0068\u0074\u006d\u006c"};type zipDirectory struct{_cbb _ab .Buffer ;_g *_b .Writer ;}; |