コード例 #1
0
ファイル: Program.cs プロジェクト: StarcounterPrefabs/Content
        static void Main()
        {
            MainHandlers handlers = new MainHandlers();
            ContentHandlers content = new ContentHandlers();
            CommitHooks hooks = new CommitHooks();
            DataHelper data = new DataHelper();

            data.GenerateData();
            handlers.Register();
            content.Register();
            hooks.Register();
        }
コード例 #2
0
        public void Register()
        {
            RegisterPartials();

            Handle.GET("/content/standalone", () => {
                Session session = Session.Current;

                if (session != null && session.Data != null && session.Data is StandalonePage) {
                    return session.Data as StandalonePage;
                }

                StandalonePage standalone = new StandalonePage();

                if (session == null) {
                    session = new Session(SessionOptions.PatchVersioning);
                }

                standalone.Session = session;
                standalone.User = Self.GET("/sc/mapping/user", () => new Page());

                return standalone;
            });

            Handle.GET("/content/cms", () => {
                return Db.Scope<StandalonePage>(() => {
                    string url = "/content/partials/cms";
                    StandalonePage master = this.GetMaster();

                    master.PartialUrl = url;
                    master.RefreshCurrentPage();

                    return master;
                });
            });

            Handle.GET("/content/cms/item/{?}", (string key) => {
                return Db.Scope<StandalonePage>(() => {
                    string url = "/content/partials/cms/item/" + key;
                    StandalonePage master = this.GetMaster();

                    master.PartialUrl = url;
                    master.RefreshCurrentPage();

                    return master;
                });
            });

            Handle.GET("/content/cleardata", () => {
                DataHelper data = new DataHelper();

                data.ClearData();

                return 200;
            });

            Handle.GET("/content/resetdata", () => {
                DataHelper data = new DataHelper();

                data.ClearData();
                data.GenerateData();

                return 200;
            });
        }