public PartialViewResult Comments(string workspace, string collection, int? year, int? month, int? day, string path)
    {
      FeedModel model = new FeedModel();
      model.Feed = AnnotateService.GetAnnotations(EntryId, true, 0, int.MaxValue);

      return PartialView("BlogCommentsWidget", model);
    }
Exemple #2
0
        public ActionResult <FeedModel> GetFeed([FromQuery] SearchRequest searchRequest)
        {
            var posts     = _posts.SearchFeed(searchRequest);
            var postCount = _posts.Count(searchRequest);

            return(FeedModel.Create(searchRequest, posts, postCount));
        }
Exemple #3
0
        public void ImprimirResultadoAnalisePorFeed(List <PalavraModel> palavras, FeedModel model = null)
        {
            var i = 1;

            if (model != null)
            {
                Console.WriteLine("Realizando análise para o tópico: " + model.Titulo);
                Console.WriteLine();
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Realizando análise para todos os tópicos");
                Console.WriteLine();
                Console.WriteLine();
            }

            foreach (var item in palavras.OrderByDescending(a => a.Quantidade))
            {
                Console.WriteLine(i++ + "ª - " + item.Nome + ", foi encontrada " + item.Quantidade + " vezes");
            }

            Console.WriteLine();
            Console.WriteLine("Sendo as 10 primeiras listadas as principais palavras abordadas no tópico analisado.");

            Console.WriteLine();
            Console.WriteLine();
        }
 public PartialViewResult FullFeed(string widgetName, Include include)
 {
   var i = new FeedInclude(include);
   if (!i.Count.HasValue) i.Count = int.MaxValue;
   FeedModel model = new FeedModel() { Feed = GetFeed(i, false) };
   return PartialView(widgetName, model);
 }
Exemple #5
0
        private ArticleModel FeedToArticleModel(ChildNode item, FeedModel fcm)
        {
            if (item == null || item.klub != null)
                return null;

            return ExecuteSafe(() =>
            {

                var a = ConstructArticleModel(fcm);

                a.Title = item.title;
                a.SubTitle = item.kicker;
                a.Teaser = item.text;
                a.LogicUri = item.linkURL;
                a.PublicUri = fcm.Source.PublicBaseUrl + item.docpath;

                if (item.teaserImageURL != null)
                {
                    var url = item.teaserImageURL;
                    if (url.Contains("w=320"))
                        url = url.Replace("w=320", "w=400");
                    a.LeadImage = new ImageContentModel() { Url = url };
                }

                return a;

            });
        }
Exemple #6
0
        public override Task<List<ArticleModel>> EvaluateFeed(FeedModel feedModel)
        {
            return ExecuteSafe(async () =>
            {
                var feed = await DownloadAsync(feedModel);
                var articlelist = new List<ArticleModel>();
                if (feed == null) return articlelist;

                var rootObj = JsonConvert.DeserializeObject<FeedRoot>(feed);

                if (rootObj == null)
                    LogHelper.Instance.Log(LogLevel.Error,
                        "BildHelper.EvaluateFeed failed: rootObj is null after deserialisation", this);
                else
                {
                    foreach (var children in rootObj.__childNodes__)
                    {
                        if (children.__childNodes__ != null)
                        {
                            foreach (var childNode in children.__childNodes__.Where(a => a.targetType == "article"))
                            {
                                var article = FeedToArticleModel(childNode, feedModel);
                                if (article != null)
                                    articlelist.Add(article);
                            }
                        }
                    }
                }
                return articlelist;
            });
        }
Exemple #7
0
 public ActionResult Reports(FeedModel model)
 {
     model.Provider           = Provider;
     model.CurrentPage        = "Feed";
     model.CurrentSubMenuItem = "reports";
     return(View(model));
 }
Exemple #8
0
        public async Task <IHttpActionResult> PutFeed(int id, FeedModel feed)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != feed.ID)
            {
                return(BadRequest());
            }

            db.Entry(_modelFactory.Unwrap(feed)).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeedExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public FeedPostAdapter(FeedModel model)
        {
            var postSelect = model.data.follows.SelectMany(n => n.posts).Reverse();

            //postSelect = postSelect.OrderByDescending(n => DateTime.ParseExact(n.createdAt.Substring(0,10),"yyyy-MM-dd",CultureInfo.InvariantCulture));
            this.items = postSelect.ToList();
        }
