public static HtmlString AppSourceFile(this HtmlHelper helper, string file) { var location = ((RazorView)helper.ViewContext.View).Path; var path = Path.GetDirectoryName(location.Replace("/", "\\")); path = System.IO.Path.Combine(path, file); return(new HtmlString("<a target=\"blank\" style=\"font-weight: bold; color: #ffc\" href=\"" + helper.Encode(path.Replace("\\", "/").Replace("~/", // using syntax below to prevent replace of S E R E N E in URL "https://github.com/volkanceylan/S" + "erene/blob/master/S" + "erene/S" + "erene.Web/")) + "\">" + helper.Encode(Path.GetFileName(file)) + "</a>")); }
public static HtmlString AppSourceFile(this HtmlHelper helper, string file) { var viewLocation = ((RazorView)helper.ViewContext.View).Path; var absolutePath = Path.GetDirectoryName(viewLocation).Replace('\\', '/') + '/'; var relative = file.Replace('\\', '/'); var question = relative.IndexOf('?'); if (question >= 0) { relative = new Uri("x:" + absolutePath + relative.Substring(0, question)) .AbsolutePath.Substring(2) + relative.Substring(question); } else { relative = new Uri("x:" + absolutePath + relative).AbsolutePath.Substring(2); } return(new HtmlString("<a target=\"blank\" style=\"font-weight: bold; color: #ffc\" href=\"" + helper.Encode("https://github.com/volkanceylan/S" + "erene/blob/master/S" + "erene/S" + "erene.Web" + relative) + "\">" + helper.Encode(Path.GetFileName(file)) + "</a>")); }
public static HtmlString BasicSamplesSourceFile(this HtmlHelper helper, string file) { var viewLocation = ((RazorView)helper.ViewContext.View).Path; var absolutePath = Path.GetDirectoryName(viewLocation).Replace('\\', '/') + '/'; var relative = file.Replace('\\', '/'); var question = relative.IndexOf('?', StringComparison.Ordinal); if (question >= 0) { relative = new Uri("x:" + absolutePath + relative.Substring(0, question)) .AbsolutePath.Substring(2) + relative.Substring(question); } else { relative = new Uri("x:" + absolutePath + relative).AbsolutePath.Substring(2); } return(new HtmlString("<a target=\"blank\" style=\"font-weight: bold; color: #ffc\" href=\"" + helper.Encode("https://github.com/serenity-is/common-features/" + "blob/master/src/Serenity.Demo.BasicSamples/" + relative) + "\">" + helper.Encode(Path.GetFileName(file)) + "</a>")); }