Ejemplo n.º 1
0
        public Dictionary <string, string> GetBindings(Kooboo.Dom.Element El)
        {
            Dictionary <string, string> Bindings = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in El.attributes)
            {
                if (!IsIgnoreAttribute(item.name))
                {
                    Bindings[item.name] = item.value;
                }
            }

            if (!Service.DomService.IsSelfCloseTag(El.tagName))
            {
                // if (!Bindings.ContainsKey("innerHtml"))
                // {
                Bindings["innerHtml"] = El.InnerHtml;
                // }
                //else
                //{
                //    Bindings["innerKoobooText"] = El.InnerHtml;
                //}
            }

            return(Bindings);
        }
Ejemplo n.º 2
0
        public bool IsSystemTag(Kooboo.Dom.Element el)
        {
            if (el == null || string.IsNullOrEmpty(el.tagName))
            {
                return(false);
            }
            else
            {
                var name = el.tagName.ToLower();
                if (name == "layout" || name == "placeholder" || Kooboo.Sites.Render.Components.Manager.IsComponentElement(el))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static List <AnalyzerUpdate> ProcessInlineResource(Kooboo.Dom.Element inlineElement, string baseurl, DownloadManager manager, Guid OwnerObjectId)
        {
            List <AnalyzerUpdate> updates = new List <AnalyzerUpdate>();

            string csstext = inlineElement.getAttribute("style");

            if (string.IsNullOrEmpty(csstext))
            {
                return(updates);
            }

            var urlInfos = Service.CssService.GetUrlInfos(csstext);

            foreach (var item in urlInfos)
            {
                if (item.isImportRule)
                {
                    string newurl = AddImport(item.PureUrl, baseurl, manager, OwnerObjectId);
                    if (newurl != item.PureUrl)
                    {
                        updates.Add(new AnalyzerUpdate {
                            StartIndex = inlineElement.location.openTokenStartIndex, EndIndex = inlineElement.location.openTokenEndIndex, IsReplace = true, OldValue = item.PureUrl, NewValue = newurl
                        });
                    }
                }
                else
                {
                    string newurl = string.Empty;
                    if (Kooboo.Lib.Utilities.DataUriService.isDataUri(item.PureUrl))
                    {
                        newurl = ParseDataUri(item.PureUrl, manager);
                    }
                    else
                    {
                        newurl = DownloadCssFile(item.PureUrl, baseurl, manager, OwnerObjectId);
                    }

                    updates.Add(new AnalyzerUpdate {
                        StartIndex = inlineElement.location.openTokenStartIndex, EndIndex = inlineElement.location.openTokenEndIndex, IsReplace = true, OldValue = item.PureUrl, NewValue = newurl
                    });
                }
            }

            return(updates);
        }
Ejemplo n.º 4
0
        public string GetNonSrcUrl(Kooboo.Dom.Element imagetag)
        {
            if (imagetag == null)
            {
                return(null);
            }

            foreach (var item in imagetag.attributes)
            {
                if (item != null && item.name != null)
                {
                    string name = item.name.Trim().ToLower();
                    if (name != "src" && name.Contains("src"))
                    {
                        return(item.value);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        public KConfig GetOrAdd(string key, Kooboo.Dom.Element El)
        {
            var old = GetByNameOrId(key);

            if (old != null)
            {
                return(old);
            }
            else
            {
                KConfig config = new KConfig();
                config.Name    = key;
                config.TagHtml = El.OuterHtml;
                config.TagName = El.tagName;

                config.Binding = GetBindings(El);
                AddOrUpdate(config);
                return(config);
            }
        }
Ejemplo n.º 6
0
        private bool verify(RenderContext context, Kooboo.Dom.Element element, Guid ImageId)
        {
            if (element == null || element.tagName != "img")
            {
                return(false);
            }
            string src   = Service.DomUrlService.GetLinkOrSrc(element);
            var    route = context.WebSite.SiteDb().Routes.GetByObjectId(ImageId);

            if (route == null || string.IsNullOrEmpty(route.Name) || string.IsNullOrEmpty(src))
            {
                return(false);
            }

            if (route.Name.ToLower() != src.ToLower())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        public KConfigRenderTask(Kooboo.Dom.Element configEl, string key)
        {
            this.Key          = key;
            this.RenderValues = new List <KConfigValues>();

            this.OrgHtml = configEl.OuterHtml;

            this.IsSelfClose = Service.DomService.IsSelfCloseTag(configEl.tagName);

            string header = "<" + configEl.tagName;

            RenderValues.Add(new KConfigValues()
            {
                Value = header
            });

            foreach (var item in configEl.attributes)
            {
                if (item.name == "k-config")
                {
                    continue;
                }

                if (IsIgnoreAttribute(item.name))
                {
                    string attHtml = " " + item.name;
                    if (!string.IsNullOrEmpty(item.value))
                    {
                        attHtml += "=\"" + item.value + "\"";
                    }
                    RenderValues.Add(new KConfigValues()
                    {
                        Value = attHtml
                    });
                }
                else
                {
                    string start = " " + item.name;
                    start += "=\"";
                    RenderValues.Add(new KConfigValues()
                    {
                        Value = start
                    });
                    RenderValues.Add(new KConfigValues()
                    {
                        Key = item.name, Value = item.value, IsBinding = true
                    });
                    RenderValues.Add(new KConfigValues()
                    {
                        Value = "\""
                    });
                }
            }

            if (IsSelfClose)
            {
                RenderValues.Add(new KConfigValues()
                {
                    Value = " />"
                });
            }
            else
            {
                RenderValues.Add(new KConfigValues()
                {
                    Value = ">"
                });
                RenderValues.Add(new KConfigValues()
                {
                    Key = "innerHtml", Value = configEl.InnerHtml, IsBinding = true
                });
                string endtag = "</" + configEl.tagName + ">";
                RenderValues.Add(new KConfigValues()
                {
                    Value = endtag
                });
            }
        }