Exemple #10
0
        public ActionResult Console(FeedModel model)
        {
            model.Provider           = Provider;
            model.CurrentPage        = "Feed";
            model.CurrentSubMenuItem = "console";

            if (!string.IsNullOrEmpty(model.Alias))
            {
                //this means we are editing
                DataFeed feed = model.GetFeed();
                if (feed != null)
                {
                    model.Guid              = feed.FeedGUID.ToString();
                    model.Name              = feed.FeedName;
                    model.Description       = feed.FeedDescription;
                    model.Link              = feed.FeedLink;
                    model.Private           = feed.Private;
                    model.Active            = feed.Active;
                    model.FeedType          = feed.FeedType;
                    model.Query             = feed.FeedQuery;
                    model.DefaultParameters = feed.DefaultParameters;
                    model.Message           = GetAndRemoveSessionValue("SaveFeedMessage");
                    model.ErrorMessage      = GetAndRemoveSessionValue("SaveFeedError");
                }
            }
            else
            {
                model.Active = true;
            }

            return(View(model));
        }
Exemple #11
0
        public ArticleModel FeedToArticleModel(NzzFeedArticle nfa, FeedModel scm)
        {
            if (nfa == null || !nfa.path.Contains("/api/"))
            {
                return(null);
            }

            try
            {
                var a = ConstructArticleModel(scm);
                a.PublishDateTime = nfa.publicationDateTime;
                a.Title           = nfa.title;
                a.SubTitle        = nfa.subTitle;
                if (string.IsNullOrWhiteSpace(a.SubTitle) && nfa.title == "Was heute wichtig ist")
                {
                    a.SubTitle = "Dieser Artikel wird laufend aktualisiert";
                }

                a.LeadImage = LeadImageToImage(nfa.leadImage, scm);

                a.LogicUri = scm.Source.LogicBaseUrl + nfa.path.Substring("/api/".Length);
                var guid = nfa.path.Substring(nfa.path.LastIndexOf("/", StringComparison.Ordinal) + 1);
                a.PublicUri = scm.Source.PublicBaseUrl + guid;

                return(a);
            }
            catch (Exception ex)
            {
                LogHelper.Instance.Log(LogLevel.Error, "NzzHelper.FeedToArticleModel failed", this, ex);
                return(null);
            }
        }
Exemple #12
0
        private async Task LoadArticlesIntoFeed(FeedModel feed, int max = -1)
        {
            if (max == -1)
            {
                max = 100;
            }
            for (int i = 0; i < max; i++)
            {
                if (feed.AllArticles.Count <= i)
                {
                    var stringGuid = feed.Guid.ToString();
                    var realmax    = max == 0 ? 0 : max - i;
                    var relations  = await _sqliteService.GetByCondition <FeedArticleRelationEntity>(s => s.FeedGuid == stringGuid, s => s.Index, false, realmax, i);

                    foreach (var feedArticleRelationEntity in relations)
                    {
                        var article = await LoadHelper.LoadForFeed(feedArticleRelationEntity.ArticleId, feed, _sqliteService, _imageDownloadService);

                        feed.AllArticles.Add(article);
                    }
                }

                _imageDownloadService.Download(feed);

                //no more entries
                if (feed.AllArticles.Count <= i)
                {
                    return;
                }
            }
        }
Exemple #13
0
        // Public

        public FeedViewModel(FeedModel model)
        {
            this._model            = model;
            model.PropertyChanged += ModelOnPropertyChanged;

            AddFeedCommand = new RelayCommand(AddFeed, CanAddFeed);
        }
Exemple #14
0
 private ImageContentModel LeadImageToImage(NzzLeadImage li, FeedModel feedModel)
 {
     if (li != null)
     {
         try
         {
             var uri = ParseImageUri(li.path);
             if (uri != null)
             {
                 return(new ImageContentModel()
                 {
                     Text = new TextContentModel()
                     {
                         Content = HtmlConverter.CreateOnce(feedModel.Source.PublicBaseUrl).HtmlToParagraph(li.caption)
                     },
                     Url = uri
                 });
             }
         }
         catch (Exception ex)
         {
             LogHelper.Instance.Log(LogLevel.Error, "NzzHelper.LeadImageToImage deserialization failed", this, ex);
             return(null);
         }
     }
     return(null);
 }
