Optimize and cache member data, move from unnecessary macros to regular partials in the master and community templates
This commit is contained in:
@@ -1687,8 +1687,6 @@
|
||||
<Content Include="Views\DisplayTopic.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Forum\TopicForm.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Members\HeaderProfile.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Members\QuickMenu.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Members\JsValues.cshtml" />
|
||||
<Content Include="Views\Partials\Forum\Comment.cshtml" />
|
||||
<Content Include="Assets\css\fonts\our-icon\our-umbraco.eot" />
|
||||
<Content Include="Assets\css\fonts\our-icon\our-umbraco.svg" />
|
||||
@@ -1696,7 +1694,6 @@
|
||||
<Content Include="Assets\css\fonts\our-icon\our-umbraco.woff" />
|
||||
<Content Include="Assets\images\logo.svg" />
|
||||
<Content Include="Assets\images\magnifier.svg" />
|
||||
<Content Include="Views\MacroPartials\Navigation\TopNavigation.cshtml" />
|
||||
<Content Include="Assets\css\fonts\icomoon\icomoon.eot" />
|
||||
<Content Include="Assets\css\fonts\icomoon\icomoon.ttf" />
|
||||
<Content Include="Assets\css\fonts\icomoon\icomoon.woff" />
|
||||
@@ -1717,7 +1714,6 @@
|
||||
<Content Include="Views\MacroPartials\Projects\ProjectDetails.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Members\Register.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Members\ProfileProjectForums.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Global\AlertBar.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Members\PublicProfile.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Rss\Forum.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Rss\LatestTopics.cshtml" />
|
||||
@@ -1734,7 +1730,6 @@
|
||||
<Content Include="umbraco\lib\font-awesome\fonts\FontAwesome.otf" />
|
||||
<Content Include="macroScripts\repository-popularpackages.cshtml" />
|
||||
<Content Include="Views\MacroPartials\RedirectProjectCategory.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Community\Home.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Project\Edit.cshtml" />
|
||||
<Content Include="umbraco\lib\bootstrap-tabdrop\README.md" />
|
||||
<Content Include="Views\MacroPartials\Releases\ReleasesDropdown.cshtml" />
|
||||
@@ -1750,13 +1745,15 @@
|
||||
<Content Include="Views\FileDownload.cshtml" />
|
||||
<Content Include="Views\DocumentationSubpage.cshtml" />
|
||||
<Content Include="Views\Download.cshtml" />
|
||||
<Content Include="Views\Partials\Community\Scripts.cshtml" />
|
||||
<Content Include="Views\Partials\Community\Home.cshtml" />
|
||||
<Content Include="Views\Partials\Community\JsValues.cshtml" />
|
||||
<None Include="Views\Partials\Forum\MemberBadge.cshtml" />
|
||||
<Content Include="Views\Partials\Project\EditFiles.cshtml" />
|
||||
<Content Include="Views\Partials\Project\PackageEditNavigation.cshtml" />
|
||||
<Content Include="Views\Partials\Project\EditScreenshots.cshtml" />
|
||||
<Content Include="Views\Partials\Project\Complete.cshtml" />
|
||||
<Content Include="Views\Partials\Home\LatestForumActivity.cshtml" />
|
||||
<Content Include="Views\MacroPartials\Community\Scripts.cshtml" />
|
||||
<Content Include="Service References\Application Insights\ConnectedService.json" />
|
||||
<Content Include="Views\Web.config" />
|
||||
<Content Include="web.config">
|
||||
@@ -4346,8 +4343,6 @@
|
||||
<Content Include="Views\Release.cshtml" />
|
||||
<Content Include="Views\Textpage.cshtml" />
|
||||
<Content Include="Views\RoadMap.cshtml" />
|
||||
<Content Include="Views\Partials\Members\Login.cshtml" />
|
||||
<Content Include="Views\Partials\Members\ForgotPassword.cshtml" />
|
||||
<Content Include="Views\Profilepage.cshtml" />
|
||||
<Content Include="Views\ProjectPage.cshtml" />
|
||||
<Content Include="Views\ReleaseDownload.cshtml" />
|
||||
@@ -4367,6 +4362,9 @@
|
||||
<Content Include="Views\Partials\Grid\Bootstrap3-Fluid.cshtml" />
|
||||
<Content Include="Views\Partials\Grid\Bootstrap2.cshtml" />
|
||||
<Content Include="Views\Partials\Grid\Bootstrap2-Fluid.cshtml" />
|
||||
<Content Include="Views\Partials\Members\QuickMenu.cshtml" />
|
||||
<Content Include="Views\Partials\Navigation\TopNavigation.cshtml" />
|
||||
<Content Include="Views\Partials\Global\Alertbar.cshtml" />
|
||||
<None Include="web.Debug.config">
|
||||
<DependentUpon>web.config</DependentUpon>
|
||||
</None>
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
Layout = "~/Views/Master.cshtml";
|
||||
}
|
||||
|
||||
@Umbraco.RenderMacro("CommunityHome")
|
||||
@Html.Partial("~/Views/Partials/Community/Home.cshtml")
|
||||
|
||||
@section Search {
|
||||
@section Search
|
||||
{
|
||||
<script type="text/template" class="search-item-template">
|
||||
<li>
|
||||
<a href="{{ url }}">
|
||||
@@ -26,4 +27,7 @@
|
||||
</script>
|
||||
}
|
||||
|
||||
@Umbraco.RenderMacro("CommunityHomeScripts")
|
||||
@section EndScripts
|
||||
{
|
||||
@Html.Partial("~/Views/Partials/Community/Scripts.cshtml")
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
@using OurUmbraco.Forum.Extensions
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
|
||||
@if(Members.IsLoggedIn()){
|
||||
|
||||
|
||||
var profile = Members.GetCurrentMemberProfileModel();
|
||||
var member = Members.GetCurrentMember();
|
||||
|
||||
if (member != null) {
|
||||
<script type="text/javascript">
|
||||
var umb_member_name = '@member.Name';
|
||||
var umb_member_email = '@profile.Email';
|
||||
var umb_member_icon = '@member.Avatar()';
|
||||
</script>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
Html.RequiresCss("https://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic", 0);
|
||||
Html.RequiresCss("https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css", 0);
|
||||
|
||||
|
||||
|
||||
Html.RequiresJs("https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.13.1/jquery.validate.min.js");
|
||||
Html.RequiresJs("https://ajax.aspnetcdn.com/ajax/mvc/4.0/jquery.validate.unobtrusive.min.js");
|
||||
Html.RequiresJs("https://cdnjs.cloudflare.com/ajax/libs/pagedown/1.0/Markdown.Converter.js");
|
||||
@@ -72,7 +72,21 @@
|
||||
<link rel="icon" type="image/png" href="/assets/images/app-icons/favicon.png">
|
||||
|
||||
<title>
|
||||
@Umbraco.RenderMacro("Title")
|
||||
@{
|
||||
var title = string.Empty;
|
||||
var topicTitle = HttpContext.Current.Items["topicTitle"];
|
||||
if (topicTitle != null)
|
||||
{
|
||||
title = topicTitle.ToString();
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(title) == false)
|
||||
{
|
||||
<text>@title - </text>
|
||||
}
|
||||
}
|
||||
|
||||
@Model.Content.Name - our.umbraco.org
|
||||
</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
@@ -82,7 +96,7 @@
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-1.7.2.min.js"></script>
|
||||
|
||||
@Umbraco.RenderMacro("MembersJsValues")
|
||||
@Html.Partial("~/Views/Partials/Community/JsValues.cshtml")
|
||||
|
||||
@Html.RenderCssHere()
|
||||
|
||||
@@ -112,7 +126,7 @@
|
||||
</head>
|
||||
|
||||
<body class="@bodyCss">
|
||||
@Umbraco.RenderMacro("MembersQuickMenu")
|
||||
@Html.Partial("~/Views/Partials/Members/QuickMenu.cshtml")
|
||||
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
@@ -126,7 +140,7 @@
|
||||
<a href="#" class="toggle cross"><span></span></a>
|
||||
</div>
|
||||
<nav class="col-md-9">
|
||||
@Umbraco.RenderMacro("NavigationTopNavigation")
|
||||
@Html.Partial("~/Views/Partials/Navigation/TopNavigation.cshtml")
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
@@ -136,7 +150,7 @@
|
||||
@{
|
||||
if (memberIsBlocked == false)
|
||||
{
|
||||
@Umbraco.RenderMacro("GlobalAlertBar")
|
||||
@Html.Partial("~/Views/Partials/Global/AlertBar.cshtml")
|
||||
@RenderSection("Search", false)
|
||||
@RenderBody()
|
||||
}
|
||||
@@ -175,7 +189,7 @@
|
||||
|
||||
</div>
|
||||
<!--.wrapper-->
|
||||
|
||||
|
||||
@Html.RenderJsHere()
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
+126
-126
@@ -1,127 +1,127 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
@{
|
||||
var homeNotificationText = Model.Content.GetPropertyValue<string>("homeOnlyBanner");
|
||||
var showHomeNotification = string.IsNullOrWhiteSpace(homeNotificationText) == false;
|
||||
var globalNotificationText = Model.Content.GetPropertyValue<string>("mainNotification");
|
||||
var showGlobalNotification = string.IsNullOrWhiteSpace(globalNotificationText) == false;
|
||||
}
|
||||
<!-- Search start -->
|
||||
<section id="search-all" class="search-all">
|
||||
|
||||
<div class="search-all-form">
|
||||
<div class="search-fieldset">
|
||||
<input class="search-input" type="search" placeholder="Search..">
|
||||
<input class="search-submit" type="submit" value="">
|
||||
</div>
|
||||
<span class="search-all-close"></span>
|
||||
</div>
|
||||
|
||||
<div class="search-all-results equalizer">
|
||||
<ul></ul>
|
||||
</div>
|
||||
|
||||
@if (!Members.IsLoggedIn())
|
||||
{
|
||||
<div class="search-text">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<strong>The friendliest CMS community on the planet</strong>
|
||||
<p>our.umbraco.org is the central hub for the friendly umbraco community. Search for documentation, get help and guidance from seasoned experts, download and collaborate on plugins and extensions.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</section>
|
||||
<!-- Search end -->
|
||||
|
||||
<style>
|
||||
.bannertext p{
|
||||
line-height: 1.4rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@if (showGlobalNotification)
|
||||
{
|
||||
<div class="alertbar__yellow">
|
||||
@Html.Raw(globalNotificationText)
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showHomeNotification)
|
||||
{
|
||||
@Html.Raw(homeNotificationText)
|
||||
}
|
||||
|
||||
@if (Members.IsLoggedIn())
|
||||
{
|
||||
@ForumActivity()
|
||||
@TwitterSearch()
|
||||
@Html.Partial("home/documentation")
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.Partial("home/documentation")
|
||||
@ForumActivity()
|
||||
@TwitterSearch()
|
||||
}
|
||||
|
||||
@helper ForumActivity()
|
||||
{
|
||||
<section class="forum">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<h1 class="text-center">Forum Activity</h1>
|
||||
<p>
|
||||
Recent activity in the forums, where people are helping each other with current problems.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<small>Recent posts</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 flex" id="forum-activity">
|
||||
<h2>Loading latest forum activity...</h2>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 goto-forum">
|
||||
<a class="button green" href="/forum">Go to Forum →</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
@helper TwitterSearch()
|
||||
{
|
||||
<section class="forum">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<h1 class="text-center">Twitter Activity</h1>
|
||||
<p>
|
||||
Recent activity on twitter, where people are talking about Umbraco.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<small>Recent tweets</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 flex" id="twitter-search">
|
||||
<h2>Loading twitter search results...</h2>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 goto-forum">
|
||||
<a class="button green" href="https://twitter.com/search?f=tweets&vertical=default&q=umbraco&src=typd">Join the conversation on Twitter →</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@inherits UmbracoViewPage<IPublishedContent>
|
||||
@{
|
||||
var homeNotificationText = Model.GetPropertyValue<string>("homeOnlyBanner");
|
||||
var showHomeNotification = string.IsNullOrWhiteSpace(homeNotificationText) == false;
|
||||
var globalNotificationText = Model.GetPropertyValue<string>("mainNotification");
|
||||
var showGlobalNotification = string.IsNullOrWhiteSpace(globalNotificationText) == false;
|
||||
}
|
||||
<!-- Search start -->
|
||||
<section id="search-all" class="search-all">
|
||||
|
||||
<div class="search-all-form">
|
||||
<div class="search-fieldset">
|
||||
<input class="search-input" type="search" placeholder="Search..">
|
||||
<input class="search-submit" type="submit" value="">
|
||||
</div>
|
||||
<span class="search-all-close"></span>
|
||||
</div>
|
||||
|
||||
<div class="search-all-results equalizer">
|
||||
<ul></ul>
|
||||
</div>
|
||||
|
||||
@if (!Members.IsLoggedIn())
|
||||
{
|
||||
<div class="search-text">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<strong>The friendliest CMS community on the planet</strong>
|
||||
<p>our.umbraco.org is the central hub for the friendly umbraco community. Search for documentation, get help and guidance from seasoned experts, download and collaborate on plugins and extensions.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</section>
|
||||
<!-- Search end -->
|
||||
|
||||
<style>
|
||||
.bannertext p{
|
||||
line-height: 1.4rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@if (showGlobalNotification)
|
||||
{
|
||||
<div class="alertbar__yellow">
|
||||
@Html.Raw(globalNotificationText)
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showHomeNotification)
|
||||
{
|
||||
@Html.Raw(homeNotificationText)
|
||||
}
|
||||
|
||||
@if (Members.IsLoggedIn())
|
||||
{
|
||||
@ForumActivity()
|
||||
@TwitterSearch()
|
||||
@Html.Partial("home/documentation")
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.Partial("home/documentation")
|
||||
@ForumActivity()
|
||||
@TwitterSearch()
|
||||
}
|
||||
|
||||
@helper ForumActivity()
|
||||
{
|
||||
<section class="forum">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<h1 class="text-center">Forum Activity</h1>
|
||||
<p>
|
||||
Recent activity in the forums, where people are helping each other with current problems.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<small>Recent posts</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 flex" id="forum-activity">
|
||||
<h2>Loading latest forum activity...</h2>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 goto-forum">
|
||||
<a class="button green" href="/forum">Go to Forum →</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
@helper TwitterSearch()
|
||||
{
|
||||
<section class="forum">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<h1 class="text-center">Twitter Activity</h1>
|
||||
<p>
|
||||
Recent activity on twitter, where people are talking about Umbraco.
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<small>Recent tweets</small>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 flex" id="twitter-search">
|
||||
<h2>Loading twitter search results...</h2>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 goto-forum">
|
||||
<a class="button green" href="https://twitter.com/search?f=tweets&vertical=default&q=umbraco&src=typd">Join the conversation on Twitter →</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
@using OurUmbraco.Forum.Extensions
|
||||
@using Umbraco.Core.Cache
|
||||
@inherits UmbracoViewPage<IPublishedContent>
|
||||
@{
|
||||
MemberJsValues memberJsValues = null;
|
||||
if (Members.IsLoggedIn())
|
||||
{
|
||||
var userName = Members.CurrentUserName;
|
||||
if (userName != null)
|
||||
{
|
||||
memberJsValues = ApplicationContext.ApplicationCache.RuntimeCache
|
||||
.GetCacheItem<MemberJsValues>("MemberJsValues" + userName,
|
||||
() =>
|
||||
{
|
||||
var profile = Members.GetCurrentMemberProfileModel();
|
||||
var member = Members.GetCurrentMember();
|
||||
|
||||
return new MemberJsValues
|
||||
{
|
||||
Name = member.Name,
|
||||
Email = profile.Email,
|
||||
Icon = member.Avatar()
|
||||
};
|
||||
}, TimeSpan.FromMinutes(30), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@if (memberJsValues != null)
|
||||
{
|
||||
<script type="text/javascript">
|
||||
var umb_member_name = '@memberJsValues.Name';
|
||||
var umb_member_email = '@memberJsValues.Email';
|
||||
var umb_member_icon = '@memberJsValues.Icon';
|
||||
</script>
|
||||
}
|
||||
|
||||
@functions
|
||||
{
|
||||
public class MemberJsValues
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Icon { get; set; }
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,5 +1,4 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
try {
|
||||
$("#twitter-search").load("@Url.Action("TwitterSearchResult", "TwitterSearch", new { numberOfResults = 6 })");
|
||||
@@ -15,4 +14,4 @@
|
||||
console.log("Couldn't load latest forum activity", errForum.message);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
@using System.Drawing
|
||||
@using System.Drawing
|
||||
@using OurUmbraco.Our
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
@inherits UmbracoViewPage<IPublishedContent>
|
||||
@{
|
||||
var home = Umbraco.TypedContentAtRoot().First();
|
||||
var notificationText = home.GetPropertyValue<string>("mainNotification");
|
||||
@@ -14,15 +14,15 @@
|
||||
|
||||
@Html.Action("RenderTerms", "TermsAndConditions")
|
||||
|
||||
@* We'll show it differently on the homepage *@
|
||||
@if (showNotification && Model.Content.Id != home.Id)
|
||||
@* We'll show it differently on the homepage *@
|
||||
@if (showNotification && Model.Id != home.Id)
|
||||
{
|
||||
<div class="alertbar__yellow">
|
||||
@Html.Raw(notificationText)
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Request.Cookies["dismissAvatar"] == null && CurrentPage.Id != home.Id && avatarImage != null && (avatarImage.Width < 400 || avatarImage.Height < 400))
|
||||
|
||||
@if (Request.Cookies["dismissAvatar"] == null && Model.Id != home.Id && avatarImage != null && (avatarImage.Width < 400 || avatarImage.Height < 400))
|
||||
{
|
||||
<div class="notification__blue avatarTooSmall">
|
||||
<div class="message text-center">
|
||||
@@ -1,4 +1,4 @@
|
||||
@using OurUmbraco.Our.Controllers
|
||||
@using OurUmbraco.Our.Controllers
|
||||
@using reCAPTCHA.MVC
|
||||
@inherits UmbracoViewPage<Umbraco.Web.Models.LoginModel>
|
||||
@{
|
||||
@@ -37,14 +37,14 @@
|
||||
|
||||
<input class="button green" type="submit" value="Log in">
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
.field-validation-error, .validation-summary-errors {
|
||||
color: red;
|
||||
}
|
||||
<style type="text/css">
|
||||
.field-validation-error, .validation-summary-errors {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.input-validation-error {
|
||||
border-color: red !important;
|
||||
}
|
||||
</style>
|
||||
.input-validation-error {
|
||||
border-color: red !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
+74
-41
@@ -1,29 +1,72 @@
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
@inherits UmbracoViewPage<IPublishedContent>
|
||||
@using System.Drawing
|
||||
@using OurUmbraco.Forum.Extensions
|
||||
@using OurUmbraco.Forum.Models
|
||||
@using OurUmbraco.Forum.Services
|
||||
@using OurUmbraco.Our
|
||||
@using Umbraco.Core.Cache
|
||||
@{
|
||||
var topicService = new TopicService(ApplicationContext.DatabaseContext);
|
||||
Image avatarImage = null;
|
||||
MemberData profile = null;
|
||||
if (Members.IsLoggedIn())
|
||||
{
|
||||
avatarImage = Utils.GetMemberAvatarImage(Members.GetCurrentMember());
|
||||
var userName = Members.CurrentUserName;
|
||||
|
||||
profile = ApplicationContext.ApplicationCache.RuntimeCache
|
||||
.GetCacheItem<MemberData>("MemberData" + userName,
|
||||
GetMemberData, TimeSpan.FromMinutes(5));
|
||||
}
|
||||
}
|
||||
|
||||
@functions
|
||||
{
|
||||
public class MemberData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string TwitterHandle { get; set; }
|
||||
public int Karma { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public IEnumerable<string> Roles { get; set; }
|
||||
public IEnumerable<ReadOnlyTopic> LatestTopics { get; set; }
|
||||
public int NumberOfForumPosts { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
public Image AvatarImage { get; set; }
|
||||
}
|
||||
|
||||
public MemberData GetMemberData()
|
||||
{
|
||||
var member = Members.GetCurrentMember();
|
||||
var avatarImage = Utils.GetMemberAvatarImage(member);
|
||||
|
||||
var roles = member.GetRoles();
|
||||
|
||||
var topicService = new TopicService(ApplicationContext.DatabaseContext);
|
||||
var latestTopics = topicService.GetLatestTopicsForMember(member.Id, maxCount: 100);
|
||||
|
||||
var memberData = new MemberData
|
||||
{
|
||||
Id = member.Id,
|
||||
Name = member.Name,
|
||||
AvatarImage = avatarImage,
|
||||
Roles = roles,
|
||||
LatestTopics = latestTopics,
|
||||
Avatar = Utils.GetMemberAvatar(member, 100),
|
||||
NumberOfForumPosts = member.ForumPosts(),
|
||||
Karma = member.Karma(),
|
||||
TwitterHandle = member.GetPropertyValue<string>("twitter").Replace("@", string.Empty),
|
||||
IsAdmin = member.IsAdmin()
|
||||
};
|
||||
|
||||
return memberData;
|
||||
}
|
||||
}
|
||||
|
||||
<div class="quick-menu">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
@if (Members.IsLoggedIn() && Members.GetCurrentMember() != null)
|
||||
@if (profile != null)
|
||||
{
|
||||
var member = Members.GetCurrentMember();
|
||||
|
||||
var roles = member.GetRoles();
|
||||
|
||||
var latestTopics = topicService.GetLatestTopicsForMember(member.Id, maxCount: 100);
|
||||
|
||||
<div class="close">
|
||||
<i class="icon-Delete"></i>Close
|
||||
</div>
|
||||
@@ -31,49 +74,47 @@
|
||||
<a href="/member/profile"><i class="icon-Settings"></i>Edit profile</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="user-image">
|
||||
@Html.Raw(Utils.GetMemberAvatar(member, 100))
|
||||
@Html.Raw(profile.Avatar)
|
||||
</div>
|
||||
|
||||
<div class="user-profile">
|
||||
<h2>@member.Name</h2>
|
||||
<div class="posts">
|
||||
|
||||
@member.ForumPosts()
|
||||
|
||||
@if (member.ForumPosts() == 0 || member.ForumPosts() > 1)
|
||||
<div class="user-profile">
|
||||
<h2>@profile.Name</h2>
|
||||
<div class="posts">
|
||||
|
||||
@profile.NumberOfForumPosts
|
||||
|
||||
@if (profile.NumberOfForumPosts == 0 || profile.NumberOfForumPosts > 1)
|
||||
{
|
||||
<text>Posts</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>Post</text>
|
||||
}
|
||||
<text>Post</text>
|
||||
}
|
||||
</div>
|
||||
<div class="karma">
|
||||
@member.Karma()
|
||||
@profile.Karma
|
||||
</div>
|
||||
@if (member.HasValue("twitter"))
|
||||
@if (string.IsNullOrWhiteSpace(profile.TwitterHandle) == false)
|
||||
{
|
||||
var twitterHandle = member.GetPropertyValue<string>("twitter").Replace("@", string.Empty);
|
||||
<div class="user-twitter">
|
||||
<a href="https://twitter.com/@twitterHandle">@<span>@twitterHandle</span></a>
|
||||
<a href="https://twitter.com/@profile.TwitterHandle">@<span>@profile.TwitterHandle</span></a>
|
||||
</div>
|
||||
}
|
||||
@if (roles.Any())
|
||||
@if (profile.Roles.Any())
|
||||
{
|
||||
<span class="roles">
|
||||
@foreach (var role in roles)
|
||||
@foreach (var role in profile.Roles)
|
||||
{
|
||||
<span class="@role">@role</span>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
<div class="public-profile">
|
||||
<a href="/member/@member.Id">View my public profile</a>
|
||||
<a href="/member/@profile.Id">View my public profile</a>
|
||||
</div>
|
||||
@if (member.IsAdmin())
|
||||
@if (profile.IsAdmin)
|
||||
{
|
||||
<div class="public-profile">
|
||||
<a href="/antispam">Check the spam queue</a>
|
||||
@@ -84,14 +125,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
if (avatarImage != null && (avatarImage.Width < 400 || avatarImage.Height < 400))
|
||||
if (profile.AvatarImage != null && (profile.AvatarImage.Width < 400 || profile.AvatarImage.Height < 400))
|
||||
{
|
||||
|
||||
<div class="user-notifications">
|
||||
<small>
|
||||
Your Notifications
|
||||
</small>
|
||||
|
||||
<a href="/member/profile" class="user-notification__green">
|
||||
<div class="user-notification-text">
|
||||
<p>Your profile picture is a little on the small side, It would look <strong>much nicer</strong> if you could update it to be larger image.</p>
|
||||
@@ -101,12 +140,10 @@
|
||||
}
|
||||
|
||||
<div class="user-latest-posts">
|
||||
|
||||
<small>
|
||||
Activity in threads you participated in
|
||||
</small>
|
||||
|
||||
@foreach (var topic in latestTopics)
|
||||
@foreach (var topic in profile.LatestTopics)
|
||||
{
|
||||
var forum = Umbraco.TypedContent(topic.ParentId);
|
||||
// if forum == null then it's been hidden/unpublished (example: v5 forum)
|
||||
@@ -128,20 +165,16 @@
|
||||
@topic.Updated.ConvertToRelativeTime()
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="category frontend"><span class="cat">@forum.Name</span></div>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="/member/login">Sign in</a> <a href="/member/Signup">Register</a>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+9
-10
@@ -1,22 +1,21 @@
|
||||
@using System.Collections.Specialized
|
||||
@using System.Drawing
|
||||
@using System.Drawing
|
||||
@using OurUmbraco.Our
|
||||
@inherits Umbraco.Web.Macros.PartialViewMacroPage
|
||||
@inherits UmbracoViewPage<IPublishedContent>
|
||||
|
||||
@{
|
||||
@* Get the root of the website *@
|
||||
var root = CurrentPage.AncestorOrSelf(1);
|
||||
Image avatarImage = null;
|
||||
if (Members.IsLoggedIn())
|
||||
{
|
||||
avatarImage = Utils.GetMemberAvatarImage(Members.GetCurrentMember());
|
||||
}
|
||||
var root = Model.AncestorOrSelf(1);
|
||||
Image avatarImage = null;
|
||||
if (Members.IsLoggedIn())
|
||||
{
|
||||
avatarImage = Utils.GetMemberAvatarImage(Members.GetCurrentMember());
|
||||
}
|
||||
}
|
||||
|
||||
<ul>
|
||||
@foreach (var page in root.Children.Where("Visible"))
|
||||
{
|
||||
<li class="@(page.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
|
||||
<li class="@(page.IsAncestorOrSelf(Model) ? "current" : null)">
|
||||
<a href="@page.Url">@page.Name</a>
|
||||
</li>
|
||||
}
|
||||
Reference in New Issue
Block a user