Mark Everard

Hello, I'm Mark – a PhD physicist turned technologist / architect.

Archive for the ‘C#’ Category

ImageDataExtensions for Episerver 10

without comments

Thanks to Luc Gosso embracing the true meaning of open source software and  ‘community’ (you give back at least as much as you take, in case you’re wondering) there is now  a version of my ImageDataExtensions package compatible with Episerver CMS 10.

Why the long wait?

She's already schooling me at JavaScript....

Ignoring another small package that has entirely changed how I spend my spare time, the reason is that the ImageDataExtensions package relies on a unsupported Episerver API to deliver its core resizing functionality, and I wasn’t sure what approach to take.

As part of Episerver’s quality approach they have been reducing their surface API, that is the number of methods that are available to developers to integrate and interact with the platform. This makes entire sense as they can focus their efforts on in-depth testing and validation of key features without worrying about methods that us eager developers have reflected out and used for more than their original intention.

The ThumbnailManager class that provides the resizing capability has been marked as an internal API (and moved to the Episerver.Internal namespace). Although still available to develop against, Episerver provide no promises around its operation or signature , i.e a. change to this method /API wouldn’t be considered a breaking change to the platform (though it would be for this package).

The point to remember is “if you are using  this package / or you intend to, please be aware that this means your functionality could break with any Episerver release and make sure you are comfortable with how you will deal with that”.

What next?

Luc’s contribution got me thinking about how best to provide a way out for those of you that want to safely use and rely on this functionality.

I’ve now abstracted the resizing functionality into its own interface and made it pluggable through the IOC container, enabling you to provide your own resizing implementation (thus no longer depending on the Episerver Internal ThumbnailManager class)

I’ve also created a package that uses everyone’s favourite Asp.net Image resizing module (ImageResizer). There is already an Episerver integration allowing true dynamic image resizing of any image. The new add-on delegates the image resizing on upload to ImageResizer rather than the ThumbnailManager.

I’ve dropped this into another package Chief2moro.ImageDataExtensions.ImageResizer in case you’re interested.

Is now the right time to say that I think Image scaling and resizing should absolutely be part of the core platform. I rarely come across a project that doesn’t have that need 😉

Written by mark

March 16th, 2017 at 3:12 pm

Posted in C#,EPiServer

Publish all the things!

with 5 comments

If you’ve seen some of my recent posts you’ll know I’ve been playing around with WebHooks. These are simple HTTP requests to endpoints allowing services to exchange data and events.

Integration Platforms as a Service

Those of you cool kids will have known about IFTTT (If This Then That) for some time. It’s a online tool that acts as a way to glue a huuuge number of online services together into simple workflow pairs called ‘recipes’. Each service can provide a number of triggers to the platform, which are then linked to actions provided by other services.

I’ve got a number of personal recipes set up, some useful some not. but all of them are good fun!

  • If somebody tags me in a picture on Facebook, then upload the picture to my OneDrive account
  • If one of my team creates a new GitHub repository then email me
  • If I arrive or leave my office then log the time in a Google Doc.
  • If an astronaut is launched into space then send me a notification

Whilst IFTTT targets individual users, other iPaaS platforms focus more towards business and enterprise. These will become increasingly useful and popular as a cheap means of system integration and data exchange. For example – if somebody submits a payment via the organisation’s payment gateway, log the entry directly into the cloud-based finance system. You won’t need development teams to set these up, just someone to configure the data exchange / webhook endpoints.

Publish your home!

I’ve been playing around with smart home devices (tado smart heating and WeMo lights and switches). I wanted to experiment a little with the API’s they offered.

One of the channels IFTTT offer is called the Maker channel. This is a user specific channel that will accept http triggers to an endpoint and can also make requests to a specified endpoint. It allows you pass up to 4 data points from a trigger or to an action.

publish-lights-on

Publish…… and there was light, and slippers.

As I’ve demonstrated before, adding webhooks to an existing ASP.NET app is straightforward. I decided I’d hook an Episerver solution up to an IFTTT maker channel, meaning when I clicked the publish button I could make all manner of amazing things happen, like turning my lights on :)

The code to do this is straightforward (see below). I’m using an Episerver initialisation module to hook a handler for the Content Published event. I’ve also built a simple helper method to call the Maker channel API. To use this you’d just have to add in your own API key that you get when you configure the Maker channel on IFTTT.