Exemple #15
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title")] FeedModel feedModel)
        {
            if (id != feedModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(feedModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FeedModelExists(feedModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(feedModel));
        }
Exemple #16
0
        public EditFeedModelResponse Handle(EditFeedModelRequest message)
        {
            var feed  = _repository.Feeds.Load <NugetFeed>(message.Id);
            var model = new FeedModel(feed, false);

            return(new EditFeedModelResponse(model));
        }
 public PartialViewResult SizeAnnotations(string widgetName, Include include)
 {
   var i = new FeedInclude(include);
   if (!i.Count.HasValue) i.Count = 6;
   FeedModel model = new FeedModel() { Feed = GetFeed(i, true) };
   return PartialView(widgetName, model);
 }
Exemple #18
0
        public ActionResult EditFeed(int Id)
        {
            FeedModel model = new FeedModel();

            model = _feedMgr.GetById(Id);
            return(View("EditFeed", model));
        }
Exemple #19
0
        public FeedItemModel ParseFeedUrl(string rssUrl, bool isValid)
        {
            WebClient     wclient       = new WebClient();
            string        rssData       = wclient.DownloadString(rssUrl);
            XDocument     xml           = XDocument.Parse(rssData);
            FeedItemModel feedItemModel = new FeedItemModel();

            var feed = _feedRepo.GetSingleResult(x => x.Url == rssUrl);

            if (feed == null)
            {
                var feedModel = new FeedModel
                {
                    Name = rssUrl,
                    Url  = rssUrl
                };
                this.Save(feedModel);
                feedItemModel.Url_Id = feed.Id;
            }
            else
            {
                feedItemModel.Url_Id = feed.Id;
            }

            feedItemModel.FeedXML = xml.ToString();
            return(feedItemModel);
        }
Exemple #20
0
        public void Save(FeedModel model)
        {
            //_feedNameRepo.IsExist(x => x.Id == model..Id);
            var saveRssUrl = this._modelMapper.ModelMapper.Map <Feed>(model);

            _feedRepo.Save(saveRssUrl);
        }
        public ArticleModel FeedToArticleModel(HtmlNode hn, FeedModel feed)
        {
            if (hn == null)
            {
                return(null);
            }

            try
            {
                var a = new ArticleModel();

                var linknode = hn.ChildNodes.Descendants("a").FirstOrDefault();
                if (linknode != null)
                {
                    a.PublicUri = linknode.GetAttributeValue("href", null);
                    a.LogicUri  = a.PublicUri;

                    if (linknode.ChildNodes != null && linknode.ChildNodes.Any())
                    {
                        var img = linknode.ChildNodes[0];
                        a.LeadImage = new ImageContentModel()
                        {
                            Url = img.GetAttributeValue("src", null)
                        };
                    }
                }
                else
                {
                    //newsticker
                    return(null);
                }

                var titlenode = hn.ChildNodes.FirstOrDefault(atr => atr.GetAttributeValue("title", null) != null);
                if (titlenode != null)
                {
                    a.Title = titlenode.GetAttributeValue("title", null);
                }
                else
                {
                    return(null);
                }

                if (a.Title.Contains(":"))
                {
                    a.SubTitle = a.Title.Substring(a.Title.IndexOf(":", StringComparison.Ordinal) + 1).Trim();
                    a.Title    = a.Title.Substring(0, a.Title.IndexOf(":", StringComparison.Ordinal));
                }

                a.DownloadDateTime = DateTime.Now;
                a.Author           = "Chefredaktor";

                return(a);
            }
            catch (Exception ex)
            {
                LogHelper.Instance.Log(LogLevel.Error, "PostillonHelper.FeedToArticleModel failed", this, ex);
                return(null);
            }
        }
        public object TestFeed(FeedModel feed, [FromUri] bool down, [FromUri] bool debug = false)
        {
            try
            {
                var compile = new UrlCompile();
                var addrs   = compile.GetResult(feed.Address);
                var results = new List <ExtractResult>();

                foreach (var addr in addrs)
                {
                    feed.Address = addr.ToString();
                    var job  = new FeedJob();
                    var snap = job.DoTask(feed, false);

                    if (string.IsNullOrEmpty(feed.RuiJiExpression))
                    {
                        results.Add(new ExtractResult());
                        continue;
                    }

                    var block = RuiJiBlockParser.ParserBlock(feed.RuiJiExpression);

                    var result = RuiJiExtractor.Extract(snap.Content, block);

                    if (!debug)
                    {
                        CrawlTaskFunc.ClearContent(result);
                    }

                    if (down)
                    {
                        var s = new FileStorage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "www", "download"));

                        var files = result.Content.ToString().Replace("\r\n", "\n").Split('\n');
                        foreach (var file in files)
                        {
                            if (!string.IsNullOrEmpty(file) && Uri.IsWellFormedUriString(file, UriKind.Absolute))
                            {
                                var res = Crawler.Request(file);
                                var c   = new DownloadContentModel();
                                c.Url   = file.Trim();
                                c.IsRaw = res.IsRaw;
                                c.Data  = res.Data;

                                s.Insert(c);
                            }
                        }
                    }

                    results.Add(result);
                }

                return(results);
            }
            catch (Exception ex)
            {
                return(ex);
            }
        }
 public async Task UpdateFeed(FeedModel feedModel)
 {
     lock (glush)
     {
         context.Feeds.Update(feedModel);
     }
     await context.SaveChangesAsync();
 }
