public UserTemplate(SporeServerUser author, SporeServerAsset[] assets) { // <feed /> // var document = AtomFeedBuilder.CreateDocument("feed"); // <id /> AtomFeedBuilder.AddCustomElement(document, "id", $"tag:spore.com,2006:user/{author.Id}"); // <title /> AtomFeedBuilder.AddCustomElement(document, "title", $"{author.UserName}"); // <updated /> // TODO AtomFeedBuilder.AddCustomElement(document, "updated", $"{XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc)}"); // <author /> AtomFeedBuilder.AddAuthorElement(document, $"{author.UserName}", $"{author.Id}"); // <subcount /> // TODO? AtomFeedBuilder.AddCustomElement(document, "subcount", "0"); // <link /> AtomFeedBuilder.AddLinkElement(document, "self", $"https://pollinator.spore.com/pollinator/atom/user/{author.Id}", null, null); // add assets to feed SporeAtomFeedHelper.AddAssetsToFeed(document, assets); // save xml _xml = document.OuterXml; }
public AggregatorTemplate(SporeServerAggregator aggregator, int subscriberCount) { // <feed /> // var document = AtomFeedBuilder.CreateDocument("feed"); // <id /> AtomFeedBuilder.AddCustomElement(document, "id", $"tag:spore.com,2006:aggregator/{aggregator.AggregatorId}"); // <title /> AtomFeedBuilder.AddCustomElement(document, "title", $"{aggregator.Name}"); // <updated /> AtomFeedBuilder.AddCustomElement(document, "updated", $"{XmlConvert.ToString(aggregator.Timestamp, XmlDateTimeSerializationMode.Utc)}"); // <subtitle /> AtomFeedBuilder.AddCustomElement(document, "subtitle", $"{aggregator.Description}"); // <author /> AtomFeedBuilder.AddAuthorElement(document, $"{aggregator.Author.UserName}", $"{aggregator.Author.Id}"); // <subcount /> AtomFeedBuilder.AddCustomElement(document, "subcount", $"{subscriberCount}"); // <link /> AtomFeedBuilder.AddLinkElement(document, "self", $"https://www.spore.com/pollinator/atom/aggregator/{aggregator.AggregatorId}", null, null); // add assets to feed SporeAtomFeedHelper.AddAssetsToFeed(document, aggregator.Assets.ToArray()); // save xml _xml = document.OuterXml; }
public RandomAssetTemplate(SporeServerAsset[] assets) { // <feed /> // var document = AtomFeedBuilder.CreateDocument("feed"); // <id /> AtomFeedBuilder.AddCustomElement(document, "id", "tag:spore.com,2006:randomAsset"); // <title /> AtomFeedBuilder.AddCustomElement(document, "title", "randomAsset"); // <updated /> AtomFeedBuilder.AddCustomElement(document, "updated", $"{XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc)}"); // <link /> AtomFeedBuilder.AddLinkElement(document, "self", "https://pollinator.spore.com/pollinator/atom/randomAsset", null, null); // add assets to feed SporeAtomFeedHelper.AddAssetsToFeed(document, assets); // save xml _xml = document.OuterXml; }
/// <summary> /// Creates an ATOM feed entry for the given asset /// </summary> /// <param name="document"></param> /// <param name="asset"></param> public static void AddAssetFeedEntry(XmlDocument document, SporeServerAsset asset) { // <entry /> // var entryFeed = AtomFeedBuilder.AddFeedEntry(document, id: $"tag:spore.com,2006:asset/{asset.AssetId}", title: $"{asset.Name}", updated: asset.Timestamp, subtitle: null, authorName: $"{asset.Author.UserName}", authorUri: $"{asset.Author.Id}", subCount: null, link: null); // <locale /> // TODO AtomFeedBuilder.AddCustomElement(document, entryFeed, "locale", "en_US"); // <modeltype /> AtomFeedBuilder.AddCustomElement(document, entryFeed, "modeltype", $"0x{((Int64)asset.ModelType):x2}"); // <sp:stats /> // TODO if (asset.Type == SporeAssetType.Adventure) { var statsElement = AtomFeedBuilder.AddCustomElement(document, entryFeed, "sp:stats"); // <sp:stat name="playcount" /> var statElement = AtomFeedBuilder.AddCustomElement(document, statsElement, "sp:stat", "0"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "name", "playcount"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "type", "int"); // <sp:stat name="difficulty" /> statElement = AtomFeedBuilder.AddCustomElement(document, statsElement, "sp:stat", "0"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "name", "difficulty"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "type", "int"); // <sp:stat name="rating" /> statElement = AtomFeedBuilder.AddCustomElement(document, statsElement, "sp:stat", $"{asset.Rating}"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "name", "rating"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "type", "float"); // <sp:stat name="pointvalue" /> statElement = AtomFeedBuilder.AddCustomElement(document, statsElement, "sp:stat", "0"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "name", "pointvalue"); AtomFeedBuilder.AddCustomAttribute(document, statElement, "type", "int"); } // <sp:images /> // if (asset.Type == SporeAssetType.Adventure) { var imagesElement = AtomFeedBuilder.AddCustomElement(document, entryFeed, "sp:images", null); // <sp:image_1 /> if (asset.ImageFileUrl != null) { AtomFeedBuilder.AddLinkElement(document, imagesElement, name: "sp:image_1", rel: null, url: $"https://static.spore.com/{asset.ImageFileUrl}", type: "image/png", length: null); } // <sp:image_2 /> if (asset.ImageFile2Url != null) { AtomFeedBuilder.AddLinkElement(document, imagesElement, name: "sp:image_2", rel: null, url: $"https://static.spore.com/{asset.ImageFile2Url}", type: "image/png", length: null); } // <sp:image_3 /> if (asset.ImageFile3Url != null) { AtomFeedBuilder.AddLinkElement(document, imagesElement, name: "sp:image_3", rel: null, url: $"https://static.spore.com/{asset.ImageFile3Url}", type: "image/png", length: null); } // <sp:image_4 /> if (asset.ImageFile4Url != null) { AtomFeedBuilder.AddLinkElement(document, imagesElement, name: "sp:image_4", rel: null, url: $"https://static.spore.com/{asset.ImageFile4Url}", type: "image/png", length: null); } } // <sp:ownership /> // var ownershipElement = AtomFeedBuilder.AddCustomElement(document, entryFeed, "sp:ownership"); // <sp:original /> var originalElement = AtomFeedBuilder.AddCustomElement(document, ownershipElement, "sp:original", $"{asset.OriginalAssetId}"); AtomFeedBuilder.AddCustomAttribute(document, originalElement, "name", "id"); AtomFeedBuilder.AddCustomAttribute(document, originalElement, "type", "int"); // <sp:parent /> var parentElement = AtomFeedBuilder.AddCustomElement(document, ownershipElement, "sp:parent", $"{asset.ParentAssetId}"); AtomFeedBuilder.AddCustomAttribute(document, parentElement, "name", "id"); AtomFeedBuilder.AddCustomAttribute(document, parentElement, "type", "int"); // <content /> // var contentElement = AtomFeedBuilder.AddCustomElement(document, entryFeed, "content"); AtomFeedBuilder.AddCustomAttribute(document, contentElement, "type", "html"); // <img /> var imgElement = AtomFeedBuilder.AddCustomElement(document, contentElement, "img"); AtomFeedBuilder.AddCustomAttribute(document, imgElement, "src", $"https://static.spore.com/{asset.ThumbFileUrl}"); // <link /> // AtomFeedBuilder.AddLinkElement(document, entryFeed, rel: "enclosure", url: $"https://static.spore.com/{asset.ThumbFileUrl}", type: "image/png", length: $"{asset.Size}"); // <link /> // AtomFeedBuilder.AddLinkElement(document, entryFeed, rel: "enclosure", url: $"https://static.spore.com/{asset.ModelFileUrl}", type: $"application/x-{asset.Type.ToString().ToLower()}+xml", length: null); // <summary /> // AtomFeedBuilder.AddCustomElement(document, entryFeed, "summary", $"{asset.Description}"); // <category /> // if (asset.Tags != null) { for (int i = 0; i < asset.Tags.Count; i++) { // <category scheme="tag" term="tag1" /> // <category scheme="tag" term=" tag2" /> var tag = asset.Tags.ElementAt(i); var categoryElement = AtomFeedBuilder.AddCustomElement(document, entryFeed, "category"); AtomFeedBuilder.AddCustomAttribute(document, categoryElement, "scheme", "tag"); AtomFeedBuilder.AddCustomAttribute(document, categoryElement, "term", $"{(i == 0 ? "" : " ")}{tag.Tag}"); } } if (asset.Traits != null) { foreach (var trait in asset.Traits) { // <category scheme="consequence" term="0x2b35f523" /> var categoryElement = AtomFeedBuilder.AddCustomElement(document, entryFeed, "category"); AtomFeedBuilder.AddCustomAttribute(document, categoryElement, "scheme", "consequence"); AtomFeedBuilder.AddCustomAttribute(document, categoryElement, "term", $"0x{(Int64)trait.TraitType:x}"); } } }