Written by mark

March 7th, 2016 at 11:00 am

Posted in ASP.NET,C#,Code,EPiServer

How exactly do you need to manage your content?

without comments

Detailed content management requirements are often overlooked in the design and build of a content managed website. This can result in an implementation that lacks flexibility and incurs higher costs over its lifetime.

Dual purpose

Web Content Management (WCM/CMS) implementations deliver two key capabilities for an organisation:

  1. A website, perhaps with a new or updated design or brand.
  2. The ability to manage the website content via a content management system

To achieve the best implementation outcome, it is important start your project with design measures and KPI’s that focus on both the success of the website as a business tool, as well as the CMS that enables it. Too often the focus is on just the website, largely because of the difficulty in measuring how well your content management system works for your organisation.

Whether your CMS is effective is rarely immediately apparent, instead it will emerge over time through your content team’s ability to operate autonomously and a reduction in future development need and cost.

A CMS is for life, not just for launch

Even after a successful implementation, it is still easy to overlook your content management requirements. Marketing and campaign-led activity often have bespoke visual needs which can challenge your existing CMS design and content flexibility. They also often come with fixed deadlines and limited opportunity to fully assess the expected campaign content usage and lifespan.

The default position may be to ‘content manage all the things’, but do you really need to?

It is all to easy to build up technical debt within your implementation by designing bespoke types that are so specialised they offer little or no opportunity for reuse. This feature bloat not only increases the size of your code-base, making the landscape more complex for your technical teams. It also makes the system more complex for editorial teams as they have to navigate additional content types. If you have many content types in your CMS that are only used in a few places then you may already be suffering.

Don’t waste time (or money)

To keep on the right track, you should always have your content editing team as a key stakeholder in any website or CMS development. After all, they are the team that will be using any functionality and be responsible for publishing campaign content / functionality on your website through your CMS. It is only sensible that their feedback is taken onboard.

The basics of content reuse requirements aren’t that difficult.:

  1. I need to reuse this content and/or design in many places across the website
  2. I may reuse this content occasionally
  3. I am unlikely to reuse this content, but I need to be able to change it at short notice
  4. I shouldn’t need to change the content. If I do I am happy to rely on techincal support