Exemple #24
0
        private async Task <dynamic> PostCreate(dynamic parameters, CancellationToken token)
        {
            FeedModel model   = this.Bind();
            var       request = new SaveFeedRequest(model);
            await _mediator.Send(request, token).ConfigureAwait(false);

            return(new RedirectResponse("/feed"));
        }
Exemple #25
0
 public void AddToFeeds(FeedModel feed)
 {
     if (feed != null)
     {
         _db.Feeds.Add(feed);
         _db.SaveChanges();
     }
 }
Exemple #26
0
 public static IMediaSourceHelper GetMediaSource(FeedModel fm, IThemeRepository themeRepository)
 {
     if (fm.Source != null)
     {
         return(GetMediaSource(fm.Source.Source, themeRepository));
     }
     return(null);
 }
 public async Task CreateFeed(FeedModel feedModel)
 {
     lock (glush)
     {
         context.Feeds.Add(feedModel);
     };
     await context.SaveChangesAsync();
 }
 protected ArticleModel ConstructArticleModel(FeedModel feed)
 {
     return(new ArticleModel()
     {
         DownloadDateTime = DateTime.Now,
         Feed = feed
     });
 }
Exemple #29
0
        protected override object GetEdit(dynamic parameters)
        {
            var id    = new ObjectId(parameters.id);
            var feed  = _feedBoard.GetFeed(id);
            var model = new FeedModel(feed, false);

            return(View["Edit", model]);
        }
Exemple #30
0
        private ArticleModel FeedToArticleModel(Item children, FeedModel fcm)
        {
            if (children == null)
            {
                return(null);
            }

            return(ExecuteSafe(() =>
            {
                var title = children.Title.Substring(0, children.Title.IndexOf(":", StringComparison.Ordinal));
                var subTitle = children.Title.Substring(children.Title.IndexOf(":", StringComparison.Ordinal) + 2);

                var bannedSubTitles = new[]
                {
                    "alle artikel",
                    "die wichtigsten artikel"
                };

                var bannedTitles = new[]
                {
                    "Newsblog",
                };

                var lowerSub = subTitle.ToLower();
                if (bannedSubTitles.Any(s => lowerSub.Contains(s)))
                {
                    return null;
                }

                if (bannedTitles.Any(s => title.Contains(s)))
                {
                    return null;
                }


                var a = ConstructArticleModel(fcm);
                a.Title = title;
                a.SubTitle = subTitle;
                a.Teaser = children.Description;
                a.PublishDateTime = DateTime.Parse(children.PubDate);
                a.PublicUri = children.Guid;
                a.LogicUri = children.Link;

                if (children.Enclosure != null)
                {
                    a.LeadImage = new ImageContentModel()
                    {
                        Url = children.Enclosure.Url
                    }
                }
                ;

                a.Themes.Clear();
                a.AfterSaveFunc = () => AddThemesAsync(a, new[] { children.Category });

                return a;
            }));
        }
