r/dotnet•
daoom

Allowing user to customize CSS/HTML of parts of an ASP.NET MVC Site

I'l building a site where users will have their own personalized "page" and while it's easy enough to allow them to set their own profile picture or banner, I also want grow it to the point where more advanced users can make their more significant customizations. This means allowing them to edit the CSS and/or parts of the underlying HTML layout.

Are there any existing libraries or frameworks I could leverage to safely allow this without having to roll my own solution?

And long with this, does anyone know of of any libraries I could use to also allow them to re-organize the layout of components by putting their page in "edit" mode and dragging/dropping components or adding removing them similar to the way a CMS would allow it.

Thanks for the help.

Posted Sep 21, 2015, 5:51 PM UTC · edited

46
flukus•

You're reinventing a CMS, why not use a CMS?

6
herple_derpskin•

You want an WYSIWYG editor. One of the more popular ones is called tinymce. You can either use the jquery version or the one specifically created for asp.net. I went with the jquery plugin.

2
daoomOP•

Not quite. Those are good for blog posts and for editing text. It might be useful for the users editing their HTML and CSS, but not the overall structure.

What I want is something that will support near CMS type functionality for the users to manage their pages. Think of the way subreddit admins can customize the subreddit using CSS and add in the fact that there are multiple pages and I also want them to be able to edit a bit of the structure (add or remove sections, insert custom markup or javascript, etc)

1
herple_derpskin•

Ohhh ok. Yeah I'd like to know a plugin that would allow this as well. I've had users ask for this feature.

1
daoomOP•

Right now I'm working towards rolling my own, but I'm hoping somebody can point me towards a time saver.

Here's a high level of what I'm thinking of designing:

A "Theme" engine which is made up of:

  • 1 or more "Pages" (i.e. "Home", "Profile", etc)
  • CSS (CSS which is applied to each page)
  • JS (JS which added to each page)
  • Assets (images and other files that user can upload to customize their pages)

When customized (as opposed to using the default theme) the code for the pages, CSS, and JS is stored in the database per user and the associated assets uploaded to cloud storage.

Customization of the each page is done through something like Handlebars (https://github.com/rexm/Handlebars.Net)

My problem is that I don't want to render every page every time it's requested so I also need to build a layer of caching on top of the page rendering (or maybe find a way to use output/donut caching on the actions themselves top optimize the page rendering)

Anyway, that's my thinking on it so far.

It also doesn't include any kind of visual editing where the user can easily edit the page "in-place" and either change text or move one element (say a picture or a menu) from place to another by dragging and dropping it.

2
Disconnekted•

Its a good idea, but you are looking at hundreds of hours of dev time. I would allow users to move components and use an orderby to build the page and store the raw html in a blob. Retrieve it by url in the onactionexecuting. Good luck!

1