Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Trumf 78 posts 160 karma points
    Apr 02, 2013 @ 18:07
    Rasmus Trumf
    0

    Thoughts and ideas when implementing a uBlogsy blog

     

    I have just begun using this package and so far I like it very much. It has saved med a lot of work and I appreciate that a lot :)

    I have had some issues a long the way, and I would like to share them with the rest of you friendly people. I'm not saying theres anything wrong with ublogsy. This is just what fits my needs. I heard somewhere about a hotfix and some or all of my mentions may allready have beed adressed. I'm writing this as I get to the issues so it might seem mixed up and in no particular order but here i comes.

    A client of mine needed several blogsites with different domains, so I started to look for a blog module and fell over ublogsy. I made a new project in VS2012. An empty MVC4 application. Installed Umbraco V6.0.3 (and jQuery) via Nuget. Created a database and set up the site. Installed ublogsy from backoffice dev section. Backoffice worked fine but I had an error on the site. Same error as described here

    Resharper helped me by changing UmbracoTemplatePage to Umbraco.Web.Mvc.UmbracoTemplatePage and inserting "using Umbraco.Web" and using uBlogsy.BusinessLogic and a few other usings to a lot of the cshtml files and changed landing.url() to landing.url in some places (not all) and after that it worked. (don't know it it really works as it should since this is my first ublogsy site but I have it running)

    I like to use the convention over configuration so I keep images and css in the "Content" folder in the root. Same as Microsoft does if you create a new MVC4 project in VS2012. I know that Umbraco does not do this but since this is a pure MVC module I think it should too and so should Umbraco for that matter, but this is just me. No need to argue about that.

    To the _uBlogsyBaseBlog.cshtml I added <link type="text/css" rel="stylesheet" href="/Content/Css/site.css"> I omitted the media part because i try to make my code visible on all devices. I removed the addthis reference because I hate that they shall track all my users. I also referenced the jQuery files directly.

    Instead of the addthis reference I rewritten in the uBlogsyGlobalSeoMeta.cshtml the following:

    <code>

        // get seo description, use body when no description

        var desc = Model.Content.GetValueFirstOf(new[] { "uBlogsySeoDescription", "uBlogsyContentBody" });

        // get seo keywords, use title when no keywords

        var keywords = Model.Content.GetValueFirstOf(new[] { "uBlogsySeoKeywords", "uBlogsyContentTitle" });

        // get root of site, or landing - change uBlogsySiteRoot to your root alias, otherwise uBlogsyLanding will be used

        var root = DataService.Instance.GetSiteRoot(Model.Content, "uBlogsySiteRoot") ?? DataService.Instance.GetLanding(Model.Content);

        var landing = DataService.Instance.GetSiteRoot(Model.Content, "uBlogsySiteRoot") ?? DataService.Instance.GetLanding(Model.Content);

        var url = new Uri(Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Path);

        var description = uBlogsy.Common.Extensions.StringExtensions.StripHtml(desc).GetSummary(150).Trim();

        // get title of page

        var title = root.GetPropertyValue("uBlogsyContentTitle"); @*change uBlogsyContentTitle to your title alias (if required)*@

        if (Model.Content.Id != root.Id)
    {
    title = CurrentPage.uBlogsyContentTitle + " - " + title;
    }
    <title>@Html.Raw(title)</title>
    <meta name="keywords" content="@keywords.StripNonAphaNumeric().Trim()" />
    <meta name="description" content="@description" />
    <link rel="canonical" href="@Html.Raw(url)"/>
    <link rel="shortcut icon" href="/Content/images/favicon.png" />

    if (Umbraco.Field("facebookAppID", recursive: true).ToString() != String.Empty)
    {
    <meta property="og:type" content="website" />
    <meta property="og:description" content="@description" />
    <meta property="og:url" content="@Html.Raw(url)" />
    <meta property="og:title" content="@Html.Raw(title)" />
    <meta property="fb:app_id" content="@Umbraco.Field("facebookAppID", recursive: true)" />
    <meta property="og:image" content="@landing.Url/Content/Images/facebook_logo.jpg" />
    <meta property="og:site_name" content="@landing.GetPropertyValue("uBlogsyContentTitle")" />
    <meta property="fb:admins" content="@Umbraco.Field("facebookAdmins", recursive: true)" />
    }
    </code>

    I use Html.Raw on url because in Denmark it is possible to have danish letters in URL's

    I have added a few global parameteres to the document type "[uBlogsy] [Base] Page/SEO tab": facebookAppID, facebookAdmins, googleAnalyticsID

    For the OG tags i changed the html tag to <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml" lang="da" xml:lang="da-DK" class="no-js">

    And to the uBlogsyGlobalFooter.cshtml I added right after the footer part (this might be in a seperat file):

    <code>
    {
    if (Umbraco.Field("facebookAppID", recursive: true).ToString() != String.Empty)
    {
    <div id="fb-root"></div>
    <script>(function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/da_DK/all.js#xfbml=1&[email protected]("facebookAppID", recursive: true)";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    }

    if (Umbraco.Field("googleAnalyticsID", recursive: true).ToString() != String.Empty)
    {
    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '@Umbraco.Field("googleAnalyticsID", recursive: true)']);
    _gaq.push(['_trackPageview']);
    (function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
    </script>
    }}
    </code>

    This way you have Google Analytics on alle pages and you can easily add Facebook like buttons to content pages. Test your Facebook OG tags here https://developers.facebook.com/tools/debug

    You might want to change the da_DK part to en_US for english sites...

    To the _uBlogsyBaseBlog.cshtml I also removed @Html.Partial("uBlogsy/Global/uBlogsyGlobalBrowserTitle") because <title> is allready rendered in uBlogsyGlobalSeoMeta.cshtml.

    I alterede the title part: title += " : " + CurrentPage.uBlogsyContentTitle; to title = CurrentPage.uBlogsyContentTitle + " - " + title; beacuse from a SEO perspective it is better to have the page specific before the site specific.

    uBlogsyGlobalFooter.cshtml is referenced both in _uBlogsyBaseBlog.cshtml and uBlogsyGlobalFooter.cshtml so I removed it from _uBlogsyBaseBlog.cshtml.

    In section uBlogsyHead in uBlogsySiteHome.cshtml, uBlogsyPage.cshtml and _uBlogsyBaseBlog.cshtml I referenced a partial that I created in Global (uBlogsy/Global/uBlogsyGlobalScriptHeader) because it is the same code and added a reference to Html.Partial("uBlogsy/Global/uBlogsyGlobalSeoMeta") and so contentpages and blog use the same CSS and SEO meta.

    In the menu/navigation I added if (Request.Url.AbsolutePath == node.Url() || ((Model.Content.AncestorOrSelf(2) != null) ? Model.Content.AncestorOrSelf(2).Id : 0) == node.Id) to check if a blogpost is currentpage to get toplevel blog selected.

    Changed some dates, so all will be in same format.

    Included date to post time even though it is rendered at the top.

    Added target="_blank" to commenters websites.

    Made comments count to render "No comments, be the first to comment" "1 comment" or "x comments" after the blog post.

    Search dosent seem to work on duplicate sites, since it searches in the original blog!

    Original blog: www.teaterlinje.dk

    Dublicate blog: www.musiklinje.dk

     

    Im happy about the result, so thanks to Anthony for alle the good work :)

     

  • Rasmus Trumf 78 posts 160 karma points
    Apr 02, 2013 @ 20:33
    Rasmus Trumf
    0

    I guess that search dosen't work because it is a multi site and that uBlogsyWidgetSearch is a CachedPartial so when you navigate between sites, the search url is cached from the first site to the next.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 02, 2013 @ 21:10
    Anthony Dang
    0

    Thanks for all the info Rasmus

    I'm not sure why you needed to insert using statements. It should all work out of the box. Do you have any theories?

     

    Regarding your search issue... go to  _uBlogsyBaseBlog.cshtml and to this line:

    @Html.CachedPartial("uBlogsy/Widgets/uBlogsyWidgetSearch", Model, 600)

    Replace 600 with 0, restart your app, and see if that fixes your issue... then set it back to say 60, restart the app and see if the issue appears after a couple times.

     

  • Rasmus Trumf 78 posts 160 karma points
    Apr 03, 2013 @ 17:08
    Rasmus Trumf
    0

    Hi Anthony

    I don't know why I needed the using statements. It might be because I havent compiled properly or something...

    As for the search issue, it went away after I set it to 0. Maybe this caching should be removed everywhere when used as a multi domain site.

    I left a link at the bottom of the production sites linking to your blog. Would you prefer the link to point to somewhere else. Maybe the uBlogsy download page in the Umbraco forum ?

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 03, 2013 @ 17:36
    Anthony Dang
    0

    Good catch with the search box cache.

    You can do anything with the footer link. I don't mind really. Preferably leave it in cos I might get more hits on my blog :) 

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 03, 2013 @ 17:38
    Anthony Dang
    0

    ps. do you have the same issue with rss?

     

  • Rasmus Trumf 78 posts 160 karma points
    Apr 03, 2013 @ 19:16
    Rasmus Trumf
    0

    I removed the RSS part because there was no need for it. I will make a blogsite for my self in a while and will let you know then. I dont think so though, because I will remove the cache, because it is low traffic sites, that will have little or no effect of caching.

    Thanks for all your hard work :)

  • Will Price 12 posts 94 karma points
    Apr 09, 2013 @ 03:10
    Will Price
    0

    I believe the OP issue with "UmbracoTemplatePage" errors was from creating the initial project in Visual Studio as an MVC 4.0 application. I did the same thing and got the same problem.

    Creating the Project in Visual Studio as a standard "ASP.NET Web Forms Application" and installing Umbraco via NuGet in that should avoid the problem. (Then still edit umbracoSettings.config to set Umbraco for Mvc mode.)

    Cheers,

    \ / \ / i L L

  • Rasmus Trumf 78 posts 160 karma points
    Apr 09, 2013 @ 17:36
    Rasmus Trumf
    0

    Hi Will

    I actually read about this but forgot so I think u are right. But since uBlogsy is an MVC app I think my solution is better. I prefer MVC to Web Forms ;-)

  • Rasmus Trumf 78 posts 160 karma points
    Apr 15, 2013 @ 20:20
    Rasmus Trumf
    0

    @Anthony

    I have found a few other things you can have in mind for the next update:

    1: When creating a new blogpost from the content frontpage. It would be nice to have a field for the headline/navigation title. It took me a while to realize that the default title was inserted to the navigation title also, wich is what is seen in the archive section.

    2: When using danish letters æ, ø, å the latter (å) is not translated to aa as it should in the URL for the page.

    Rasmus 

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    May 08, 2013 @ 11:38
    Anthony Dang
    0

    Hey Rasmus

    That's a good idea about the blog title.

    I'm not sure about the Danish letters. Could you give more information about what you're trying to do? I wish I spoke another language... I probably would have come up with your issue by now :)

     

     

Please Sign in or register to post replies

Write your reply to:

Draft