Skip to content

Commit

Permalink
- Started adding in Asking a Question.
Browse files Browse the repository at this point in the history
  • Loading branch information
PureKrome committed Jan 10, 2012
1 parent 0f00648 commit d76b0ec
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 15 deletions.
@@ -0,0 +1,43 @@
using System.Web.Mvc;
using Raven.Client;
using RavenOverflow.Web.Areas.Question.Models.ViewModels;
using RavenOverflow.Web.Controllers;

namespace RavenOverflow.Web.Areas.Question.Controllers
{
public class QuestionsController : AbstractController
{
public QuestionsController(IDocumentSession documentSession) : base(documentSession)
{
}

public ActionResult Details(int id)
{
return View();
}

public ActionResult Create()
{
var viewModel = new CreateViewModel(User.Identity)
{
Header = "Ask a Question"
};
return View();
}

[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here

return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
@@ -0,0 +1,12 @@
using RavenOverflow.Web.Models;
using RavenOverflow.Web.Models.Authentication;

namespace RavenOverflow.Web.Areas.Question.Models.ViewModels
{
public class CreateViewModel : _LayoutViewModel
{
public CreateViewModel(ICustomIdentity customIdentity) : base(customIdentity)
{
}
}
}
27 changes: 27 additions & 0 deletions Code/RavenOverflow.Web/Areas/Question/QuestionAreaRegistration.cs
@@ -0,0 +1,27 @@
using System.Web.Mvc;

namespace RavenOverflow.Web.Areas.Question
{
public class QuestionAreaRegistration : AreaRegistration
{
public override string AreaName
{
get { return "Question"; }
}

public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Question - ask",
"Question/ask",
new { controller = "Questions", action = "Create" }
);

context.MapRoute(
"Question_default",
"Question/{action}/{id}",
new { controller = "Questions", action = "Index", id = UrlParameter.Optional }
);
}
}
}
@@ -0,0 +1,45 @@
@using RavenOverflow.Web.Areas.Question.Models.ViewModels
@model CreateViewModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Header
{
@Model.Header
}

@section SideBar
{
<div>How to Ask a Question</div>
}

@using (Html.BeginForm())
{
<div class="form-item ask-title">
<table class="ask-title-table">
<tbody>
<tr>
<td class="ask-title-cell-key">
<label for="title">Title</label>
</td>
<td class="ask-title-cell-value">
<input type="text" maxlength="300" tabindex="100" class="actual-edit-overlay" value="" style="position: absolute; background-color: white; color: black; -webkit-text-fill-color: black; opacity: 1; width: 610px; height: 16px; line-height: normal; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; text-align: -webkit-auto; border-left-style: solid; border-right-style: solid; border-top-style: solid; border-bottom-style: solid; border-left-color: rgb(153, 153, 153); border-right-color: rgb(153, 153, 153); border-top-color: rgb(153, 153, 153); border-bottom-color: rgb(153, 153, 153); border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; " disabled="disabled"><input id="title" name="title" type="text" maxlength="300" tabindex="100" class="ask-title-field edit-field-overlayed" value="" style="z-index: 1; position: relative; opacity: 0.4; ">
</td>
</tr>
</tbody>
</table>
<div id="question-suggestions">
</div>
</div>
<div id="post-editor" class="post-editor">
<textarea id="wmd-input" class="wmd-input processed" name="post-text" cols="92" rows="15" tabindex="101"></textarea>
</div>
<div class="form-item">
<label>Tags</label>
<input id="tagnames" name="tagnames" type="text" size="60" value="" tabindex="103" style="display: none; ">
<div class="actual-edit-overlay" style="position: absolute; background-color: white; color: black; -webkit-text-fill-color: black; opacity: 1; width: 666px; height: 28px; line-height: 28px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; text-align: -webkit-auto; border-left-style: solid; border-right-style: solid; border-top-style: solid; border-bottom-style: solid; border-left-color: rgb(153, 153, 153); border-right-color: rgb(153, 153, 153); border-top-color: rgb(153, 153, 153); border-bottom-color: rgb(153, 153, 153); border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; " disabled="disabled">&nbsp;at least one tag such as (asp.net xml c++), max 5 tags</div><div class="tag-editor edit-field-overlayed" style="width: 666px; height: 28px; opacity: 0.4; z-index: 1; position: relative; "><span style=""></span><input type="text" tabindex="103" style="width: 658px; "><span></span></div>
<span class="edit-field-overlay">at least one tag such as (asp.net xml c++), max 5 tags</span>
</div>

}
58 changes: 58 additions & 0 deletions Code/RavenOverflow.Web/Areas/Question/Views/Web.config
@@ -0,0 +1,58 @@
<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>

<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>

<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>

<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />

<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
25 changes: 10 additions & 15 deletions Code/RavenOverflow.Web/Global.asax.cs
@@ -1,22 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Raven.Abstractions.Data;
using Raven.Client;
using Raven.Client.MvcIntegration;
using RavenOverflow.Core.Entities;
using RavenOverflow.FakeData;
using System.Collections.Generic;
using RavenOverflow.Web.Indexes;
using RavenOverflow.Web.Models.Authentication;
using StructureMap;

namespace RavenOverflow.Web
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
// ReSharper disable InconsistentNaming

public class MvcApplication : HttpApplication
{
Expand All @@ -33,7 +31,7 @@ public static void RegisterRoutes(RouteCollection routes)
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults
);
}