The answers will drive very different technical solutions, ranging from fully reusable content managed features to a set of static pages to be thrown away after use. The middle ground here is also useful, which allows more technically minded CMS editors and admins to standup flat HTML pages through the CMS interface (an example for Episerver – http://tedgustaf.com/blog/2011/4/publishing-plain-html-pages-in-episerver/).

The difference in cost and implementation effort can be substantial.

Why spend money and valuable time building reusable content elements for a one-off campaign if you don’t really need to?

Written by mark

February 29th, 2016 at 11:00 am

Posted in C#,EPiServer,Opinion

RSS feeds for Episerver

without comments

I’ve released a few further tweaks to my RSS / ATOM add-on for EpiserverCHIEF2MORO.SyndicationFeeds.

Whats new in version 3.0?

On request filtering

I’ve taken another look at filtering, which is a feature included from version 2. I’ve modified the inbuilt IFeedContentFilterer to allow Feed pages to filter items by category via querystring parameters. This has caused a breaking change (and helped me understand how abstractions can help stable API design).

The feature allows editors to set up single feeds and for those feeds to provide subsets of data by responding to Category names that are passed via a comma separated querystring value. e.g. www.mysite.com/feed?categories=Alloy,Blog,Technology.

The default FeedFilterer has also been modified so that a content item has to be a member of all categories (both querystring and editor set) to appear. Previously it had to be a member of just one category filter.

Editor set cache

Each feed page now includes a new property allowing an editor to cache the feed output for a given number of seconds. This is to help performance for those feed pages on sites with a large amount of content.

Validation

I made some minor amends to help the feeds to validate, and made sure I correctly understood the RSS / ATOM specification in respect of LastUpdated and Publish dates

It’s on Nuget

The source code is available at https://github.com/markeverard/Chief2moro.SyndicationFeeds.

A package (currently v3.0.0.0) is available in the Episerver Nuget Feed – http://nuget.episerver.com/ – search for CHIEF2MORO.SyndicationFeeds

Written by mark

February 3rd, 2016 at 10:00 am

Posted in ASP.NET,C#,EPiServer

Using WebHooks in an EPiServer solution

without comments

WebHooks are a way of connecting internet / cloud services together. They allow websites to communicate with each other via HTTP callbacks. Services can subscribe (via HTTP) to receive notifications from publishers about a specific event. Publishers, manage these subscriptions and then on each event push notifcations via an HTTP Post to each receiver, at an endpoint defined during subscription.

web-hooks

ASP.NET WebHooks

Microsoft have recently released a WebHook framework for ASP.NET that gives you a pattern for:

  • Handling subscriptions from interested subscribers
  • Sending subscriptions to publishers
  • Sending published messages to subscribers
  • Handling publisher messages from subscribed services (via Receivers)

Along with the basic framework, they have also provided implementations for some very common services like Dropbox, GitHub, Instagram, PayPal, Pusher, Salesforce, Slack, Stripe, Trello, and WordPress

Webhooks in EPiServer

What would an EPiServer implementation / usage of WebHooks look like?

  • Publish content events to subscribers (system to system integration)
  • Publish Form data inputs to external systems
  • Publish / Subscribe to Catalog events and changes from integrated commerce systems (Stock control and pricing)
  • Subscribe to events from external systems (Payments)
  • Subscribe to external content events – Instagram / social

Ascend London

I was invited to talk (along with fellow EMVP Khurram Khan) at the technical track at EPiServer Ascend London 2015. You can download the slides from Slideshare.


As part of a presentation I put together a simple solution demonstrating an EPiServer site with an Instagram receiver that provided a solution to the below user story.

“As a content editor, I want images that are uploaded on a social channel (Instagram) and tagged with ‘ascend15’ to be available in my content management system so I can use them on my awesome website”

The solution contained the following elements:

  • A receiver accepting notifications from Instagram when a image with a tag of ‘ascend15’ was added (using the ASP.NET WebHook framework)
  • A Dynamic Data Store implementation to store the number of notifications received
  • A scheduled job: to request, download and import images into EPiServer as MediaData / IContent items

The solution and even the scenario was a little contrived, so I’m not going to show the code (though it you really want it just drop me a line). It did however work on the day, which when you’re trying a tech demo that relies on the cloud and external services and also your own code; is always nice :)

Written by mark

November 11th, 2015 at 10:49 am

Posted in ASP.NET,C#,EPiServer

Chief2moro.ImageDataExtensions now available for EPiServer 9

without comments

Another short, sharp blog post to note that a version of the CHIEF2MORO.ImageDataExtensions package which is compatible with EPiServer 9 is now available in the EPiServer Nuget Feed. Fellow EMVP Marija Jemuovic did all the hard work, and I got the easy part in blogging about it.

There not much more to say, so here is a space filler…..

7d25cb66b18e1a6fbada9f630e84e2db

 

 

Written by mark

October 27th, 2015 at 9:00 am

Posted in ASP.NET,C#,EPiServer

Enhanced RSS / ATOM Feeds for EPiServer

without comments

I’ve released a new version of CHIEF2MORO.SyndicationFeeds. Along with upgrading to EPiServer 9, I’ve also taken the opportunity to add a few additional features based on some feedback and my own real usage.

Advanced Filtering

The library now contains the IFeedContentFilterer interface which provides an extension for any custom filtering you may want to achieve (for example – removing items with empty description’s). The default implementation filters via the EPiServer FilterForVisitor filters (Published status, Access rights, Has a template), though ignores the HasTemplate rule for blocks, so they can still be exposed. It also filters on EPiServer categories and ContentType, both of which are selectable by an editor on an instance of the Feed PageType.

Changing each Item’s summary in the feed.

You can now provide your own implementation of IFeedDescriptionProvider which is an interface that describes how a content item’s feed summary / description is derived. This allows you to provide your own implementation of where the items summary is stored. This may for example be from a common page property across all content types, or may be specific to each content type. By default, each item has a summary like ‘An src link to content with id = {content.ContentLink.ID} and name = {content.Name}’. The IFeedDescriptionProvider extension replaces the previous SetItemDescription delegate way of overriding the summary / description. The delegate is still available to maintain backwards compatibility but is marked as obsolete.

It’s on Nuget

The source code is available at https://github.com/markeverard/Chief2moro.SyndicationFeeds. I am happy to receive feedback and pull requests though I need to make a formal and public apology to Thomas Svensen who did indeed send me a pull request, which I ignored like an extremely bad open source steward….. Sorry :(

A package (currently v2.0.0.0) is available in the EPiServer Nuget Feed – http://nuget.episerver.com/ – search for CHIEF2MORO.SyndicationFeeds

 

 

Written by mark

October 26th, 2015 at 9:00 am

Posted in ASP.NET,C#,EPiServer

Helping EPiServer editors Find unused content

with 2 comments

It might sound obvious, but content management is about more than just content creation and editing. It is also knowing when your content has reached the end of its useful lifespan. It means knowing when it’s time to ‘Move to Trash’, and when it’s time to ‘Move to Trash’ permanently!

I’ve seen as many content management systems ultimately fail due to poor on-going content control by editorial teams as I have through poor initial implementations by developers. There are many reasons that your content can grow out of control. When it does, your CMS becomes nothing more than a publishing platform and a quite inefficient one.

“I’m sure I’ve written an item like that before…”
“Yeah, it’s in here somewhere, I just can’t find it…”
“I don’t think that content is used but I’m not sure, so I didn’t archive or delete it, just in case…”

Tidying up after yourself whatever your discpline, is just good practise. Whether its content, a codebase or your email inbox. Being scared to delete is a sign that you aren’t in control.

One of the editors I work with on an EPiServer site wasn’t scared to delete content, but he was overawed by the effort needed to discover unneeded content.

This got me thinking. There must be a better and easier way than trawling through a hierarchical tree…

Content reporting using a slice

EPiServer recently reintroduced PowerSlice as a ‘supported’ add-on. PowerSlice uses EPiServer Find to give editors a view of content which goes beyond the traditional hierarchical structure. It allows developers to very easily ‘slice up’ content in any number of ways.

Whilst thinking about the best way to implement a feature for editors to report on unused content, it dawned on me that creating a slice for ‘unused content’ would be incredibly easy :)

  • PowerSlice already has a well-thought out user interface
  • PowerSlice allows editors to very quickly jump to managing content using the standard EPiServer interface / good for if you want to find and then delete content

I’ve put together two slices, to help editors find unreferenced blocks and media, using standard methods from the EPiServer IContentRepository interface.

Unused Blocks Slice

Unused Media Slice

These slices and PowerSlice were such a good solution that I’d argue that PowerSlice should be bundled out of the box with a Find install. It could perhaps form the basis of a new and more flexible content reporting function? Reporting is something that is in need of a little love in EPiServer 7/8.

Thoughts?

Written by mark

March 16th, 2015 at 10:00 am

Posted in C#,EPiServer

Configurable Content Feeds for EPiServer 7.5

with 2 comments

AKA – another (and better!) RSS/ATOM feed for EPiServer. Developing an RSS feed for an EPiServer CMS system is actually quite a simple task and there is already a good amount of information and community options that you can download and use.

However, the particular problem I was presented with required something a little more than what was already out there, so I took the opportunity to build a fuller solution based on CMS 7.5. This may be the last RSS feed module for EPiServer that you’ll ever need!

This effort started out with a requirement to integrate content from EPiServer CMS to an IBM WebSphere Commerce system (WCS). WCS contains out-of-the-box functionality to consume external content from a publishing feed presented in an ATOM format so this seemed like a suitable integration method.

The design of the pages and content area to be shared required that we shared only specifc HTML snippets from the CMS to the WCS system. This fitted in perfectly with the new Content Blocks in EPiServer 7; meaning we needed a content feed that could share not only pages but also content blocks. This additionally  meant that content blocks needed to be routed so the individual output could be consumed by the external WCS solution.

Also the new Media system in EPiServer 7.5 allows the content feeds to handle and output media items in a simpler way. Its all IContent man!

Editor functionality

  • Editors can create multiple feeds (a feed is a Page Type)
  • Feeds contain a date ordered (most recently published first) list of content items
  • Editors can specify whether a feed is delivered in RSS or ATOM format
  • Editors can specify how many items appear in the feed.
  • Editors have granular control over what content items are shared. They can include any of the following in a single feed.
    1. Descendents of a specified page in the page tree
    2. Child blocks contained within a specified content folder
    3. Child media items within a specified media folder
    4. Any number of individually selected pages, blocks or media items, via a ContentArea property
  • Blocks included in a feed are externally routed so their HTML output can be consumed by external systems.
  • Feed pages have a partial renderer meaning they can be dragged into Content Areas to display an RSS feed logo and link.

 

