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 WikiPages { get; set; } + public DbSet 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 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 @@ + Global.asax @@ -426,6 +427,7 @@ + @@ -534,10 +536,12 @@ + + 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) { +
  • @category.Name +
      + @foreach(var cat in category.Children) + { + CreateCategoryListRecursive(cat); + } + @foreach(var page in category.Pages) + { +
    • @Html.ActionLink(page.Name, "Index", "Wiki", new { id = page.Id }, null)
    • + } +
    +
  • +} + +
    +
    +
    +

    Pages

    + +
      + @foreach(var cat in Model.Categories) + { + CreateCategoryListRecursive(cat); + } +
    +
    +
    + +
    +
    + @if(Model.Page != null) + { +

    @Model.Page.Name

    + +

    @Html.Markdown(Model.Page.Contents)

    + } + else + { +

    ShiftOS Wiki

    + +

    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!

    + +

    How to post to and edit the wiki

    + +

    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.

    + +

    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?

    + +

    Adding categories

    + +

    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.

    + +

    This wiki supports Markdown!

    + +

    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.

    + + + } +
    +
    +
    +