//- $MasterPage_Load -// private void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { String blogGuid = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid); BlogMetaData blogMetaData = BlogAgent.GetBlogMetaData(blogGuid); //+ rsd.Attributes.Add("href", WebConfiguration.Domain + "rsd.xml"); wlwmanifest.Attributes.Add("href", WebConfiguration.Domain + "wlwmanifest.xml"); //+ hlBlogUrl.NavigateUrl = blogMetaData.Uri.AbsoluteUri; hlBlogUrl.Text = blogMetaData.Title; //+ image.Attributes.Add("onclick", "window.location='" + WebConfiguration.Domain + "'"); //+ rssLink.Attributes.Add("title", blogMetaData.FeedTitle); rssLink.Attributes.Add("href", blogMetaData.FeedUri.AbsoluteUri); rssLink.Attributes.Remove("id"); //+ hlFeedUrl.NavigateUrl = blogMetaData.FeedUri.AbsoluteUri; hlFeedUrl.Attributes.Add("title", "Subscribe to my feed"); hlFeedUrl.Attributes.Add("rel", "alternate"); hlFeedUrl.Attributes.Add("type", "application/rss+xml"); //+ litBlogDescription.Text = blogMetaData.Description; //+ } }
public async Task <ServiceResponse <List <BlogMetaData> > > GetLatestBlogGistsAsync() { ServiceResponse <List <BlogMetaData> > response = new ServiceResponse <List <BlogMetaData> >(); SearchParameters searchParameters = new SearchParameters(orderBy: new string[] { "LastModifiedDate desc" }, top: 3); SearchCredentials searchCredentials = new SearchCredentials(Environment.GetEnvironmentVariable(SEARCH_API_KEY_KEY)); try { using (SearchIndexClient client = new SearchIndexClient(SEARCH_SERVICE_NAME, SEARCH_INDEX_NAME, searchCredentials)) { List <BlogMetaData> metas = new List <BlogMetaData>(); DocumentSearchResult <Document> searchResult = await client.Documents.SearchAsync("*", searchParameters : searchParameters); foreach (SearchResult <Document> item in searchResult.Results) { string serializedDoc = JsonConvert.SerializeObject(item.Document); BlogMetaData metaData = JsonConvert.DeserializeObject <BlogMetaData>(serializedDoc); metas.Add(metaData); } response.Data = metas; } } catch (Exception ex) { response.Error = ex; } return(response); }
//- $SetDefaultHeader -// private String GetDefaultHeader() { String pageTitle = String.Empty; BlogMetaData blogMetaData = Themelia.Web.HttpData.GetScopedCacheItem <BlogMetaData>(Info.Scope, Info.BlogMetaData); if (blogMetaData != null) { pageTitle = blogMetaData.Title; } //+ return(pageTitle); }
//- @OnPostProcessorExecute -// public override System.Web.IHttpHandler OnPostProcessorExecute(System.Web.HttpContext context, System.Web.IHttpHandler activeHttpHandler, params Object[] parameterArray) { String blogGuid = HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid); BlogMetaData blogMetaData = HttpData.GetScopedCacheItem <BlogMetaData>(Info.Scope, Info.BlogMetaData); if (blogMetaData == null) { blogMetaData = Minima.Service.Agent.BlogAgent.GetBlogMetaData(blogGuid); HttpData.SetScopedCacheItem <BlogMetaData>(Info.Scope, Info.BlogMetaData, blogMetaData); } //+ return(activeHttpHandler); }
//- @OnPostProcessorExecute -// public override System.Web.IHttpHandler Execute(System.Web.IHttpHandler activeHttpHandler) { String blogGuid = HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid); BlogMetaData blogMetaData = HttpData.GetScopedCacheItem <BlogMetaData>(Info.Scope, Info.BlogMetaData); if (blogMetaData == null) { blogMetaData = Minima.Service.Agent.BlogAgent.GetBlogMetaData(blogGuid); HttpData.SetScopedCacheItem <BlogMetaData>(Info.Scope, Info.BlogMetaData, blogMetaData); } //+ return(activeHttpHandler); }
//- $MasterPage_Load -// private void Page_Load(Object sender, EventArgs e) { if (!IsPostBack) { BlogMetaData blogMetaData = BlogAgent.GetBlogMetaData(Minima.Web.Controls.MinimaBlog.BlogGuid); //+ hlBlogUrl.NavigateUrl = blogMetaData.Uri.AbsoluteUri; hlBlogUrl.Text = blogMetaData.Title; this.Page.Title = blogMetaData.Title; //+ litBlogDescription.Text = blogMetaData.Description; } }
public async Task <ServiceResponse <List <BlogMetaData> > > GetRecommendedGistsAsync(string searchRequest) { if (string.IsNullOrWhiteSpace(searchRequest)) { return(await this.GetLatestBlogGistsAsync()); } string searchFullText = searchRequest .Replace(",", " ") .Split(' ') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => HttpUtility.UrlEncode(x)) .Aggregate((l, r) => $"{l} +{r}"); searchFullText = "+" + searchFullText; List <BlogMetaData> metas = new List <BlogMetaData>(); ServiceResponse <List <BlogMetaData> > response = new ServiceResponse <List <BlogMetaData> >(); SearchParameters searchParameters = new SearchParameters(orderBy: new string[] { "LastModifiedDate" }, queryType: QueryType.Full, searchMode: SearchMode.Any); SearchCredentials searchCredentials = new SearchCredentials(Environment.GetEnvironmentVariable(SEARCH_API_KEY_KEY)); try { using (SearchIndexClient client = new SearchIndexClient(SEARCH_SERVICE_NAME, SEARCH_INDEX_NAME, searchCredentials)) { DocumentSearchResult <Document> searchResult = await client.Documents.SearchAsync(searchFullText, searchParameters : searchParameters); foreach (SearchResult <Document> item in searchResult.Results) { string serializedDoc = JsonConvert.SerializeObject(item.Document); BlogMetaData metaData = JsonConvert.DeserializeObject <BlogMetaData>(serializedDoc); metas.Add(metaData); } } } catch (Exception ex) { var x = ex; } if (metas.Any()) { response.Data = metas; return(response); } return(await this.GetLatestBlogGistsAsync()); }
//- @GetRssFeed -// public Rss20FeedFormatter GetRssFeed(String blogGuid, String maxCount) { Int32 maxCountInt32; if (!Int32.TryParse(maxCount, out maxCountInt32)) { return(null); } using (BlogClient blogClient = new BlogClient(BlogSection.GetConfigSection().Service.Endpoint.Blog)) { blogClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; blogClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; List <BlogEntry> blogEntryList = null; try { blogEntryList = blogClient.GetBlogEntryList(blogGuid, maxCountInt32, true, false, BlogEntryRetreivalType.MetaDataOnly); } catch (FaultException <ArgumentException> ) { return(null); } catch (FaultException <SecurityException> ) { return(null); } catch { return(null); } if (blogEntryList.Count == 0) { return(null); } BlogMetaData blogMetaData = blogClient.GetBlogMetaData(blogGuid); //+ blog SyndicationFeed syndicationFeed = new SyndicationFeed(); syndicationFeed.Description = new TextSyndicationContent(blogMetaData.Description); foreach (Label label in blogMetaData.LabelList) { syndicationFeed.Categories.Add(new SyndicationCategory(label.Title)); } //+ blog entry list List <SyndicationItem> itemList = new List <SyndicationItem>(); foreach (BlogEntry blogEntry in blogEntryList) { SyndicationItem syndicationItem = new SyndicationItem { Title = new TextSyndicationContent(blogEntry.Title), Summary = new TextSyndicationContent(blogEntry.Content), PublishDate = new DateTimeOffset(blogEntry.PostDateTime), }; syndicationItem.Links.Add(new SyndicationLink(new Uri(Themelia.Web.Http.Root + "/" + Themelia.Web.UrlCleaner.FixWebPathHead(blogEntry.MappingNameList.First())))); foreach (Author author in blogEntry.AuthorList) { syndicationItem.Authors.Add(new SyndicationPerson(author.Email)); } foreach (Label label in blogEntry.LabelList) { syndicationItem.Categories.Add(new SyndicationCategory(label.Title)); } //+ itemList.Add(syndicationItem); } syndicationFeed.Items = itemList; //+ return(new Rss20FeedFormatter(syndicationFeed)); } }