Beispiel #1
0
        public async Task <ActionResult <SubmitResult> > Submit([FromBody] SubmitRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId, GatherManager.PermissionsList))
            {
                return(Unauthorized());
            }

            var rule = await _ruleRepository.GetAsync(request.RuleId);

            //var regexListArea = GatherUtils.GetRegexArea(rule.ListAreaStart, rule.ListAreaEnd);

            //var regexContentUrl = GatherUtils.GetRegexUrl(rule.ContentUrlStart, rule.ContentUrlEnd);
            //var regexImageUrl = string.Empty;
            //if (rule.ImageSource == ImageSource.List)
            //{
            //    regexImageUrl = GatherUtils.GetRegexUrl(rule.ImageUrlStart, rule.ImageUrlEnd);
            //}

            var items = await GatherUtils.GetItemsAsync(request.GatherUrl, rule);

            return(new SubmitResult
            {
                Items = items
            });

            //var urls = GatherUtils.GetContentAndImageUrls(request.GatherUrl, rule.Charset, rule.CookieString, regexListArea, regexContentUrl, regexImageUrl);

            //return new SubmitResult
            //{
            //    ContentUrls = urls.contentUrls,
            //    ImageUrls = urls.imageUrls
            //};
        }
Beispiel #2
0
        public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId, GatherManager.PermissionsList))
            {
                return(Unauthorized());
            }

            var rule = await _ruleRepository.GetAsync(request.RuleId);

            var items = await GatherUtils.GetItemsAsync(request.ListUrl, rule);

            var item = items.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(x.Url, request.ContentUrl));

            var attributes = await GatherUtils.GetContentNameValueCollectionAsync(rule, item);

            var list = new List <KeyValuePair <string, string> >();

            //var contentAttributes = Context.ContentApi.GetInputStyles(siteId, rule.ChannelId);

            foreach (var attributeName in attributes.AllKeys)
            {
                var value = attributes[attributeName];

                if (string.IsNullOrEmpty(value))
                {
                    continue;
                }
                if (StringUtils.EqualsIgnoreCase(nameof(SSCMS.Models.Content.ImageUrl), attributeName))
                {
                    var imageUrl = GatherUtils.GetUrlByBaseUrl(value, request.ContentUrl);
                    list.Add(new KeyValuePair <string, string>(attributeName, imageUrl));
                }
                else
                {
                    list.Add(new KeyValuePair <string, string>(attributeName, value));
                }
            }

            return(new GetResult
            {
                Attributes = list
            });
        }