views:

91

answers:

3

I have a website (ASP.NET MVC) which I would like to extend to another similar topic (like stackoverflow-serverfault-superuser).

Database layer and controllers layer are the same for both websites. What differs is just the vie layerw, and only for just a few detail: logos, masterpage and some resources files (in part) and css.

What's the best way to manage this situation? How is this accomplished by Jeff and his team?

My ideal goal is to have a single solution (Visual Studio solution), a project with controllers and model, and n different project: each for every view. (added this line to clarify)

I get this done simply branching the two solutions (with svn o mercurial) and then merging while publishing?

Thanks guys!

A: 

You say that you have a website, and you want to extend it for another topic. I think you should think is this fashion:

  • you have a web app that does your job.
  • you have a website on which you've deployed that web app
  • now you want another webapp with the same functionality (just like SO-SF), but different look and feel
  • I think your task is just configuring your web app to look different, and deploying it on a separate server

Notes: * These two websites will be independent of each other. They will not have data in common! * If you want the websites to interact, its better to make the web app capable of interacting with other instances of itself, and then redeploying.

I hope I understood what you were asking correctly, and that what I've written will be helpful.

Cheers, jrh

Here Be Wolves
Yes this could be right, but this way I have to duplicate almost the entire view (resources files and template), and this sounds as code duplication...I edited the original question, I hope to clarify
Davide Vosti
+2  A: 

I can think in two way of doing this

  1. you could have to apache web servers or IIS in case your domains are different and the store the css, logos and other UI stuff that could be store in the server.

  2. If you're using .net which I suppouse cause you're talking about master page and your domains are not different, you could add some logic to your web app to switch from one template to another according some rules like the username or profile. If you're using .net I think you can generate to different skins and assign them according certain logic that you must implement. If you're using some different language you could also generate a template and switch it according your rules.

Hope this helps.

chermosillo
The problem with your second point is that the code will be filled with so many if-else that you won't be able to read and modify it after a few months.... That's not a feasible solution
Davide Vosti
I don't think you need to make a lot of if-else statement you can simple add some kind of session variable telling you the kind of template and then use it as pre/postfix to your css and logos i.e {$templatename}-main.css, you can save that templatename variable in user pofile
chermosillo
A: 

We use the App_GlobalResources folder to do this

  • App_GlobalResources\ServerFault.resx
  • App_GlobalResources\StackOverflow.resx
  • App_GlobalResources\MetaStackOverflow.resx

with a helper class:

public static class Resources
{
public static string TeamEmail { get { return GetString("TeamEmail"); } }    
public static string GetString(string key)
{
    return HttpContext.GetGlobalResourceObject(
         GlobalApplication.CurrentSite.ToString(), key).ToString();
}
}

and it appears in the view like so:

<a href="mailto:<%= Resources.TeamEmail %>">contact us</a>

For more total replacements (e.g., the /faq), we have multiple copies of the faq like so:

  • Faq-ServerFault.aspx
  • Faq-StackOverflow.aspx
  • Faq-StackOverflowMeta.aspx

The build renames the file appropriately for each server.

(Note that these are content views, so they are literally just the faq CONTENT itself, the master page determines the rest of the layout)

Jeff Atwood