Expand All @@ -43,9 +41,7 @@ private static void RegisterRazorViewEngine()
ViewEngines.Engines.Add(new RazorViewEngine());
}

// ReSharper disable InconsistentNaming
protected void Application_Start()
// ReSharper restore InconsistentNaming
{
AreaRegistration.RegisterAllAreas();

Expand All @@ -66,25 +62,24 @@ protected void Application_Start()
RavenProfiler.InitializeFor(ObjectFactory.GetInstance<IDocumentStore>());
}

// ReSharper disable InconsistentNaming
protected void Application_AuthenticateRequest()
// ReSharper restore InconsistentNaming

{
CustomFormsAuthentication.AuthenticateRequestDecryptCustomFormsAuthenticationTicket(Context);
}

private static void SeedDocumentStore(IDocumentStore documentStore)
{
using (var session = documentStore.OpenSession())
using (IDocumentSession session = documentStore.OpenSession())
{
// Don't add any seed data, if we already have some data in the system.
var user = session.Query<User>().Take(1).ToList();
List<User> user = session.Query<User>().Take(1).ToList();
if (user.Any())
{
return;
}

var users = FakeUsers.CreateFakeUsers();
ICollection<User> users = FakeUsers.CreateFakeUsers();

StoreEntites(session, users);

Expand All @@ -106,12 +101,12 @@ private static void StoreEntites(IDocumentSession session, IEnumerable<RootAggre
throw new ArgumentNullException("entities");
}

foreach (var entity in entities)
foreach (RootAggregate entity in entities)
{
session.Store(entity);
}
}


}

// ReSharper restore InconsistentNaming
}
13 changes: 13 additions & 0 deletions Code/RavenOverflow.Web/RavenOverflow.Web.csproj
Expand Up @@ -73,6 +73,9 @@
<Reference Include="Raven.Client.MvcIntegration, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\RavenDB.1.0.573\lib\net40\Raven.Client.MvcIntegration.dll</HintPath>
</Reference>
<Reference Include="RouteDebugger">
<HintPath>..\..\packages\routedebugger.2.1.2\lib\net40\RouteDebugger.dll</HintPath>
</Reference>
<Reference Include="StructureMap">
<HintPath>..\..\packages\structuremap.2.6.3\lib\StructureMap.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -107,6 +110,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\StructuremapMvc.cs" />
<Compile Include="Areas\Question\Controllers\QuestionsController.cs" />
<Compile Include="Areas\Question\Models\ViewModels\CreateViewModel.cs" />
<Compile Include="Areas\Question\QuestionAreaRegistration.cs" />
<Compile Include="Areas\User\Controllers\UsersController.cs" />
<Compile Include="Areas\User\UserAreaRegistration.cs" />
<Compile Include="DependencyResolution\AuthenticationRegistry.cs" />
Expand Down Expand Up @@ -154,6 +160,7 @@
<Content Include="Views\Shared\_Layout.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\Question\Views\Shared\" />
<Folder Include="Areas\User\Models\" />
<Folder Include="Areas\User\Views\Shared\" />
<Folder Include="Scripts\" />
Expand Down Expand Up @@ -211,6 +218,12 @@
<ItemGroup>
<Content Include="Views\Shared\_QuestionTagList.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Areas\Question\Views\Web.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Areas\Question\Views\Questions\Create.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
1 change: 1 addition & 0 deletions Code/RavenOverflow.Web/Web.config
Expand Up @@ -16,6 +16,7 @@
<add key="FacebookSecret" value="4727898cbaaba07eed0a1ca60f1e74b3" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="RouteDebugger:Enabled" value="true" />
</appSettings>
<!-- Unused .. i think the Facebook library uses this .. which i'm not leveraging. -->
<system.web>
Expand Down
1 change: 1 addition & 0 deletions Code/RavenOverflow.Web/packages.config
Expand Up @@ -7,6 +7,7 @@
<package id="Newtonsoft.Json" version="4.0.5" />
<package id="NLog" version="2.0.0.2000" />
<package id="RavenDB" version="1.0.573" />
<package id="routedebugger" version="2.1.2" />
<package id="structuremap" version="2.6.3" />
<package id="StructureMap.MVC3" version="1.0.8" />
<package id="WebActivator" version="1.5" />
Expand Down

0 comments on commit d76b0ec

Please sign in to comment.