Posted by admin under General  sBlog.Net  Customizations  sBlog.Net v3.0  on Jul 18 2014

It's been forever since I blogged anything about sBlog.Net! That's obviously because I didn't have the time to do a lot for this project! But here I am with an interesting feature! Now you have the ability to enable something I call as "social features". This can be done from the web.config. There is a new section called sblognetSettings. Within this section there is an element called socialFeatures. Here it is!


<sblognetSettings enableMiniProfiler="true">
    <socialFeatures enabled="false" twitterId="" githubId="" facebookId="" pinterestId=""
                                   dropboxId="" flickrId="" instagramId="" linkedinId=""
                                   soundcloudId="" spotifyId="" tumblrId="" />
</sblognetSettings>

To use this, you just have to set the enabled property to "true". After that, you just have to enter your user ids in the corresponding properties like twitterId, githubId etc etc. That's it! You are all set!! Here is a screenshot of how it looks like using the Perfect Blemish theme:



 

If you mouse over one of the icons, it pops out as shown below and on clicking in an icon, the inevitable happen! - the corresponding page is opened in a new page! Hope you like this new feature! Have fun and happy coding!


Posted by admin under General  sBlog.Net v3.0  Bootswatch  on Jan 11 2014

Hello,

I have published 3 themes using bootswatch to github! Check them out, If you are not famililar with bootswatch, they are a set of themes using the bootstrap styles as the base! You can check them out here

As a sidenote, while trying these new themes, make sure you have the latest binaries for sBlog.Net (just copying the theme files with v2.0 won't work). Also, if you notice that the styles are messed up, you may have to restart the application pool, since the cutsom view engine of sBlog.Net may still be using the old theme. I am thinking about a much better way to deal with this. My previous post discusses about the custom view engines of sBlog.Net. But, for now, have fun with the new themes!!!

PS: This blog currently uses the Amelia theme!

Posted by admin under General  sBlog.Net v3.0  on Dec 01 2013

In this post, I would like to discuss the most recent check-in for sBlog.Net. With the latest update you will be able to create theme specific partial views and thus you are not limited by the partial views provided by the blog engine. For example, you could create a partial view that override's the way a post pager for the blog is displayed [used for navigating between posts]. For this to happen, a Shared folder has to be created within the theme's folder and then a partial view that correspond to the name (in this case PostPager.cshtml) of the partial view being overridden. This is possible because of a few changes to the SetupViewEngines method in the Application_Start event. It's given below:

   private void SetupViewEngines()
   {
       var settings = InstanceFactory.CreateSettingsInstance();
       ViewEngines.Engines.Clear();
       ViewEngines.Engines.Add(new CustomRazorViewEngine(settings.BlogTheme));
   }

Note how an instance of CustomRazorViewEngine is passed to the ViewEngines.Engines.Add. CustomRazorViewEngine is a class that overrides RazorViewEngine. The main function of this class is to set the locations to be searched for finding a view, partial view or a master. Here is the complete listing:

    public class CustomRazorViewEngine : RazorViewEngine
    {
        public CustomRazorViewEngine(string blogTheme)
        {
            base.AreaViewLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/{1}/{0}.vbhtml", "~/Areas/{2}/Views/Shared/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.vbhtml" };
            base.AreaMasterLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/{1}/{0}.vbhtml", "~/Areas/{2}/Views/Shared/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.vbhtml" };
            base.AreaPartialViewLocationFormats = new[] { "~/Areas/{2}/Views/{1}/{0}.cshtml", "~/Areas/{2}/Views/{1}/{0}.vbhtml", "~/Areas/{2}/Views/Shared/{0}.cshtml", "~/Areas/{2}/Views/Shared/{0}.vbhtml" };
            base.ViewLocationFormats = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/{1}/{0}.vbhtml", "~/Views/Shared/{0}.cshtml", "~/Views/Shared/{0}.vbhtml" };
            base.MasterLocationFormats = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/{1}/{0}.vbhtml", "~/Views/Shared/{0}.cshtml", "~/Views/Shared/{0}.vbhtml" };
            base.PartialViewLocationFormats = GetPartialViewLocations(blogTheme);
            base.FileExtensions = new[] { "cshtml", "vbhtml" };
        }

        private static string[] GetPartialViewLocations(string blogTheme)
        {
            var locations = new List<string>();

            if (HasSharedPartialViews(blogTheme))
            {
                var csPath = "~/Themes/" + blogTheme + "/Shared/{0}.cshtml";
                var vbPath = "~/Themes/" + blogTheme + "/Shared/{0}.vbhtml";
                locations.Add(csPath);
                locations.Add(vbPath);
            }

            locations.Add("~/Views/{1}/{0}.cshtml");
            locations.Add("~/Views/{1}/{0}.vbhtml");
            locations.Add("~/Views/Shared/{0}.cshtml");
            locations.Add("~/Views/Shared/{0}.vbhtml");

            return locations.ToArray();
        }

        private static bool HasSharedPartialViews(string blogTheme)
        {
            if (string.IsNullOrEmpty(blogTheme))
                return false;

            var pathMapper = DependencyResolver.Current.GetService<IPathMapper>();
            var directoryRelativePath = string.Format("~/Themes/{0}/Shared", blogTheme);
            var directoryPath = pathMapper.MapPath(directoryRelativePath);
            return Directory.Exists(directoryPath);
        }
    }

The constructor takes care of setting the locations. The thing to note in the constructor is the call to GetPartialViewLocations. This method is used to "find" out if the current theme contains a Shared folder. If so, it's added as the first entry to the list. It has to be the first entry since that's the order used for searching by the MVC framework. Thus, using this approach, a partial view residing within the appropriate theme folder gets the priority over the one in the common shared views folder. Hope you enjoyed this short post! Happy coding!

Posted by admin under General  sBlog.Net  Customizations  sBlog.Net v2.0  on Dec 01 2013

I have published yet another theme based on bootstrap! You can get it here! A demo helps always right? Visit the blog, it now uses the theme I just published! If you need some help on installing / using this theme, refer to this post!

Tagged sblog.net 
Posted by admin under General  sBlog.Net  Customizations  sBlog.Net v2.0  on Sep 07 2013

Hello people! 

I have published a new theme using bootstrap. It was in my to-do list for a long time and I am happy I got to this atlast! You can download this here! If you want to look at a sample, you are already seeing it!

To use this theme, download the zip file. Right click on the zip file, choose "Extract Here" [WinRAR] (If you choose "Extract to Folder.." the following may not apply. Once you extract the file, you will see the following folder structure:

                GoBootstrapDark
                                |
                                |
                                ----- css
                               |
                               ------ js
                               |
                               ------ img
                               | 
                               ------ _Layout.cshtml
                               | 
                               ----- _LayoutPage.cshmtl

With Themes folder in your web application, the same structure should be recreated (as shown below).

                Themes
                |
                ---- GoBootstrapDark
                                |
                                |
                                ----- css
                               |
                               ------ js
                               |
                               ------ img
                               | 
                               ------ _Layout.cshtml
                               | 
                               ----- _LayoutPage.cshmtl

That's it! Now, if you logon to the admin section,  go to the settings page, you will now see the new theme in the dropdown, select, update the settings, that's it! You are all set to rock on!!!

Tagged sblog.net  theming 

<< Previous Page