1

私は、まったく専門的ではなく、誰も使用しないことを意図したブログ エンジンの構築を開始しました。ですから、平易な英語では、あなたが先に進んで自分でこれを実行すれば、あなたは幸せになるとは言えません.

これまでに書いた完全なコードが表示される場合があります。

https://github.com/tugberkugurlu/MvcBloggy

現在、私はDALに取り組んでいますが、何をする必要があるかを考えています。ここで立ち往生している点の 1 つは、ブログ エンジンのテーマ選択をどのように処理できるかということです。

  • 基本の構築はどのように開始すればよいですか?スケルトン html を作成し、他の人に CSS を書いてもらい、基本的にそれを選択する必要がありますか? または、他の何か?
  • ASP.NET MVC 構造に関して、この機能を処理するための最良のアプローチは何でしょうか。

これまでにこのようなことをしたことがある人はいないと思います。方法を教えていただければ幸いです。

4

2 に答える 2

1

I suggest you to look at NBlog temable blog engine

https://github.com/ChrisFulstow/NBlog

In particular, look at the class ThemeableRazorViewEngine.cs

https://github.com/ChrisFulstow/NBlog/blob/master/NBlog.Web/Application/Infrastructure/ThemeableRazorViewEngine.cs

using System.Web.Mvc;
using NBlog.Web.Application.Service;

namespace NBlog.Web.Application.Infrastructure
{
public class ThemeableRazorViewEngine : RazorViewEngine
{
    private readonly IThemeService _themeService;

    public ThemeableRazorViewEngine(IThemeService themeService)
    {
        _themeService = themeService;

        base.ViewLocationFormats = new[]
        {
            _themeService.Current.BasePath + "/Views/{1}/{0}.cshtml",
            _themeService.Current.BasePath + "/Views/Shared/{0}.cshtml",
            "~/Themes/Default/Views/{1}/{0}.cshtml"                
        };

        base.PartialViewLocationFormats = new string[] {
            _themeService.Current.BasePath + "/Views/{1}/{0}.cshtml",
            _themeService.Current.BasePath + "/Views/Shared/{0}.cshtml",
            "~/Themes/Default/Views/Shared/{0}.cshtml"
        };
    }

    public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
    {           
        // bypass the view cache, the view will change depending on the current theme
        const bool useViewCache = false;

        return base.FindView(controllerContext, viewName, masterName, useViewCache);
    }
}
}
于 2011-10-26T15:10:52.010 に答える
0

Web アプリケーションを完全にテーマ化することは、非常に複雑な問題です。機能するブログ エンジンを用意する前に、問題を解決しようとしてはいけません。

シンプルでかなり簡単にカスタマイズを実現するには、ユーザーが .css ファイルを選択できるようにし、ページ内のすべての要素を適切な ID/クラスで簡単にアドレス指定/選択できるようにします。

于 2011-10-27T01:35:33.627 に答える