Enable serving documentation pages statically.

This commit is contained in:
2021-08-18 03:46:58 +01:00
parent 8d5d3254ff
commit b399ad37b8
11 changed files with 8 additions and 547 deletions

View File

@@ -136,6 +136,13 @@
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Device\Edit.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Device\Index.cshtml" />
<_ContentIncludedByDefault Remove="Areas\Admin\Views\Atas\EditorTemplates\IdHashModel.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\Changelog.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\CODE_OF_CONDUCT.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\CONTRIBUTING.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\ISSUE_TEMPLATE.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\NEEDED.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\NEEDINFO.cshtml" />
<_ContentIncludedByDefault Remove="Views\Home\PULL_REQUEST_TEMPLATE.cshtml" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,200 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : HomeController.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Provides documentation data for razor views.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System;
using System.IO;
using System.Reflection;
using Markdig;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
namespace Aaru.Server.Controllers
{
public sealed class HomeController : Controller
{
readonly IWebHostEnvironment _environment;
public HomeController(IWebHostEnvironment environment) => _environment = environment;
[Route(""), Route("README")]
public ActionResult Index()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "README.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
[Route("Changelog")]
public ActionResult Changelog()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "Changelog.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
[Route("CODE_OF_CONDUCT")]
public ActionResult CODE_OF_CONDUCT()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "CODE_OF_CONDUCT.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
[Route("PULL_REQUEST_TEMPLATE")]
public ActionResult PULL_REQUEST_TEMPLATE()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "PULL_REQUEST_TEMPLATE.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
[Route("ISSUE_TEMPLATE")]
public ActionResult ISSUE_TEMPLATE()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "ISSUE_TEMPLATE.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
[Route("CONTRIBUTING")]
public ActionResult Contributing()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "CONTRIBUTING.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
return View();
}
[Route("DONATING"), Route("NEEDED")]
public ActionResult Needed()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "NEEDED.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
[Route("NEEDINFO")]
public ActionResult NeedInfo()
{
var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "NEEDINFO.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();
mdcontent = mdcontent.Replace(".md)", ")");
ViewBag.Markdown = Markdown.ToHtml(mdcontent);
ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString();
return View();
}
}
}

View File

@@ -61,6 +61,7 @@ namespace Aaru.Server
app.UseHsts();
}
app.UseDefaultFiles();
app.UseStaticFiles();
// Add other security headers

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : CODE_OF_CONDUCT.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders code of conduct.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
Aaru's code of conduct:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : CONTRIBUTING.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders contributing guidelines.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
How to contribute to Aaru:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Changelog.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders changelog.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
Aaru list of changes:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : ISSUE_TEMPLATE.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders issue's template.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
Aaru's template for issue reports:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,46 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Index.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders readme.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<header>
Welcome to
<i>
<a href="http://github.com/aaru-dps/aaru" target="_blank">
Aaru
</a>
</i> Server version @ViewBag.lblVersion
</header>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : NEEDED.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders list of needed donations.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
Aaru list of hardware and software needed:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : NEEDINFO.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders list of needed donations.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
Aaru list of information needed:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -1,43 +0,0 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Aaru Server";
}
@{
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : PULL_REQUEST_TEMPLATE.cshtml
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Renders pull request's template.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
}
<p>
@Html.ActionLink("Return to main page.", "Index")
<br />
Aaru's template for pull requests:
</p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div>