public void Export( [Argument("site", "s", Description = "The root http address of the website copy.")] string site, [Argument("path", "p", Description = "The directory to export to.")] string directory, [Argument("rebase", DefaultValue = true, Description = "Changes the fully-qualified links to use file: references.")] bool rebase) { if (String.IsNullOrEmpty(directory) || File.Exists(directory)) { throw new ArgumentException("Please specify a valid directory."); } if (!Directory.Exists(directory)) { if (!new ConfirmPrompt().Continue("Directory does not exist, create the directory")) { return; } Directory.CreateDirectory(directory); } using (SiteConverter converter = new SiteConverter(StoragePath(site), site)) { converter.RebaseLinks = rebase; converter.Export(directory); } }
public ActionResult Detail(string siteId) { var site = _siteDynamicsRepository.GetSite(siteId); SiteViewModel model = new SiteConverter().ConvertToView(site); return(View(model)); }
public void Import( [Argument("page", "p", Description = "The full http address of the page to save the source content to.")] string targetLink, [Argument("source", "s", Description = "The full http address of the page you want to import.")] string sourceLink, [Argument("recursive", "r", DefaultValue = false, Description = "True to recursivly import all links within the same domain.")] bool recursive, [Argument("noprompt", "q", DefaultValue = false, Description = "True to stop prompt for confirmation before overwriting content.")] bool noPrompt ) { Uri targetUri = new Uri(targetLink, UriKind.Absolute); using (TempDirectory tempFolder = new TempDirectory()) using (ContentStorage writer = new ContentStorage(StoragePath(targetLink), false)) { bool exists = writer.ContainsKey(targetUri.NormalizedPathAndQuery()); if (exists) { if (!noPrompt && !new ConfirmPrompt().Continue("Overwrite " + targetUri.NormalizedPathAndQuery())) { return; } } Uri sourceUri = new Uri(sourceLink, UriKind.Absolute); using (SiteCollector index = new SiteCollector(tempFolder.TempPath, sourceLink)) { index.NoDefaultPages = true; index.UpdateSearchTemplate = false; if (recursive) { index.CrawlSite(); } else { index.AddUrlsFound = false; index.CrawlPage(sourceUri.NormalizedPathAndQuery()); } } using (SiteConverter index = new SiteConverter(tempFolder.TempPath, sourceLink)) { index.Overwrite = true; index.ConvertTo(targetLink, writer); } if (exists) { writer.Remove(targetUri.NormalizedPathAndQuery()); } writer.Rename(sourceUri.NormalizedPathAndQuery(), targetUri.NormalizedPathAndQuery()); } }
public void CopySite( [Argument("site", "s", Description = "The root http address of the website to copy.")] string original, [Argument("target", "t", Description = "The root http address of the destination website.")] string target, [Argument("overwrite", "y", DefaultValue = false, Description = "True to overwrite any existing content.")] bool overwrite) { using (SiteConverter index = new SiteConverter(StoragePath(original), original)) using (ContentStorage writer = new ContentStorage(StoragePath(target), false)) { index.Overwrite = overwrite; index.ConvertTo(target, writer); } }
public JsonResult GetActiveSites() { var model = new SiteViewModel(); var sites = new List <SiteViewModel>(); var tempSites = _siteDynamicsRepository.GetSites().Where(x => x.INACTIVE != 1).ToList(); if (tempSites != null && tempSites.Count > 0) { foreach (var tempSite in tempSites) { SiteViewModel convertedModel = new SiteConverter().ConvertToView(tempSite); sites.Add(convertedModel); } } model.Sites = sites.OrderBy(x => x.SiteDescription).ToList(); return(Json(model, JsonRequestBehavior.AllowGet)); }