summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-03-27 18:57:07 -0400
committerMichael <[email protected]>2017-03-27 18:57:07 -0400
commit1dcbadf2eb928c63ce3a968f311f6af6b81d33a4 (patch)
tree53491bbdee3e5d77059f810541441ff585c96d0e
parent7111f0d5cd4123287d2510d77350d849afe7ea98 (diff)
downloadproject-unite-1dcbadf2eb928c63ce3a968f311f6af6b81d33a4.tar.gz
project-unite-1dcbadf2eb928c63ce3a968f311f6af6b81d33a4.tar.bz2
project-unite-1dcbadf2eb928c63ce3a968f311f6af6b81d33a4.zip
Beginning of wiki development
-rw-r--r--Project-Unite/Controllers/WikiControllerController.cs22
-rw-r--r--Project-Unite/Models/IdentityModels.cs3
-rw-r--r--Project-Unite/Models/WikiModels.cs69
-rw-r--r--Project-Unite/Project-Unite.csproj4
-rw-r--r--Project-Unite/Views/Wiki/Index.cshtml76
5 files changed, 174 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/WikiControllerController.cs b/Project-Unite/Controllers/WikiControllerController.cs
new file mode 100644
index 0000000..1840074
--- /dev/null
+++ b/Project-Unite/Controllers/WikiControllerController.cs
@@ -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);
+ }
+ }
+} \ No newline at end of file
diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs
index 5ec480f..cf04def 100644
--- a/Project-Unite/Models/IdentityModels.cs
+++ b/Project-Unite/Models/IdentityModels.cs
@@ -204,6 +204,9 @@ namespace Project_Unite.Models
}
+ public DbSet<WikiPage> WikiPages { get; set; }
+ public DbSet<WikiCategory> WikiCategories { get; set; }
+
public void DeleteObject(object obj)
{
((IObjectContextAdapter)this).ObjectContext.DeleteObject(obj);
diff --git a/Project-Unite/Models/WikiModels.cs b/Project-Unite/Models/WikiModels.cs
new file mode 100644
index 0000000..ac6c6cb
--- /dev/null
+++ b/Project-Unite/Models/WikiModels.cs
@@ -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();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj
index 74f2ef4..2872ce2 100644
--- a/Project-Unite/Project-Unite.csproj
+++ b/Project-Unite/Project-Unite.csproj
@@ -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" />
diff --git a/Project-Unite/Views/Wiki/Index.cshtml b/Project-Unite/Views/Wiki/Index.cshtml
new file mode 100644
index 0000000..dc7d8bb
--- /dev/null
+++ b/Project-Unite/Views/Wiki/Index.cshtml
@@ -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>
+