Skip to content

Commit

Permalink
Updated UI to use Bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
jzablocki committed May 15, 2012
1 parent 40b524b commit 7c220dd
Show file tree
Hide file tree
Showing 16 changed files with 918 additions and 195 deletions.
81 changes: 0 additions & 81 deletions src/TapMapWeb/Content/Site.css
@@ -1,62 +1,3 @@
body
{
font-size: .85em;
font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif;
color: #232323;
background-color: #680000;
margin:0px;
}

header,
footer,
nav,
section {
display: block;
}

h2
{
padding:10px;
}

a
{
color:#FF0000;
}


/* Styles for basic forms
-----------------------------------------------------------*/

fieldset
{
border:1px solid #ddd;
padding:0 1.4em 1.4em 1.4em;
margin:20px 20px 1.5em 20px;
}

legend
{
font-size:1.2em;
font-weight: bold;
}

textarea
{
min-height: 75px;
}

.editor-label
{
margin: 1em 0 0 0;
}

.editor-field
{
margin:0.5em 0 0 0;
}


/* Styles for validation helpers
-----------------------------------------------------------*/
.field-validation-error
Expand Down Expand Up @@ -84,26 +25,4 @@ textarea
.validation-summary-valid
{
display: none;
}

/* Navigation ------------- */
#main-nav
{
background-color:#303030;
color:#fff;
font-size:2.0em;
}

#main-nav a
{
color:#fff;
text-decoration:none;
margin-right:10px;
margin-left:10px;
}

#main-nav a:hover
{
color:#c0c0c0;
background-color:#000;
}
734 changes: 734 additions & 0 deletions src/TapMapWeb/Content/Styles/bootstrap.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/TapMapWeb/Controllers/AccountController.cs
Expand Up @@ -49,7 +49,7 @@ public ActionResult LogOn(string username, string password)
public ActionResult LogOut()
{
SessionUser.SetCurrent(null);
return RedirectToAction("Index");
return RedirectToAction("Index", "Home");
}
//
// GET: /Account/Details/5
Expand Down
1 change: 0 additions & 1 deletion src/TapMapWeb/Controllers/TapController.cs
Expand Up @@ -58,7 +58,6 @@ public ActionResult List()
time = t.Timestamp,
user = t.Username
})
//.Where(t => t.time > SessionUser.Current.LastQuery)
.ToList(), JsonRequestBehavior.AllowGet);
SessionUser.Current.LastQuery = DateTime.Now;
return json;
Expand Down
5 changes: 4 additions & 1 deletion src/TapMapWeb/Models/BeerRepository.cs
Expand Up @@ -9,7 +9,10 @@ public class BeerRepository : RepositoryBase<Beer>
{
public IEnumerable<Beer> GetBeers(string startsWith)
{
return View("all_beers").StartKey(startsWith).Where(c => c.Name.StartsWith(startsWith));
foreach (var item in View("all_beers").StartKey(startsWith).EndKey(startsWith + "Z"))
{
yield return Get(item.ItemId);
}
}
}
}
5 changes: 4 additions & 1 deletion src/TapMapWeb/Models/PlaceRepository.cs
Expand Up @@ -10,7 +10,10 @@ public class PlaceRepository : RepositoryBase<Place>

public IEnumerable<Place> GetPlaces(string startsWith)
{
return View("all_places").StartKey(startsWith).Where(c => c.Name.StartsWith(startsWith));
foreach (var item in View("all_places").StartKey(startsWith).EndKey(startsWith + "Z"))
{
yield return Get(item.ItemId);
}
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/TapMapWeb/Models/RepositoryBase.cs
Expand Up @@ -43,9 +43,9 @@ public virtual void Remove(string id)
_Client.Remove(id);
}

protected IView<T> View(string viewName)
{
return _Client.GetView<T>(InflectorNet.Pluralize(typeof(T).Name.ToLower()), viewName);
protected IView<IViewRow> View(string viewName)
{
return _Client.GetView(InflectorNet.Pluralize(typeof(T).Name.ToLower()), viewName);
}

protected IView<IViewRow> Project(string viewName)
Expand Down
5 changes: 4 additions & 1 deletion src/TapMapWeb/Models/TapRepository.cs
Expand Up @@ -21,7 +21,10 @@ public override ulong Create(Tap model)

public IEnumerable<Tap> GetTaps()
{
return View("all_taps").Limit(10).ToList();
foreach (var item in View("all_taps").Limit(20).Descending(true))
{
yield return Get(item.ItemId);
}
}
}
}
12 changes: 10 additions & 2 deletions src/TapMapWeb/Models/UserRepository.cs
Expand Up @@ -23,7 +23,11 @@ public override ulong Create(User model)

public User GetByEmail(string email)
{
return View("by_email").Limit(1).Key(email).Stale(StaleMode.False).FirstOrDefault();
foreach (var item in View("by_email").Limit(1).Key(email).Stale(StaleMode.False))
{
return Get(item.ItemId);
}
return null;
}

private Couchbase.StaleMode StaleModeFirstOrDefault()
Expand All @@ -33,7 +37,11 @@ private Couchbase.StaleMode StaleModeFirstOrDefault()

public User GetByUsername(string username)
{
return View("by_username").Limit(1).Key(username).Stale(StaleMode.False).FirstOrDefault();
foreach (var item in View("by_username").Limit(1).Key(username).Stale(StaleMode.False))
{
return Get(item.ItemId);
}
return null;
}

public User Get(string username, string password)
Expand Down
4 changes: 4 additions & 0 deletions src/TapMapWeb/TapMapWeb.csproj
Expand Up @@ -105,6 +105,7 @@
<Compile Include="Session\SessionUser.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\Styles\bootstrap.min.css" />
<Content Include="Content\Styles\Grid.css" />
<Content Include="Content\themes\base\images\ui-bg_flat_0_aaaaaa_40x100.png" />
<Content Include="Content\themes\base\images\ui-bg_flat_75_ffffff_40x100.png" />
Expand Down Expand Up @@ -188,6 +189,9 @@
<ItemGroup>
<Content Include="Views\Account\Edit.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Shared\TapForm.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
12 changes: 9 additions & 3 deletions src/TapMapWeb/Views/Account/Create.cshtml
@@ -1,15 +1,21 @@
@model TapMapWeb.Models.User

@{
ViewBag.Title = "Create";
ViewBag.Title = "Register for TapMap";
}

<h2>Create</h2>
<h2>Register for TapMap</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {

<div style="padding:10px;">
Existing user? @Html.ActionLink("Login", "LogOn", "Account") here.
</div>

@using (Html.BeginForm("Create", "Account", FormMethod.Post, new { @class = "well" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>User</legend>
Expand Down
3 changes: 2 additions & 1 deletion src/TapMapWeb/Views/Account/LogOn.cshtml
Expand Up @@ -14,7 +14,8 @@ New user? @Html.ActionLink("Register", "Create", "Account") here.
</div>


@using (Html.BeginForm()) {
@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { @class = "form-vertical well" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Login</legend>
Expand Down
40 changes: 22 additions & 18 deletions src/TapMapWeb/Views/Home/Index.cshtml
@@ -1,23 +1,27 @@
@{
ViewBag.Title = "Index";
ViewBag.Title = "TapMap";
}

<h2>Taps</h2>
<h2>Welcome to TapMap</h2>

<div style="padding:10px;" id="taps">
<script language="javascript">
window.setInterval(function () {
$.get('@Url.Content("~/Tap/List")', function (data) {
$("#taps").empty();
$.each(data, function (i, v) {
$("#taps").append(
"<div>" + v.user + " tapped " + v.beer + " at " + v.place + "</div>" +
"<div style='margin-bottom:10px;border-bottom:1px solid #c0c0c0;'><em>"
+ v.comment + " at " + v.time +
"</em></div>"
);
});
<div id="taps" class="well" style="margin-top:20px;">

</div>

<script language="javascript">
window.setInterval(function () {
$.get('@Url.Content("~/Tap/List")', function (data) {
$("#taps").empty();
$.each(data, function (i, v) {
var date = v.time.replace("/Date(", "").replace(")/", "");
$("#taps").append(
"<div>" + v.user + " tapped " + v.beer + " at " + v.place + "</div>" +
"<div style='margin-bottom:10px;border-bottom:1px solid #c0c0c0;'><em>"
+ v.comment + " at " + new Date(parseInt(date)) +
"</em></div>"
);
});
}, 10000);
</script>
</div>
});
}, 1000);
</script>
44 changes: 44 additions & 0 deletions src/TapMapWeb/Views/Shared/TapForm.cshtml
@@ -0,0 +1,44 @@
@{ Func<bool> isLoggedIn = () => SessionUser.Current.IsInRole(TapMapWeb.Constants.RoleConstants.ACTIVE_USERS); }
@if (isLoggedIn())
{
<div>
@Html.Label("Place")
@Html.TextBox("Place")
@Html.Hidden("PlaceId")
@Html.Label("Beer")
@Html.TextBox("Beer")
@Html.Hidden("BeerId")
@Html.Label("Comment")
@Html.TextArea("Comment")
<input type="Button" value="Tap" id="Tap" class="btn-primary" />
</div>
}
<script language="javascript">
$().ready(function (a) {
$("#Place").autocomplete({
source: '@Url.Content("~/AutoComplete/Places")',
minLength: 2,
select: function (e, u) { $("#PlaceId").val(u.item.id); }
});
$("#Beer").autocomplete({
source: '@Url.Content("~/AutoComplete/Beers")',
minLength: 2,
select: function (e, u) { $("#BeerId").val(u.item.id); }
});
$("#Tap").bind("click", function (e) {
$.post('@Url.Content("~/Tap/Create")',
{
"placeId": $("#PlaceId").val(),
"beerId": $("#BeerId").val(),
"Comment": $("#Comment").val()
},
function (data) {
$("#Place").val("");
$("#Beer").val("");
$("#Comment").val("");
});
});
});
</script>

0 comments on commit 7c220dd

Please sign in to comment.