Exemple #31
0
 public static void AddFeed(FeedModel fm, SourceModel source, bool isActive = false)
 {
     fm.Source = source;
     if (isActive)
     {
         fm.Source.ActiveFeeds.Add(fm);
     }
     fm.IsActive = isActive;
 }
Exemple #32
0
        public void AddJob(FeedModel feed)
        {
            var feedRequest = FeedModel.ToFeedRequest(feed);
            var dic         = new Dictionary <string, object>();

            dic.Add("request", feedRequest);

            AddJob(feed.Id.ToString(), feed.Scheduling, dic);
        }
Exemple #33
0
        public RssServiceFacts()
        {
            var item = new ItemModel
            {
                Title       = "Test title",
                Link        = "http://example.com/1",
                Description = "This is an example blog article"
            };

            var item2 = new ItemModel
            {
                Title       = "Test title 2",
                Link        = "http://example.com/2",
                Description = "This is a second example blog article"
            };

            var items = new List <ItemModel>()
            {
                item, item2
            };

            var feedModel = new FeedModel
            {
                FeedName = "My Favorite Feed",
                RssItems = items
            };
            var feedModels = new List <FeedModel> {
                feedModel
            };

            var feed = new RssFeed();

            feed.Title       = "Example blog feed";
            feed.Link        = "http://example.com/";
            feed.Description = "A fake blog for testing.";
            feed.Copyright   = "2019 Fake Bloggers Anonymous";
            feed.Items       = items;
            var serializedFeed = feed.Serialize();

            var httpClientFactoryMock = Substitute.For <IHttpClientFactory>();
            var optionsMock           = Substitute.For <IOptions <ReaderConfig> >();
            var fileRepositoryMock    = Substitute.For <IFileRepository>(optionsMock);

            var fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(serializedFeed)
            });

            var fakeHttpClient = new HttpClient(fakeHttpMessageHandler);

            httpClientFactoryMock.CreateClient().Returns(fakeHttpClient);

            fileRepositoryMock.LoadFeeds().Returns(Task.Run <List <FeedModel> >(() => feedModels));

            _rssService = new RssService(httpClientFactoryMock, fileRepositoryMock);
        }
    //[ActionOutputCache(60 * SEC, true)]
    public virtual ActionResult Listing(string workspace, string collection, int? page)
    {
      FeedModel model = new FeedModel();
      model.Feed = AtomPubService.GetFeed(Collection.Id, (page ?? 1) - 1, Collection.PageSize);
      var links = model.Feed.Links.ToList();
      links.Merge(new AtomLink()
      {
        Rel = "wlwmanifest",
        Type = "application/wlwmanifest+xml",
        Href = Url.RouteIdUri("BlogWriterManifest", Collection.Id)
      });

      //TODO: use default view

      Url.GetPagingLinks("BlogListing", Collection.Id, null, model.Feed.TotalResults ?? 0,
        (page ?? 1) - 1, Collection.PageSize, "text/html").ToList().ForEach(l => links.Merge(l));
      model.Feed.Links = links;

      return View("BlogListing", model);
    }
 private SortableItemMetaData CreateSortable(FeedModel aFeedModel, FeedItem aFeedItem)
 {
     return new SortableItemMetaData() {
         DateTimeStamp = aFeedModel.DateTimeStamp,
         FeedItem = aFeedItem
     };
 }
 public ActionResult ServiceIndex()
 {
   FeedModel model = new FeedModel();
   model.Feed = AtomPubService.GetFeed(0, 10);
   return View("AtomPubIndex", model);
 }
 public ActionResult WorkspaceIndex(string workspace)
 {
   FeedModel model = new FeedModel();
   model.Feed = AtomPubService.GetFeed(workspace, 0, 10);
   return View("AtomPubIndex", model);
 }
 public ActionResult CollectionIndex(string workspace, string collection)
 {
   FeedModel model = new FeedModel();
   model.Feed = AtomPubService.GetFeed(Collection.Id, 0, 10);
   return View("AtomPubIndex", model);
 }