/// <summary> /// 标签 /// </summary> public void Tag() { var model = new PostListModel(); TagInfo tag = TagService.GetTagBySlug(slug); if (tag != null) { tagId = tag.TagId; model.MetaKeywords = tag.CateName; model.MetaDescription = tag.Description; model.PageTitle = tag.CateName; model.PostMessage = string.Format("<h2 class=\"post-message\">标签:{0}</h2>", tag.CateName); model.Url = ConfigHelper.SiteUrl + "tag/" + HttpContext.Current.Server.UrlEncode(slug) + "/page/{0}" + BlogConfig.GetSetting().RewriteExtension; int recordCount = 0; model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword); model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url); } model.IsDefault = 0; model.ThemeName = _themeName; th.Put("Model", model); Display(th, _listTemplate); }
/// <summary> /// 获取配置类 /// </summary> /// <returns></returns> public BlogConfig GetConfig() { BlogConfig blogConfig = new BlogConfig(); //ID string TopBlog = ConfigHelper.GetXmlValueByName(Path, "TopBlog"); int TopBlogId = -1; if (!string.IsNullOrEmpty(TopBlog)) { TopBlogId = Convert.ToInt32(TopBlog); } blogConfig.TopBlog = TopBlogId; //MyInfo string MyInfo = ConfigHelper.GetXmlValueByName(Path, "MyInfo"); blogConfig.MyInfo = MyInfo; //Link XElement xlink = ConfigHelper.GetXmlElement(Path, "Link"); IEnumerable <XElement> xlinks = xlink.Elements("LinkItem"); List <Link> links = new List <Link>(); foreach (var item in xlinks) { links.Add(new Link() { Href = item.Element("Href").Value, LinkName = item.Element("LinkName").Value }); } blogConfig.Links = links; return(blogConfig); }
public virtual ActionResult Index(BlogConfig config) { if (ModelState.IsValid == false) { ViewBag.Message = ModelState.FirstErrorMessage(); if (Request.IsAjaxRequest()) { return(Json(new { Success = false, ViewBag.Message })); } return(View(BlogConfig)); } var current = RavenSession.Load <BlogConfig>(BlogConfig.Key); if (IsFuturePostsEncryptionOptionsChanged(current, config)) { RemoveFutureRssAccessOnEncryptionConfigChange(); } RavenSession.Advanced.Evict(current); RavenSession.Store(config, BlogConfig.Key); RavenSession.SaveChanges(); OutputCacheManager.RemoveItem(MVC.Section.Name, MVC.Section.ActionNames.ContactMe); ViewBag.Message = "Configurations successfully saved!"; if (Request.IsAjaxRequest()) { return(Json(new { Success = true, ViewBag.Message })); } return(View(config)); }
/// <summary> /// 归档 /// </summary> public void Archive() { var model = new PostListModel(); string year = Jqpress.Framework.Web.PressRequest.GetQueryString("year"); string month = Jqpress.Framework.Web.PressRequest.GetQueryString("month"); DateTime date = Convert.ToDateTime(year + "-" + month); begindate = date.ToString(); enddate = date.AddMonths(1).ToString(); model.MetaKeywords = "归档"; model.MetaDescription = BlogConfig.GetSetting().SiteName + date.ToString("yyyy-MM") + "的归档"; model.PageTitle = "归档:" + date.ToString("yyyy-MM"); model.PostMessage = string.Format("<h2 class=\"post-message\">归档:{0}</h2>", date.ToString("yyyy-MM")); model.Url = ConfigHelper.SiteUrl + "archive/" + date.ToString("yyyyMM") + "/page/{0}" + BlogConfig.GetSetting().RewriteExtension; int recordCount = 0; model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword); model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url); model.IsDefault = 0; model.ThemeName = _themeName; th.Put("Model", model); Display(th, _listTemplate); }
/// <summary> /// 作者 /// </summary> public void Author() { var model = new PostListModel(); string userName = Jqpress.Framework.Web.PressRequest.GetQueryString("username"); UserInfo user = UserService.GetUser(userName); if (user != null) { userId = user.UserId; model.MetaKeywords = user.NickName; model.MetaDescription = user.Description; model.PageTitle = user.NickName; model.PostMessage = string.Format("<h2 class=\"post-message\">作者:{0}</h2>", user.NickName); model.Url = ConfigHelper.SiteUrl + "author/" + HttpContext.Current.Server.UrlEncode(userName) + "/page/{0}" + BlogConfig.GetSetting().RewriteExtension; int recordCount = 0; model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword); model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url); } model.IsDefault = 0; model.ThemeName = _themeName; th.Put("Model", model); Display(th, _listTemplate); }
/// <summary> /// 初始化配置信息 /// </summary> /// <returns></returns> public BlogConfig InitBlogConfig() { File.Create(AppConfig.ConfigFilePath).Close(); var blogConfig = new BlogConfig(); Utils.Instance.Output("请配置您的博客参数:"); Utils.Instance.Output("您的博客地址(例如 https://www.cnblogs.com/xhznl):"); blogConfig.BlogUrl = Console.ReadLine(); Utils.Instance.Output("您的博客ID(例如 xhznl ):"); blogConfig.BlogId = Console.ReadLine(); Utils.Instance.Output("您的博客用户名(例如 xhznl):"); blogConfig.UserName = Console.ReadLine(); Utils.Instance.Output("您的博客密码(例如 ******):"); blogConfig.Password = Console.ReadLine(); Utils.Instance.Output("博客MetaWeblog API地址(例如 https://rpc.cnblogs.com/metaweblog/xhznl):"); blogConfig.MetaWeblogUrl = Console.ReadLine(); File.WriteAllText(AppConfig.ConfigFilePath, blogConfig.SerializeObject()); Utils.Instance.Output("参数配置完成!"); return(blogConfig); }
/// <summary> /// 处理加精操作加积分 /// </summary> /// <param name="blogThread">日志</param> /// <param name="eventArgs">事件</param> private void BlogThreadPointModuleForManagerOperation_After(BlogThread blogThread, CommonEventArgs eventArgs) { NoticeService noticeService = new NoticeService(); string pointItemKey = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()) { pointItemKey = PointItemKeys.Instance().EssentialContent(); PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "日志", blogThread.ResolvedSubject); pointService.GenerateByRole(blogThread.UserId, pointItemKey, description); if (blogThread.UserId > 0) { Notice notice = Notice.New(); notice.UserId = blogThread.UserId; notice.ApplicationId = BlogConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = blogThread.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(blogThread.UserId))); notice.RelativeObjectName = HtmlUtility.TrimHtml(blogThread.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().BlogDetail(blogThread.User.UserName, blogThread.ThreadId)); notice.TemplateName = NoticeTemplateNames.Instance().ManagerSetEssential(); noticeService.Create(notice); } } }
public static Credentials GetCredentials(BlogConfig blogConfig) { return(new Credentials() { User = blogConfig.RedditUser, Password = blogConfig.RedditPassword }); }
/// <summary> /// Rsd /// from BlogEngine Source /// </summary> public void Rsd() { HttpContext.Current.Response.ContentType = "text/xml"; using (XmlTextWriter rsd = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8)) { rsd.Formatting = Formatting.Indented; rsd.WriteStartDocument(); // Rsd tag rsd.WriteStartElement("rsd"); rsd.WriteAttributeString("version", "1.0"); // Service rsd.WriteStartElement("service"); rsd.WriteElementString("engineName", "jqpress" + BlogConfig.GetSetting().Version); rsd.WriteElementString("engineLink", "http://www.jqpress.com"); rsd.WriteElementString("homePageLink", ConfigHelper.SiteUrl); // APIs rsd.WriteStartElement("apis"); // MetaWeblog rsd.WriteStartElement("api"); rsd.WriteAttributeString("name", "MetaWeblog"); rsd.WriteAttributeString("preferred", "true"); rsd.WriteAttributeString("apiLink", ConfigHelper.SiteUrl + "xmlrpc/metaweblog.aspx"); rsd.WriteAttributeString("blogID", "1"); rsd.WriteEndElement(); // WordPress rsd.WriteStartElement("api"); rsd.WriteAttributeString("name", "WordPress"); rsd.WriteAttributeString("preferred", "false"); rsd.WriteAttributeString("apiLink", ConfigHelper.SiteUrl + "xmlrpc/metaweblog.aspx"); rsd.WriteAttributeString("blogID", "1"); rsd.WriteEndElement(); // BlogML //rsd.WriteStartElement("api"); //rsd.WriteAttributeString("name", "BlogML"); //rsd.WriteAttributeString("preferred", "false"); //rsd.WriteAttributeString("apiLink", Utils.AbsoluteWebRoot + "api/BlogImporter.asmx"); //rsd.WriteAttributeString("blogID", Utils.AbsoluteWebRoot.ToString()); //rsd.WriteEndElement(); // End APIs rsd.WriteEndElement(); // End Service rsd.WriteEndElement(); // End Rsd rsd.WriteEndElement(); rsd.WriteEndDocument(); } }
public BlogServerHandler(XmlElement configEl) : base(true) { string blogProperty = XmlUtil.ReadString(configEl, "@blogProperty", null); if (blogProperty == null) throw new ConfigurationException("BlogServerHandler requires a 'blogProperty' attribute"); _blogConfig = ConfigProperties.Instance[blogProperty] as BlogConfig; if (_blogConfig == null) throw new ConfigurationException("Property '" + blogProperty + "' was missing or invalid"); }
/// <summary> /// 初始化 /// </summary> void BlogInit(string action) { if (action == "feed") { templatePath = HttpContext.Current.Server.MapPath(ConfigHelper.SitePath + "common/config/"); } else { templatePath = HttpContext.Current.Server.MapPath(string.Format("{0}/themes/default/template/", ConfigHelper.SitePath)); } if (BlogConfig.GetSetting().SiteStatus == 0) { ResponseError("网站已关闭", "网站已关闭,请与站长联系!"); } pageindex = Framework.Web.PressRequest.GetQueryInt("page", 1); slug = Framework.Web.PressRequest.GetQueryString("slug"); UpdateViewCount();//更新访问量 //主题处理 _themeName = BlogConfig.GetSetting().Theme; string previewThemeName = Jqpress.Framework.Web.PressRequest.GetQueryString("theme", true); //if (Jqpress.Framework.Web.PressRequest.IsMobile) //{ // _themeName = BlogConfig.GetSetting().MobileTheme; //} if (!string.IsNullOrEmpty(previewThemeName)) { _themeName = previewThemeName; } //非预览时 if (!System.IO.Directory.Exists(templatePath) && string.IsNullOrEmpty(previewThemeName)) { BlogConfigInfo s = BlogConfig.GetSetting(); if (Jqpress.Framework.Web.PressRequest.IsMobile) { s.MobileTheme = "default"; } else { s.Theme = "default"; } _themeName = "default"; // BlogConfig.UpdateSetting(); templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, _themeName)); } if (action != "feed") { templatePath = Server.MapPath(string.Format("{0}/themes/{1}/template/", ConfigHelper.SitePath, _themeName)); } th = new NVelocityHelper(templatePath); }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { var blogConfig = Session.Load <BlogConfig>("Blog/Config"); if (blogConfig == null) { blogConfig = new BlogConfig(); Session.Store(blogConfig); } ViewBag.BlogConfig = blogConfig.MapTo <BlogConfigViewModel>(); }
public OpmlController( ILogger <OpmlController> logger, CategoryService categoryService, BlogConfig blogConfig, BlogConfigurationService blogConfigurationService) : base(logger) { _categoryService = categoryService; _blogConfig = blogConfig; _blogConfig.GetConfiguration(blogConfigurationService); }
public ActionResult About() { #region 网站设置 //CustomCon custom = (CustomCon)ConfigurationManager.GetSection("customCon"); //WebInfo webInfo = custom.WebInfo; ViewBag.WebInfo = webInfo; #endregion BlogConfig blogConfig = webConfigManager.GetConfig(); return(View(blogConfig)); }
/// <summary> /// 加载feed /// </summary> public void Feed() { int categoryId = Jqpress.Framework.Web.PressRequest.GetQueryInt("categoryid", -1); int postId = Jqpress.Framework.Web.PressRequest.GetQueryInt("postid", -1); string action = Jqpress.Framework.Web.PressRequest.GetQueryString("action", true); // HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "text/xml"; if (BlogConfig.GetSetting().RssStatus == 1) { switch (action) { case "comment": List <CommentInfo> commentList = CommentService.GetCommentList(BlogConfig.GetSetting().RssRowCount, 1, -1, postId, 0, 1, -1, null); PostInfo commentPost = PostService.GetPost(postId); HttpContext.Current.Response.Write("<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">\r\n"); HttpContext.Current.Response.Write(" <channel>\r\n"); HttpContext.Current.Response.Write(" <title><![CDATA[" + (commentPost == null ? BlogConfig.GetSetting().SiteName : commentPost.Title) + "的评论]]></title>\r\n"); HttpContext.Current.Response.Write(" <link>" + (commentPost == null ? ConfigHelper.SiteUrl : commentPost.Url) + "</link>\r\n"); HttpContext.Current.Response.Write(" <description><![CDATA[" + BlogConfig.GetSetting().SiteDescription + "]]></description>\r\n"); HttpContext.Current.Response.Write(" <pubDate>" + DateTime.Now.ToString("r") + "</pubDate>\r\n"); HttpContext.Current.Response.Write(" <generator>jqpress</generator>\r\n"); HttpContext.Current.Response.Write(" <language>zh-cn</language>\r\n"); foreach (CommentInfo comment in commentList) { HttpContext.Current.Response.Write(" <item>\r\n"); HttpContext.Current.Response.Write(" <title><![CDATA[" + comment.Author + "对" + comment.Post.Title + "的评论]]></title>\r\n"); HttpContext.Current.Response.Write(" <link>" + comment.Url + "</link>\r\n"); HttpContext.Current.Response.Write(" <guid>" + comment.Url + "</guid>\r\n"); HttpContext.Current.Response.Write(" <author><![CDATA[" + comment.Author + "]]></author>\r\n"); HttpContext.Current.Response.Write(string.Format(" <description><![CDATA[{0}]]></description>\r\n", comment.Contents)); HttpContext.Current.Response.Write(" <pubDate>" + comment.CreateTime.ToString("r") + "</pubDate>\r\n"); HttpContext.Current.Response.Write(" </item>\r\n"); } HttpContext.Current.Response.Write(" </channel>\r\n"); HttpContext.Current.Response.Write("</rss>\r\n"); break; default: var model = new PostListModel(); model.PostList = PostService.GetPostList(BlogConfig.GetSetting().RssRowCount, categoryId, -1, -1, 1, -1, 0); th.Put("Model", model); Display(th, "feed.config"); break; } } else { HttpContext.Current.Response.Write("<rss>error</rss>\r\n"); } // HttpContext.Current.Response.End(); }
public static void ResponseError(string title, string msg, int statusCode) { string str = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><header><title>{0} - {1}</title><style>a {{ color:gray;}}</style></header><body><div style=\"border:1px solid #94a2a3; background-color:#F1F8FE; width:500px; padding:8px 25px; margin:100px auto 0 auto;\" ><h5>提示:</h5><h2>{2}</h2><h4><a href=\"{3}\">返回首页</a></h4></div><div style=\" text-align:center; padding:5px 0;color:gray;font-size:12px;\" >Powered by <a href=\"http://www.jqpress.com\" target=\"_blank\">jqpress</a> </div></body></html>"; str = string.Format(str, title, BlogConfig.GetSetting().SiteName, msg, ConfigHelper.SiteUrl); HttpContext.Current.Response.Clear(); // HttpContext.Current.Response.Status = "200 Internal Server Error"; HttpContext.Current.Response.StatusCode = statusCode; HttpContext.Current.Response.Write(str); HttpContext.Current.Response.End(); }
public static IList <string> ParseSubreddits(BlogConfig config) { if (string.IsNullOrEmpty(config.RedditSubredditsToSubmitToOnPublish)) { return(new List <string>()); } return(config.RedditSubredditsToSubmitToOnPublish .Split(',') .Select(x => x.Trim()) .ToList()); }
public SearchController( ILogger <OpmlController> logger, IOptions <AppSettings> settings, PostService postService, BlogConfig blogConfig, BlogConfigurationService blogConfigurationService) : base(logger, settings) { _postService = postService; _blogConfig = blogConfig; _blogConfig.Initialize(blogConfigurationService); }
public CommentService( ILogger <CommentService> logger, IOptions <AppSettings> settings, BlogConfig blogConfig, BlogConfigurationService blogConfigurationService, IRepository <Comment> commentRepository, IRepository <CommentReply> commentReplyRepository) : base(logger: logger, settings: settings) { _blogConfig = blogConfig; _commentRepository = commentRepository; _commentReplyRepository = commentReplyRepository; _blogConfig.GetConfiguration(blogConfigurationService); }
public void WhenTheBlogConfigIsAvailable_ThePropertyShouldReturnTheConfig() { var config = new BlogConfig { Title = "Test Config", Id = "blog/config" }; SetupData(session => session.Store(config)); BlogConfig configFromController = null; ExecuteAction <LoginController>(controller => configFromController = controller.BlogConfig); Assert.Equal(config.Title, configFromController.Title); }
public bool SetBlogConfig(BlogConfig cfg) //设定博客配置文件 { bool isSuccess = false; try { new SerializeTool().Serialize <BlogConfig>(cfg); isSuccess = true; } catch { } return(isSuccess); }
public BlogHomepageHandler(XmlElement configEl) { string blogProperty = XmlUtil.ReadString(configEl, "@blogProperty", null); if (blogProperty == null) throw new ConfigurationException("BlogHomepageHandler requires a 'blogProperty' attribute"); _blogConfig = ConfigProperties.Instance[blogProperty] as BlogConfig; if (_blogConfig == null) throw new ConfigurationException("Property '" + blogProperty + "' was missing or invalid"); _template = Template.Compile( StringUtil.StripIndentation(configEl.InnerText), new ArgumentDescription(typeof(BlogConfig), "blogConfig")); }
public BlogServerHandler(XmlElement configEl) : base(true) { string blogProperty = XmlUtil.ReadString(configEl, "@blogProperty", null); if (blogProperty == null) { throw new ConfigurationException("BlogServerHandler requires a 'blogProperty' attribute"); } _blogConfig = ConfigProperties.Instance[blogProperty] as BlogConfig; if (_blogConfig == null) { throw new ConfigurationException("Property '" + blogProperty + "' was missing or invalid"); } }
void ImportBlog(IDocumentStore store, BlogMLBlog blog) { var config = BlogConfig.New(); config.Title = blog.Title; config.Subtitle = blog.SubTitle; config.Copyright = String.Join(", ", blog.Authors.Select(author => author.Title)); config.MetaDescription = String.Join(", ", blog.Categories.Select(category => category.Title)); using (var session = store.OpenSession()) { session.Store(config); session.SaveChanges(); } }
/// <summary> /// blogger.getUsersBlogs /// </summary> /// <param name="appKey">Key from application. Outdated methodology that has no use here.</param> /// <param name="userName">login username</param> /// <param name="password">login password</param> /// <param name="rootUrl">The root URL.</param> /// <returns>array of blog structs</returns> internal List <MWABlogInfo> GetUserBlogs(string appKey, string userName, string password, string rootUrl) { ValidateRequest(userName, password); List <MWABlogInfo> blogs = new List <MWABlogInfo>(); MWABlogInfo temp = new MWABlogInfo(); temp.url = rootUrl; temp.blogID = "1000"; temp.blogName = BlogConfig.GetSetting().SiteName; blogs.Add(temp); return(blogs); }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="blogThread"></param> /// <param name="eventArgs"></param> private void BlogThreadActivityModule_After(BlogThread blogThread, AuditEventArgs eventArgs) { //生成动态 ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) { //初始化Owner为用户的动态 Activity activityOfUser = Activity.New(); activityOfUser.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogThread(); activityOfUser.ApplicationId = BlogConfig.Instance().ApplicationId; //判断是否有图片、音频、视频 AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().BlogThread()); IEnumerable <Attachment> attachments = attachmentService.GetsByAssociateId(blogThread.ThreadId); if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image)) { activityOfUser.HasImage = true; } activityOfUser.HasMusic = false; activityOfUser.HasVideo = false; activityOfUser.IsOriginalThread = !blogThread.IsReproduced; activityOfUser.IsPrivate = blogThread.PrivacyStatus == PrivacyStatus.Private ? true : false; activityOfUser.UserId = blogThread.UserId; activityOfUser.ReferenceId = 0; activityOfUser.ReferenceTenantTypeId = string.Empty; activityOfUser.SourceId = blogThread.ThreadId; activityOfUser.TenantTypeId = TenantTypeIds.Instance().BlogThread(); activityOfUser.OwnerId = blogThread.UserId; activityOfUser.OwnerName = blogThread.Author; activityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); //是否是公开的(用于是否推送站点动态) bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false; //生成动态 activityService.Generate(activityOfUser, true, isPublic); } //删除动态 else if (auditDirection == false) { activityService.DeleteSource(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId); } }
private static void CreateConfig(IDocumentStore store) { using (IDocumentSession s = store.OpenSession()) { var config = BlogConfig.New(); config.Id = "Blog/Config"; config.CustomCss = "hibernatingrhinos"; config.Subtitle = "Unnatural acts on source code"; config.Title = "Ayende @ Rahien"; config.Copyright = "Ayende Rahien"; config.AkismetKey = "43f0db211711"; s.Store(config); s.SaveChanges(); } }
public ImageController( ILogger <ImageController> logger, IOptions <AppSettings> settings, IMemoryCache memoryCache, IAsyncImageStorageProvider imageStorageProvider, ISessionBasedCaptcha captcha, BlogConfig blogConfig, BlogConfigurationService blogConfigurationService) : base(logger, settings, memoryCache: memoryCache) { _blogConfig = blogConfig; _blogConfig.Initialize(blogConfigurationService); _imageStorageProvider = imageStorageProvider; _captcha = captcha; }
/// <summary> /// 首页 /// </summary> public void Home() { var model = new PostListModel(); model.IsDefault = 1; model.ThemeName = _themeName; model.PostMessage = string.Empty; model.Url = ConfigHelper.SiteUrl + "page/{0}" + BlogConfig.GetSetting().RewriteExtension;; int recordCount = 0; model.PostList = PostService.GetPostList(BlogConfig.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword); model.Pager = Pager.CreateHtml(BlogConfig.GetSetting().PageSizePostCount, recordCount, model.Url); th.Put("Model", model); Display(th, _listTemplate); }
public SyndicationService( ILogger <SyndicationService> logger, IOptions <AppSettings> settings, BlogConfig blogConfig, BlogConfigurationService blogConfigurationService, IHttpContextAccessor httpContextAccessor, IRepository <Category> categoryRepository, IRepository <Post> postRepository) : base(logger: logger, settings: settings) { _blogConfig = blogConfig; _categoryRepository = categoryRepository; _postRepository = postRepository; _blogConfig.GetConfiguration(blogConfigurationService); var acc = httpContextAccessor; _baseUrl = $"{acc.HttpContext.Request.Scheme}://{acc.HttpContext.Request.Host}"; }
public EmailService( ILogger <EmailService> logger, IOptions <AppSettings> settings, IHostingEnvironment env, BlogConfig blogConfig, BlogConfigurationService blogConfigurationService, IRepository <Post> postRepository) : base(logger, settings) { _env = env; _blogConfig = blogConfig; _postRepository = postRepository; _blogConfig.GetConfiguration(blogConfigurationService); var configSource = $@"{AppDomain.CurrentDomain.GetData(Constants.AppBaseDirectory)}\mailConfiguration.xml"; if (!File.Exists(configSource)) { throw new FileNotFoundException("Configuration file for EmailHelper is not present.", configSource); } if (EmailHelper == null) { var emailSettings = new EmailSettings( _blogConfig.EmailConfiguration.SmtpServer, _blogConfig.EmailConfiguration.SmtpUserName, _blogConfig.EmailConfiguration.SmtpPassword, _blogConfig.EmailConfiguration.SmtpServerPort) { EnableSsl = _blogConfig.EmailConfiguration.EnableSsl, EmailDisplayName = _blogConfig.EmailConfiguration.EmailDisplayName, SenderName = _blogConfig.EmailConfiguration.EmailDisplayName }; EmailHelper = new EmailHelper(configSource, emailSettings); EmailHelper.EmailSent += (sender, eventArgs) => { if (sender is MailMessage msg) { Logger.LogInformation($"Email {msg.Subject} is sent, Success: {eventArgs.IsSuccess}"); } }; } }
public ActionResult SetConfig() //设定博客配置文件 { string configTitle = Request["Title"].ToString(); string configSign = Request["Sign"].ToString(); string configNote = Request["Note"].ToString(); var model = new BlogConfig { Name = configTitle, Note = configNote, Sign = configSign }; bool isSuccess = manager.SetBlogConfig(model); if (isSuccess) { return(View()); //设定成功 } else { return(View()); } }
/// <summary> /// コンストラクタ。ブログの設定値をデータベースから取得します /// </summary> /// <param name="dbConnectionString"></param> public HNKBlogConfigManager(string dbConnectionString) { List<BlogConfig> configs = HNKBlogConfigFetcher.GetConfigs(dbConnectionString); if (configs.Count > 0) { List<BlogConfig> enableArticleFeed = configs.Where(i => i.Name == KEY_ENABLE_ARTICLE_FEED).ToList(); if (enableArticleFeed.Count > 0) { _enableArticleFeed = enableArticleFeed[0]; } List<BlogConfig> enableArticleComment = configs.Where(i => i.Name == KEY_ENABLE_ARTICLE_COMMENT).ToList(); if (enableArticleFeed.Count > 0) { _enableArticleComment = enableArticleComment[0]; } List<BlogConfig> enableDisqus = configs.Where(i => i.Name == KEY_ENABLE_DISQUS).ToList(); if (enableArticleFeed.Count > 0) { _enableDisqus = enableDisqus[0]; } List<BlogConfig> titleList = configs.Where(i => i.Name == KEY_BLOG_TITLE).ToList(); if (enableArticleFeed.Count > 0) { this.BlogTitle = titleList[0]; } List<BlogConfig> feedStatusList = configs.Where(i => i.Name == KEY_BLOG_DESCRIPTION).ToList(); if (enableArticleFeed.Count > 0) { this.BlogDescription = feedStatusList[0]; } List<BlogConfig> googleAnalytics = configs.Where(i => i.Name == KEY_GOOGLE_ANALYTICS).ToList(); if (googleAnalytics.Count > 0) { this.GoogleAnalytics = googleAnalytics[0]; } } }