Copied to clipboard

Flag this post as spam?

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


  • JotaBe 6 posts 27 karma points
    Feb 23, 2013 @ 22:49
    JotaBe
    0

    uBlogsy/uBlogsyRSS.cshtml fails to render RSS in Umbraco 6.0 + solution

    Ublogy fails to render the <link> tag inside uBlogsy/uBlogsyRSS.cshtml. Depending of the browser it may look as if the browser can't read it, but the problem is the rendering.

    You can read a thorough explaination of this problema and how to solve it here:

    http://stackoverflow.com/questions/12761288/asp-net-rss-feed-error-in-link-tag-in-item-node-issue-with-razor-in-umbraco-rss

    Hope this helps!

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Feb 24, 2013 @ 15:34
    Anthony Dang
    0

    It's a breaking change in razor in mvc 4

    The following should work. Just replace the whole file.

     

    @using System.Text
    @using uBlogsy.BusinessLogic
    @using uBlogsy.Common.Extensions
    @using uHelpsy.Extensions
    @inherits UmbracoTemplatePage
    @{
        Layout = null;
    
        // get tag, label, or author from query string
        var tag = Request.QueryString["tag"];
        var label = Request.QueryString["label"];
        var author = Request.QueryString["author"];
        var searchTerm = Request.QueryString["search"];
        var commenter = Request.QueryString["commenter"];
        int page = int.TryParse(Request.QueryString["page"], out page) ? page : 1;
        var year = Request.QueryString["year"];
        var month = Request.QueryString["month"];
        var day = Request.QueryString["day"];
        int postCount;
    
        var posts = PostService.Instance.GetPosts(Model.Content, tag, label, author, searchTerm, commenter, year, month, day, out postCount);
    
        var lastPubDate = !posts.Any() ? DateTime.Now : DateTime.Parse(posts.First().GetValue("uBlogsyPostDate"));
    
        var qs = Request.QueryString.ToString().Replace("+", "%20");
    
        // get blog url
        string blogUrl = Request.Url.AbsoluteUri
                                .Replace(CurrentPage.Url(), string.Empty)
                                .TrimEnd("/".ToCharArray());
    
        if (!string.IsNullOrWhiteSpace(qs))
        {
            blogUrl = blogUrl.Replace(qs, string.Empty).Replace("?", string.Empty);
        }
    
        Response.Clear();
        Response.ContentType = "text/xml";
        Response.ContentEncoding = Encoding.UTF8;
        @Html.Raw("")
    
    
                @(Model.Content.GetPropertyValue("uBlogsyRssTitle"))
                @(Model.Content.GetPropertyValue("uBlogsyRssDescription"))
                @(Model.Content.GetPropertyValue("uBlogsyRssCopyright"))
                @*@Model.Content.uBlogsyRssImage*@
                @Html.Raw(string.Format("{0}", blogUrl))
                @(lastPubDate.ToString("ddd, dd MMMM yyyy HH:mm:ss"))
                @(lastPubDate.ToString("ddd, dd MMMM yyyy HH:mm:ss"))
                @ListPosts(blogUrl, posts)
    
    
    }
    
    
    @helper ListPosts(string blogUrl, IEnumerable posts)
    {
        foreach (var p in posts)
        {
    
                @p.GetValue("uBlogsyContentTitle")
                @p.GetValue("uBlogsyPostAuthor")
                @(blogUrl + p.Url())
                @(uBlogsy.Common.Extensions.StringExtensions.StripHtml(p.GetValue("uBlogsyContentBody")).Trim())
                @Html.Raw(string.Format("{0}{1}", blogUrl, p.Url()))
                @(blogUrl + p.Url())
                @(p.GetValue("uBlogsyPostDate").FormatDateTime("ddd, dd MMMM yyyy HH:mm:ss")) 
    
        }
    }
    
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Feb 24, 2013 @ 19:29
    Anthony Dang
    0

    btw.... i'm about to release beta 2 which has a big bug fix, but is also quite a big refactor.... in other words, it may be a pain to upgrade...better off packacking what ever content you did.

    Also did changes in the css.

     

  • Stephen Dougherty 23 posts 45 karma points
    Feb 24, 2013 @ 22:11
    Stephen Dougherty
    0

    I am currently still using uBlogsy 2.0.0.1. I made quite a few changes to the razor etc and thus haven't kept up to date. I have been following closely your work and upgraded my site to 6.0. I plan to upgrade my site to the new version of uBlogsy. I was just wondering for existing content will uBlogsy 3.0 be backward compatible? You say in the previous post about packaging content. Excuse my limited knowledge but can you advise on how best to do this.

    Well done with all the hard work on the new version of uBlogsy. I was wondering what your thoughts are on a mobile version of uBlogsy. I am currently using the MVC 4 mobile features to create a responsive site. With the changes of 6.0 it is still being developed with some links not working as expected. My site is http://www.monkstowncommunityschool.org and like I said will continue to be developed.

  • JotaBe 6 posts 27 karma points
    Feb 25, 2013 @ 01:29
    JotaBe
    0

    I'm soory, Anthony. For some reason a response I added to stackoverflow question is missing, but you can find it now in the link of my first comment.

    Basically, the breaking change in razor 4 is that it checks the HTML you're trying to write is correct, and stops parsing if it finds something illegal.

    A <link> tag is required to be a singleton tag, or, in other words, it must be self-closing (), or it cannot have an open and close tag with contents in the middle.Thats's why your original Razor script fails. (This is the link tag for referencing external .css files!).

    The solution is to deceive Razor so that it doesn't know it is writing a link tag. The way to do it is opening and closing the tag using @Html.Raw("<link>") and @HtmlRaw("</link>") so you can use your original script making this little change,

     

    <link>@[email protected]</link>
    @Html.Raw("<link>")@[email protected]@Html.Raw("</link>")

    (I think this is much more clear than the solution posted here!) . Hope this helps!

     

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Feb 25, 2013 @ 02:06
    Anthony Dang
    0

    Curses, it looks like the umbraco forum stripped all the tags out of my pasted code.

    Thanks JotaBe. That's basically what I tried to paste here. I put the Html.Raw() around the entire line though. But it's basically the same.

    Btw, beta 2 is online.

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

    Steven I think it should be ok to just replace all the files. There may be some crashes here and there but try the same old solutions like republishing.

    Basically I've changed the css, most of the cshtml files, and changed the starter kit content tree. But it's sort of what you'd be using it for anyway.

    Regarding mobile... I prefer to stay away from "mobile versions"

    I think making things responsive it the best solution. Just need to find the time to write some media queries, and of course test it on a jillion devices. I havent used mvc4 mobile... any good?

     

  • JotaBe 6 posts 27 karma points
    Feb 25, 2013 @ 02:12
    JotaBe
    0

    That's why I couldn't understand that code, so it wasn't clear at all :)

    That "@Html.Raw(string.Format("{0}"... looked too strange :)

    There's a problem with Umbraco Forum: when you post a comment for the first time, it accepts the tags starting with <. But if you edit your comment, all tags starting with < get lost! I discovered it right now, editing my new comment. Perhaps you can try editing it and posting the code again, or simply add a reference to another place where the source code can be donwloaded.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Feb 25, 2013 @ 02:16
    Anthony Dang
    0

    Editing comments generally ends up with an xslt error for me... oh well.

    Thanks for the bug report. Strange that chrome didnt complain about it.

     

  • Stephen Dougherty 23 posts 45 karma points
    Feb 25, 2013 @ 10:02
    Stephen Dougherty
    0

    MVC 4 is good from the point of view that it will automatically apply a mobile template if I create a file with .mobile in the file name.

    i.e

             uBlogsyLanding.cshtml

             if I create

             uBlogsyLanding.mobile.cshtml

    this template will be applied.

    I use a combination of this and responsive design to create the mobile element of my site.

     

     

Please Sign in or register to post replies

Write your reply to:

Draft