mirror of
https://github.com/miniflux/v2.git
synced 2025-08-16 18:01:37 +00:00
Refactor assets bundler and split Javascript files
This commit is contained in:
parent
e1c56b2e53
commit
53deb0b8cd
49 changed files with 2837 additions and 2000 deletions
24
vendor/github.com/tdewolff/minify/html/html.go
generated
vendored
24
vendor/github.com/tdewolff/minify/html/html.go
generated
vendored
|
@ -80,10 +80,10 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
|
|||
return err
|
||||
}
|
||||
case html.CommentToken:
|
||||
if o.KeepConditionalComments && len(t.Text) > 6 && (bytes.HasPrefix(t.Text, []byte("[if ")) || bytes.Equal(t.Text, []byte("[endif]"))) {
|
||||
if o.KeepConditionalComments && len(t.Text) > 6 && (bytes.HasPrefix(t.Text, []byte("[if ")) || bytes.Equal(t.Text, []byte("[endif]")) || bytes.Equal(t.Text, []byte("<![endif]"))) {
|
||||
// [if ...] is always 7 or more characters, [endif] is only encountered for downlevel-revealed
|
||||
// see https://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx#syntax
|
||||
if bytes.HasPrefix(t.Data, []byte("<!--[if ")) { // downlevel-hidden
|
||||
if bytes.HasPrefix(t.Data, []byte("<!--[if ")) && len(t.Data) > len("<!--[if ]><![endif]-->") { // downlevel-hidden
|
||||
begin := bytes.IndexByte(t.Data, '>') + 1
|
||||
end := len(t.Data) - len("<![endif]-->")
|
||||
if _, err := w.Write(t.Data[:begin]); err != nil {
|
||||
|
@ -95,7 +95,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
|
|||
if _, err := w.Write(t.Data[end:]); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if _, err := w.Write(t.Data); err != nil { // downlevel-revealed
|
||||
} else if _, err := w.Write(t.Data); err != nil { // downlevel-revealed or short downlevel-hidden
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -281,13 +281,16 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
|
|||
attrs := tb.Attributes(html.Content, html.Http_Equiv, html.Charset, html.Name)
|
||||
if content := attrs[0]; content != nil {
|
||||
if httpEquiv := attrs[1]; httpEquiv != nil {
|
||||
content.AttrVal = minify.ContentType(content.AttrVal)
|
||||
if charset := attrs[2]; charset == nil && parse.EqualFold(httpEquiv.AttrVal, []byte("content-type")) && bytes.Equal(content.AttrVal, []byte("text/html;charset=utf-8")) {
|
||||
httpEquiv.Text = nil
|
||||
content.Text = []byte("charset")
|
||||
content.Hash = html.Charset
|
||||
content.AttrVal = []byte("utf-8")
|
||||
if charset := attrs[2]; charset == nil && parse.EqualFold(httpEquiv.AttrVal, []byte("content-type")) {
|
||||
content.AttrVal = minify.Mediatype(content.AttrVal)
|
||||
if bytes.Equal(content.AttrVal, []byte("text/html;charset=utf-8")) {
|
||||
httpEquiv.Text = nil
|
||||
content.Text = []byte("charset")
|
||||
content.Hash = html.Charset
|
||||
content.AttrVal = []byte("utf-8")
|
||||
}
|
||||
} else if parse.EqualFold(httpEquiv.AttrVal, []byte("content-style-type")) {
|
||||
content.AttrVal = minify.Mediatype(content.AttrVal)
|
||||
defaultStyleType, defaultStyleParams = parse.Mediatype(content.AttrVal)
|
||||
if defaultStyleParams != nil {
|
||||
defaultInlineStyleParams = defaultStyleParams
|
||||
|
@ -296,6 +299,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
|
|||
defaultInlineStyleParams = map[string]string{"inline": "1"}
|
||||
}
|
||||
} else if parse.EqualFold(httpEquiv.AttrVal, []byte("content-script-type")) {
|
||||
content.AttrVal = minify.Mediatype(content.AttrVal)
|
||||
defaultScriptType, defaultScriptParams = parse.Mediatype(content.AttrVal)
|
||||
}
|
||||
}
|
||||
|
@ -365,7 +369,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
|
|||
if attr.Traits&caselessAttr != 0 {
|
||||
val = parse.ToLower(val)
|
||||
if attr.Hash == html.Enctype || attr.Hash == html.Codetype || attr.Hash == html.Accept || attr.Hash == html.Type && (t.Hash == html.A || t.Hash == html.Link || t.Hash == html.Object || t.Hash == html.Param || t.Hash == html.Script || t.Hash == html.Style || t.Hash == html.Source) {
|
||||
val = minify.ContentType(val)
|
||||
val = minify.Mediatype(val)
|
||||
}
|
||||
}
|
||||
if rawTagHash != 0 && attr.Hash == html.Type {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue