Browse Source

Added active tags and Url helper for getting current subdomain.

tags/2.0.3
Teknikode 4 years ago
parent
commit
03a5b5ab46

+ 25
- 2
Teknik/Areas/Profile/Views/Profile/Index.cshtml View File

@@ -133,6 +133,31 @@
<input class="form-control" id="update_blog_description" name="update_blog_description" placeholder="This blog is not worth reading." title="enter your blog's description" type="text" value="@Model.BlogDescription" />
</div>
</div>
<!-- Upload Settings -->
<div class="row">
<div class="col-sm-12 text-center">
<h3>Upload Settings</h3>
</div>
</div>
<hr>
<div class="row">
<div class="form-group col-sm-6">
<label for="update_blog_title"><h4>Title</h4></label>
<input class="form-control" id="update_blog_title" name="update_blog_title" placeholder="click bait" title="enter your blog's title" type="text" value="@Model.BlogTitle" />
</div>
<div class="form-group col-sm-6">
<label for="update_blog_description"><h4>Description</h4></label>
<input class="form-control" id="update_blog_description" name="update_blog_description" placeholder="This blog is not worth reading." title="enter your blog's description" type="text" value="@Model.BlogDescription" />
</div>
</div>
<!-- Paste Settings -->
<div class="row">
<div class="col-sm-12 text-center">
<h3>Paste Settings</h3>
</div>
</div>
<hr>
<!-- Save Settings -->
<div class="row">
<div class="form-group col-sm-12">
<br />
@@ -140,8 +165,6 @@
<button class="btn btn-lg" type="reset"><i class="glyphicon glyphicon-repeat"></i> Reset</button>
</div>
</div>
<!-- Upload Settings -->
<!-- Paste Settings -->
</form>
</div><!--/tab-pane-->
<div class="tab-pane" id="privacy">

+ 26
- 0
Teknik/Helpers/UrlExtensions.cs View File

@@ -125,5 +125,31 @@ namespace Teknik
else
return string.Empty;
}

public static string GetSubdomain(this UrlHelper url)
{
string host = url.RequestContext.HttpContext.Request.Url.Authority;
// Grab the sub from parameters if it exists
string subParam = url.RequestContext.HttpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname unless on dev
if (string.IsNullOrEmpty(subParam))
{
// If we are on dev and no subparam, we need to set the subparam to the specified sub
subParam = host.GetSubdomain();
}
return subParam;
}

public static string GetActive(this UrlHelper url, params string[] subs)
{
string curSub = url.GetSubdomain();
foreach (string sub in subs)
{
if (curSub == sub)
{
return "active";
}
}
return string.Empty;
}
}
}

+ 1
- 0
Teknik/ViewModels/ViewModelBase.cs View File

@@ -29,6 +29,7 @@ namespace Teknik.ViewModels
public ViewModelBase()
{
Error = false;
ErrorMessage = string.Empty;
}
}
}

+ 11
- 15
Teknik/Views/Shared/_Navbar.cshtml View File

@@ -12,45 +12,41 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="@Url.SubRouteUrl("www", "Home.Index")">Home</a></li>
<li><a href="@Url.SubRouteUrl("about", "About.Index")">About</a></li>
<li class="@Url.GetActive("www", string.Empty)"><a href="@Url.SubRouteUrl("www", "Home.Index")">Home</a></li>
<li class="@Url.GetActive("about")"><a href="@Url.SubRouteUrl("about", "About.Index")">About</a></li>
<li class="divider-vertical"></li>

<li class="dropdown">
<a href="#" id="services_menu" class="dropdown-toggle" data-toggle="dropdown">Services <strong class="caret"></strong></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="services_menu">
<li>
<li class="@Url.GetActive("blog")">
<a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = string.Empty })">Blog</a>
</li>
<li>
<li class="@Url.GetActive("podcast")">
<a href="@Url.SubRouteUrl("podcast", "Podcast.Index")">Podcast</a>
</li>
<li class="divider"></li>
<li>
<li class="@Url.GetActive("upload", "u")">
<a href="@Url.SubRouteUrl("upload", "Upload.Index")">Upload</a>
</li>
<li>
<li class="@Url.GetActive("paste", "p")">
<a href="@Url.SubRouteUrl("paste", "Paste.Index")">Paste</a>
</li>
<li>
<li class="@Url.GetActive("git")">
<a href="@Url.SubRouteUrl("git", "Git.Index")">Git</a>
</li>
<li>
<li class="@Url.GetActive("mail")">
<a href="@Url.SubRouteUrl("mail", "Mail.Index")" target="_blank">Mail</a>
</li>
<li>
<li class="@Url.GetActive("mumble")">
<a href="mumble://mumble.@(Model.Config.Host):64738/?version=1.2.5" target="_blank">Mumble</a>
</li>
<li class="divider"></li>
<li>
<a href="@Url.SubRouteUrl("ricehalla", "Ricehalla.Index")">Ricehalla</a>
</li>
</ul>
</li>
<li>
<li class="@Url.GetActive("contact")">
<a href="@Url.SubRouteUrl("contact", "Contact.Index")">Contact</a>
</li>
<li>
<li class="@Url.GetActive("help")">
<a href="@Url.SubRouteUrl("help", "Help.Index")">Help</a>
</li>
</ul>

Loading…
Cancel
Save