event-feed

Extending and modifying

There isn’t much to do as a developer beyond installing the package. Note. I’ve only tested this against an MVC Alloy solution. It should play nicely with WebForms but I’ve not tested!

  • You may want to change the partial renderer view for a Feed Page. This can be found in /modules/Chief2moro.SyndicationFeeds/Views/Partial.cshtml

event-feed-partial

  • You can override the description that is shown along with each item in the feed by providing a method for the SetItemDescription delegate. By default this is of the form ‘An src link to content with id = {content.ContentLink.ID} and name = {content.Name}’

Other integration considerations

There is one item not included in the solution which you may need to consider . Whilst the feed presents absolute urls from the feed to pages, blocks and media.  Any content within a page or block that contains editor set hyperlinks, such as an XHtml property will most likely contain relative urls. If these are consumed and presented on an external website you’ll get a serious case of the 404’s.

You can get around this by rewriting any outbound urls in the content to be absolute. The solution I used was to set up a rule in my favourite tool IIS UrlRewrite. This intecepted all outbound html from a particular path and rewrites all links to be absolute. This isn’t the most flexible solution as it relies on outbound scanning on specific paths. It may be better to add something into this solution, but this isn’t something I’ve looked at yet.

It’s on Nuget

The source code is available at https://github.com/markeverard/Chief2moro.SyndicationFeeds – I’m happy to accept Pull requests

A package (currently v1.0.0.1)  is (soon to be – when its approved) available in the EPiServer Nuget Feed – http://nuget.episerver.com/ – search for CHIEF2MORO.SyndicationFeeds

Happy Feeding!

Written by mark

May 30th, 2014 at 1:30 pm

Posted in ASP.NET,C#,EPiServer

Image resizing in EPiServer 7.5 CMS

with 13 comments

Dynamic image scaling is an often sought after feature for interface designers and content editors. Whilst not natively supporting this feature; EPiServer 7.5 CMS contains a neat hidden feature (Thanks @athraen for the heads up) that allows a limited but useful ability to automatically scale your images.

True dynamic scaling, and by that I mean that your http request for an image also contains your requested height, width and cropping options, is a complex operation to perform successfully, just check out the interesting blog posts at http://imageresizing.net/. Note there is a community integration of ImageResizer.Net with EPiServer 7.5.

The new media editing interface allows in-line preview of uploaded images via a scaled thumbnail representation of the image. These are created automatically by EPiServer for any ImageData content types that are created.  This is achieved via a ImageDescriptor attribute which can be placed on any ‘routed’ blob property (i.e those on ImageData content types).

Thumbnails in the media edit interface

The ImageDescriptor is pretty cool, but not so helpful when you start working with real images with differing aspect ratios.

A simple use case could be that for every uploaded image you want to create a version that has a maximum width of 300 px, which could be used in a site sidebar. The ImageDescriptor as-is forces you to define a height and width at compile time meaning that all uploaded images will be resized to the same width and height specified in the attribute. Any additional height or width will be filled with white-space.

The CHIEF2MORO.ImageDataExtensions nuget package I blogged about previously also contains a couple of additional attributes to help overcome this limitation. Extend your ImageData content object (ImageFile in Alloy) with a few Blob properties for the different sizes and mark up with the attributes. The blob routing feature in EPiServer means that these scaled images are available publically (<imagename>.jpg/image250 and <imagename>.jpg/half). Behind the scenes both of these descriptors use the underlying ThumbnailManager class contained in the EPiServer API.


   [ScaffoldColumn(false)]
   [ImageWidthDescriptor(Width = 250)]
   public virtual Blob image250 { get; set; }

   [ScaffoldColumn(false)]
   [ImageScaleDescriptor(Percent = 50)]
   public virtual Blob half { get; set; }

The ImageWidthDescriptor only requires you to specify the scaled width and will calculate the height at content publish time from the originally uploaded image dimensions to ensure that the aspect ratio is maintained (so you get no padding / whitespace)

The ImageScaleDescriptor allows you to specify a scale and will calculate the desired height and width from the original image.

Written by mark

February 13th, 2014 at 10:00 am

Posted in ASP.NET,C#,EPiServer