Пример #1
0
        public ActionResult Index()
        {
            SeoSettings seo = Context.ManagedSite.SeoSettings;

             if (seo == null)
             {
            seo = new SeoSettings
            {
               Site = Context.ManagedSite
            };
             }

             return View("Index", seo);
        }
Пример #2
0
        public Site CreateNewSite(string name, string description, string email, string siteHost, Theme theme)
        {
            if (theme == null)
            throw new NullReferenceException("a default theme is mandatory to create a new site");

             // Site
             Site site = new Site
             {
            Name = name,
            Description = description,
            AllowRegistration = false,
            EnableCaptchaForComments = false,
            AllowPasswordRetrieval = true,
            DefaultCulture = "en-US",
            TimeZone = 0,
            Email = string.IsNullOrEmpty(email) ? "*****@*****.**" : email,
            MaxPostsPerPage = 10,
            MaxCommentsPerPage = 50,
            MaxLinksInComments = 3,
            MaxSyndicationFeeds = 10,
            AllowComments = true,
            AllowCommentsOnlyForRegisteredUsers = false,
            SortCommentsFromOlderToNewest = true,
            FeedUseSummary = true,
            ShowAvatars = true,
            Theme = theme,
            CreatedDate = DateTime.Now.ToUniversalTime()
             };

             // Site Host
             SiteHost host = new SiteHost
             {
            HostName = siteHost,
            IsDefault = true,
            Site = site,
            CreatedDate = DateTime.Now.ToUniversalTime()
             };

             site.Hosts.Add(host);

             //// Site Host for Control Panel
             //SiteHost cpHost = new SiteHost
             //{
             //   HostName = "admin." + siteHost,
             //   IsDefault = false,
             //   Site = site,
             //   CreatedDate = DateTime.Now.ToUniversalTime()
             //};

             //site.Hosts.Add(cpHost);

             SeoSettings seo = new SeoSettings
             {
            Site = site,
            PostTitleFormat = "%post_title% | %blog_title%",
            PageTitleFormat = "%page_title% | %blog_title%",
            CategoryTitleFormat = "%category_title% | %blog_title%",
            TagTitleFormat = "%tag% | %blog_title%",
            SearchTitleFormat = "%search% | %blog_title%",
            ArchiveTitleFormat = "%date% | %blog_title%",
            Page404TitleFormat = "Nothing found for %request_words%",
            DescriptionFormat = "%description%",
            UseCategoriesForMeta = true,
            GenerateKeywordsForPost = true,
            UseNoIndexForArchives = true,
            UseNoIndexForCategories = true,
            UseNoIndexForTags = false,
            GenerateDescriptions = true,
            CapitalizeCategoryTitles = true,
            RewriteTitles = true,
            HomeDescription = "",
            HomeKeywords = "",
            HomeTitle = ""
             };
             //site.SeoSettings = seo;

             //using (INHTransactionScope tx = new NHTransactionScope())
             //{
            log.Debug("SiteService.CreateNewSite: Saving new site...");

            // Save the new site
            SaveSite(site);

            // this is ...odd, but if I comment the following 3 lines I get an error
            // from NH: Could not perform Save for Site ---> NHibernate.PropertyValueException: not-null property references a null or transient valueArashi.Core.Domain.SeoSettings.Site
            site.SeoSettings = seo;
            SaveSeoSettings(seo);
            SaveSite(site);

            log.Debug("SiteService.CreateNewSite: Site saved...");

            log.Debug("SiteService.CreateNewSite: Creating default roles...");

            // create default roles
            userService.CreateDefaultRoles(site);

            //tx.VoteCommit();
            log.Debug("SiteService.CreateNewSite: Transaction commit");
             //}

             log.Debug("SiteService.CreateNewSite: Creating Site folder structure - Start");

             // Create SiteData folder structure
             string siteDataRoot = HttpContext.Current.Server.MapPath(site.SiteDataPath);
             log.Debug("Install.CreateSite: siteDataRoot = " + siteDataRoot);

             DirectoryInfo di = new DirectoryInfo(siteDataRoot);

             // Check if the parent folder is writable
             if (di.Parent != null && !fileService.CheckIfDirectoryIsWritable(di.Parent.FullName))
            throw new IOException(string.Format("Unable to create the site because the directory {0} is not writable.", siteDataRoot));

             string siteDataPhysicalDirectory = siteDataRoot; //Path.Combine(siteDataRoot, site.SiteId.ToString());

             fileService.CreateDirectory(siteDataPhysicalDirectory);
             //CreateDirectory(Path.Combine(siteDataPhysicalDirectory, "UserFiles"));
             fileService.CreateDirectory(Path.Combine(siteDataPhysicalDirectory, "index"));

             log.Debug("SiteService.CreateNewSite: Creating Site folder structure - End");

             return site;
        }
Пример #3
0
 public void SaveSeoSettings(SeoSettings seoSettings)
 {
     //using (INHTransactionScope tx = new NHTransactionScope())
      //{
      Repository<SeoSettings>.Save(seoSettings);
      //   tx.VoteCommit();
      //}
 }