using System;
namespace PolyFeed
{
public enum SourceType { HTML, XML, JSON };
public class SelectorSettings
{
///
/// A selector that matches against an element to select.
///
public string Selector { get; set; }
///
/// The name of the attribute to get the value of.
/// Set to an empty string to select the content of the element instead of the
/// content of an attribute.
///
public string Attribute { get; set; }
public override string ToString()
{
return $"[SelectorSettings Selector = {Selector}, Attribute = {Attribute}]";
}
}
public class FeedSettings
{
public string Output { get; set; }
///
/// The url of the source document to parse.
///
/// The URL.
public string Url { get; set; }
///
/// The type of source document to expect.
///
public string SourceType { get; set; }
///
/// The title of the feed.
/// Supports the same {} syntax as .
///
public string Title { get; set; }
///
/// The subtitle of the feed.
/// Supports the same {} syntax as .
///
/// The subtitle.
public string Subtitle { get; set; }
///
/// Selector that matches against the feed logo url.
///
public SelectorSettings Logo { get; set; }
}
public class EntrySettings
{
///
/// The selector that specifies the location of nodes in the object model that
/// should be added to the feed.
/// The format varies depending on the .
/// - HTML: CSS selector (e.g. main > article)
/// - XML: XPath (e.g. //element_name)
/// - JSON: Dotted object (e.g. items.fruit)
///
public string Selector { get; set; }
///
/// Selector settings to get the URL that an entry should link to.
///
public SelectorSettings Url { get; set; } = new SelectorSettings() { Attribute = "href" };
///
/// The title of an entry.
/// Selectors may be included in curly braces {} to substitute in content.
/// Such selectors are relative to the current feed entry.
/// The format varies in the same way as does.
///
public string Title { get; set; }
///
/// Same as , but for the body of an entry. HTML is allowed.
///
public string Content { get; set; }
///
/// The selector for the date published for an entry.
///
public SelectorSettings Published { get; set; }
///
/// The selector for the date published for an entry.
///
public SelectorSettings LastUpdated { get; set; }
///
/// The selector for the name of the author of an entry.
///
public SelectorSettings AuthorName { get; set; }
///
/// The selector for the url that points to a page that represents
/// the author of an entry.
///
public SelectorSettings AuthorUrl { get; set; }
}
public class FeedSource
{
public FeedSettings Feed { get; set; }
public EntrySettings Entries { get; set; }
}
}