public ExternalReviewLink FromExternalReview(ExternalReviewLinkDds externalReviewLinkDds) { var projectName = ""; var projectId = externalReviewLinkDds.ProjectId; if (projectId.HasValue) { try { var project = _projectRepository.Get(externalReviewLinkDds.ProjectId.Value); projectName = project.Name; } catch { projectName = string.Empty; projectId = null; } } string externalUrlPrefix; if (externalReviewLinkDds.IsEditable) { externalUrlPrefix = UrlPath.EnsureStartsWithSlash(_options.ReviewsUrl); } else { ContentReference contentReference = ContentReference.StartPage; if (externalReviewLinkDds.ContentLink != null) { // if the page has been published before we can generate a link like /alloy-plan/${_options.ContentPreviewUrl} // however if the page has never been published then we have to "proxy" it through the StartPage so that the // AuthorizationFilter does not block it var content = _contentLoader.Get <IContent>(externalReviewLinkDds.ContentLink.ToReferenceWithoutVersion()); contentReference = content.IsPublished() ? externalReviewLinkDds.ContentLink : ContentReference.StartPage; } var url = _urlResolver.GetUrl(contentReference); // the preview url has to be language specific as it's handled entirely by the EPiServer partial router // the edit url is just a pure aspnet.mvc controller, handled outside EPiServer externalUrlPrefix = UrlPath.Combine(url, _options.ContentPreviewUrl); } return(new ExternalReviewLink { ContentLink = externalReviewLinkDds.ContentLink, IsEditable = externalReviewLinkDds.IsEditable, ProjectId = projectId, Token = externalReviewLinkDds.Token, ValidTo = externalReviewLinkDds.ValidTo, LinkUrl = UrlPath.Combine(externalUrlPrefix, externalReviewLinkDds.Token), PinCode = externalReviewLinkDds.PinCode, DisplayName = externalReviewLinkDds.DisplayName, ProjectName = projectName }); }
public ExternalReviewLink AddLink(ContentReference contentLink, bool isEditable, TimeSpan validTo) { var externalReviewLink = new ExternalReviewLinkDds { ContentLink = contentLink, IsEditable = isEditable, Token = Guid.NewGuid().ToString(), ValidTo = DateTime.Now.Add(validTo) }; GetStore().Save(externalReviewLink); return(ExternalReviewLink.FromExternalReview(externalReviewLink, _externalReviewOptions.ReviewsUrl, _externalReviewOptions.ContentPreviewUrl)); }
internal static ExternalReviewLink FromExternalReview(ExternalReviewLinkDds externalReviewLinkDds, string editUrl, string previewUrl) { previewUrl = "en/" + previewUrl; //TODO: #externalreview hardcoded return(new ExternalReviewLink { ContentLink = externalReviewLinkDds.ContentLink, IsEditable = externalReviewLinkDds.IsEditable, Token = externalReviewLinkDds.Token, ValidTo = externalReviewLinkDds.ValidTo, LinkUrl = "/" + (externalReviewLinkDds.IsEditable ? editUrl: previewUrl) + "/" + externalReviewLinkDds.Token //TODO: externalReviews URL }); }
public ExternalReviewLink AddLink(ContentReference contentLink, bool isEditable, TimeSpan validTo, int?projectId) { var externalReviewLink = new ExternalReviewLinkDds { ContentLink = contentLink, IsEditable = isEditable, ProjectId = projectId, Token = Guid.NewGuid().ToString(), ValidTo = DateTime.Now.Add(validTo) }; GetStore().Save(externalReviewLink); return(_externalReviewLinkBuilder.FromExternalReview(externalReviewLink)); }
public ExternalReviewLink FromExternalReview(ExternalReviewLinkDds externalReviewLinkDds) { var startPageUrl = _urlResolver.GetUrl(ContentReference.StartPage); // the preview url has to be language specific as it's handled entirely by the EPiServer partial router // the edit url is just a pure aspnet.mvc controller, handled outside EPiServer var previewUrl = startPageUrl + _options.ContentPreviewUrl; return(new ExternalReviewLink { ContentLink = externalReviewLinkDds.ContentLink, IsEditable = externalReviewLinkDds.IsEditable, Token = externalReviewLinkDds.Token, ValidTo = externalReviewLinkDds.ValidTo, LinkUrl = (externalReviewLinkDds.IsEditable ? "/" + _options.ReviewsUrl: previewUrl) + "/" + externalReviewLinkDds.Token //TODO: externalReviews URL }); }
public ExternalReviewLink FromExternalReview(ExternalReviewLinkDds externalReviewLinkDds) { var projectName = ""; var projectId = externalReviewLinkDds.ProjectId; if (projectId.HasValue) { try { var project = _projectRepository.Get(externalReviewLinkDds.ProjectId.Value); projectName = project.Name; } catch { projectName = string.Empty; projectId = null; } } string externalUrlPrefix; if (externalReviewLinkDds.IsEditable) { externalUrlPrefix = UrlPath.EnsureStartsWithSlash(_options.ReviewsUrl); } else { var url = _startPageUrlResolver.GetUrl(externalReviewLinkDds.ContentLink); // the preview url has to be language specific as it's handled entirely by the EPiServer partial router // the edit url is just a pure aspnet.mvc controller, handled outside EPiServer externalUrlPrefix = UrlPath.Combine(url, _options.ContentPreviewUrl); } return(new ExternalReviewLink { ContentLink = externalReviewLinkDds.ContentLink, IsEditable = externalReviewLinkDds.IsEditable, ProjectId = projectId, Token = externalReviewLinkDds.Token, ValidTo = externalReviewLinkDds.ValidTo, LinkUrl = UrlPath.Combine(externalUrlPrefix, externalReviewLinkDds.Token), PinCode = externalReviewLinkDds.PinCode, DisplayName = externalReviewLinkDds.DisplayName, ProjectName = projectName, VisitorGroups = externalReviewLinkDds.VisitorGroups }); }