mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 11:21:47 -05:00
Beginning of wiki development
This commit is contained in:
parent
7111f0d5cd
commit
1dcbadf2eb
5 changed files with 174 additions and 0 deletions
22
Project-Unite/Controllers/WikiControllerController.cs
Normal file
22
Project-Unite/Controllers/WikiControllerController.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Project_Unite.Models;
|
||||
|
||||
namespace Project_Unite.Controllers
|
||||
{
|
||||
public class WikiController : Controller
|
||||
{
|
||||
public ActionResult Index(string id = "")
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
var model = new WikiViewModel();
|
||||
var wikicategories = db.WikiCategories.Where(x => x.Parent == null);
|
||||
model.Categories = wikicategories;
|
||||
model.Page = db.WikiPages.FirstOrDefault(x => x.Id == id);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -204,6 +204,9 @@ public ApplicationDbContext()
|
|||
|
||||
}
|
||||
|
||||
public DbSet<WikiPage> WikiPages { get; set; }
|
||||
public DbSet<WikiCategory> WikiCategories { get; set; }
|
||||
|
||||
public void DeleteObject(object obj)
|
||||
{
|
||||
((IObjectContextAdapter)this).ObjectContext.DeleteObject(obj);
|
||||
|
|
69
Project-Unite/Models/WikiModels.cs
Normal file
69
Project-Unite/Models/WikiModels.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Project_Unite.Models
|
||||
{
|
||||
public class WikiCategory
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Parent { get; set; }
|
||||
|
||||
public WikiCategory[] Children
|
||||
{
|
||||
get
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
|
||||
return db.WikiCategories.Where(x => x.Parent == this.Id).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public WikiPage[] Pages
|
||||
{
|
||||
get
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
|
||||
return db.WikiPages.Where(w => w.CategoryId == this.Id).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WikiViewModel
|
||||
{
|
||||
public IEnumerable<WikiCategory> Categories { get; set; }
|
||||
public WikiPage Page { get; set; }
|
||||
}
|
||||
|
||||
public class WikiPage
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string CategoryId { get; set; }
|
||||
|
||||
//I stole this feature from wikipedia lol. I like the idea of disambiguation of multiple pages with the same name.
|
||||
public WikiPage[] AmbiguousReferences
|
||||
{
|
||||
get
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
|
||||
return db.WikiPages.Where(w => w.Id != this.Id && w.Name.ToLower().Contains(this.Name.ToLower())).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public string Contents { get; set; }
|
||||
|
||||
public ForumPostEdit[] EditHistory
|
||||
{
|
||||
get
|
||||
{
|
||||
var db = new ApplicationDbContext();
|
||||
return db.ForumPostEdits.Where(x => x.Parent == this.Id).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -246,6 +246,7 @@
|
|||
<Compile Include="Controllers\ModeratorController.cs" />
|
||||
<Compile Include="Controllers\ProfilesController.cs" />
|
||||
<Compile Include="Controllers\SkinsController.cs" />
|
||||
<Compile Include="Controllers\WikiControllerController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -426,6 +427,7 @@
|
|||
<Compile Include="Models\Notification.cs" />
|
||||
<Compile Include="Models\Role.cs" />
|
||||
<Compile Include="Models\Skin.cs" />
|
||||
<Compile Include="Models\WikiModels.cs" />
|
||||
<Compile Include="NotificationDaemon.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Startup.cs" />
|
||||
|
@ -534,10 +536,12 @@
|
|||
<Content Include="Views\Admin\Backups.cshtml" />
|
||||
<Content Include="Views\Download\Index.cshtml" />
|
||||
<Content Include="Views\Forum\ViewUnread.cshtml" />
|
||||
<Content Include="Views\Wiki\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Properties\PublishProfiles\" />
|
||||
<Folder Include="Views\WikiController\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="fonts\glyphicons-halflings-regular.woff" />
|
||||
|
|
76
Project-Unite/Views/Wiki/Index.cshtml
Normal file
76
Project-Unite/Views/Wiki/Index.cshtml
Normal file
|
@ -0,0 +1,76 @@
|
|||
@model Project_Unite.Models.WikiViewModel
|
||||
|
||||
@{
|
||||
if (Model.Page == null)
|
||||
{
|
||||
ViewBag.Title = "Wiki";
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewBag.Title = Model.Page.Name + " - Wiki";
|
||||
}
|
||||
}
|
||||
|
||||
@helper CreateCategoryListRecursive(Project_Unite.Models.WikiCategory category) {
|
||||
<li>@category.Name
|
||||
<ul>
|
||||
@foreach(var cat in category.Children)
|
||||
{
|
||||
CreateCategoryListRecursive(cat);
|
||||
}
|
||||
@foreach(var page in category.Pages)
|
||||
{
|
||||
<li>@Html.ActionLink(page.Name, "Index", "Wiki", new { id = page.Id }, null)</li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-4 panel">
|
||||
<div class="panel-body">
|
||||
<h4>Pages</h4>
|
||||
|
||||
<ul>
|
||||
@foreach(var cat in Model.Categories)
|
||||
{
|
||||
CreateCategoryListRecursive(cat);
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-8 panel">
|
||||
<div class="panel-body">
|
||||
@if(Model.Page != null)
|
||||
{
|
||||
<h1>@Model.Page.Name</h1>
|
||||
|
||||
<p>@Html.Markdown(Model.Page.Contents)</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h1>ShiftOS Wiki</h1>
|
||||
|
||||
<p>The ShiftOS Wiki is a community and developer-driven handbook for everything you need to know about ShiftOS. It contains tutorials, guides, code examples, and loads of other interesting things. Read on!</p>
|
||||
|
||||
<h3>How to post to and edit the wiki</h3>
|
||||
|
||||
<p>If you have a ShiftOS account, and have the right privileges to a category, simply click the "Add new page" button at the top, and fill in the blanks.</p>
|
||||
|
||||
<p>If you don't have a ShiftOS account, this is the perfect time to @Html.ActionLink("create one", "Register", "Account")! Without one, how would you play the game?</p>
|
||||
|
||||
<h3>Adding categories</h3>
|
||||
|
||||
<p>Adding categories is only available to those with the `CanManageWikiCategories` access control definition. If you have this ACL definition, you may manage wiki categories from the Developer Control Panel.</p>
|
||||
|
||||
<h3>This wiki supports Markdown!</h3>
|
||||
|
||||
<p>You can use Markdown in the wiki, just like you would in a forum post, skin description or user status update. We use the CommonMark standard - which is the standard used by websites and software like GitHub, Discourse, Gitter, and various others.</p>
|
||||
|
||||
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in a new issue