Giter Site home page Giter Site logo

cmsed's People

Contributors

katyukha avatar rikkimax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

katyukha

cmsed's Issues

Using Vibe's analog of routes

What about using vibe's REST/WEB interfaces (https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/web/common.d, https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/web/web.d, https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/web/rest.d)

Reasons:

  • avoids problem of "One more standard"
  • vibe has more unittests which allows to understand how they work even without documentaion, in in future vibe may have own documentation on it

Example of using vibe's web interface:

  1. Definition of interface:

        module blog.web;
    
        import blog.models;
    
        import vibe.http.server: HTTPServerRequest;
        import vibe.web.web;
        import vibe.web.common;
        import vibe.core.log;
    
        import std.string: format;
    
        class PostView {
    
            void index(){
                auto posts = Post.findAll();    
                render!("blog/index.dt", posts);
            } 
    
            void postAdd(HTTPServerRequest req){ 
                Post post = new Post();
                post.slug = req.form["slug"];   
                post.title = req.form["title"]; 
                post.text = req.form["text"];   
                post.save(); 
                redirect(format("/blog/%s/", post.slug));
            }     
    
            @path("/:slug/")
            void getView(HTTPServerRequest req){ 
                string slug = req.params["slug"];
                auto post = Post.query().slug_eq(slug).find()[0];
                render!("blog/post/view.dt", post);
            }
    
        }
  2. Registration

    module blog;
    
    import vibe.http.router: URLRouter;
    import vibe.web.web;
    
    public import blog.web;
    
    void register(URLRouter router){
        // register views
        auto postViewSettings = new WebInterfaceSettings();
        postViewSettings.urlPrefix = "/blog/";
        registerWebInterface(router, new PostView, postViewSettings);
    }

Example of using Cmsed routes

  1. Definition

    module routes.blog;
    
    import cmsed.base;
    
    
    class Home : OORoute {
        @RouteFunction(RouteType.Get, "/", "index")
        string index() {return "Test";}
    
    
        @RouteFunction(RouteType.Get, "/test/", "index")
        bool test() {
             return true;
        }
    }
  2. Registration

    module routes;
    
    import cmsed.base;
    public import routes.blog;
    
    shared static this() {
      registerRoute!Home;
    }

Thigs that not obvious in Cmsed routes

  • if we define template to be used by route via @RouteFunction(RouteType.Get, "/test/", "index"), how to send to that template variables
  • how to pass arguments via URL and where to look for them
  • where to look for req and res if they are required for doing something special

Spelling errors in README

Sorry if it seems pedantic, but here are a few spelling errors immediately noticeable in the README.

Note UDA's (or attributes) are stackabe.

=> Note UDAs (or attributes) are stackable.

You can utilise RouteGroup's to append e.g. path values on.

=> You can utilise RouteGroups to append e.g. path values on.

Note shared is required part of this.

=> Note shared is a required part of this.

But here its more important as it is executed and grabbed for values

=> But here it's more important as it is executed and grabbed for values

Contains list of all widgets with routes accessible at runtime.

=> Contains a list of all widgets with routes accessible at runtime.

First steps documentation.

Hello!

Cmsed seems to be nice project! thanks for doing such great work. but there is so less documentation, especialy for first steps (i mean what to do to simply run project with few models and basic views for them).
It would be nice to write in Readme some sort of tutorial how to setup initial project, what settings should be in configuration file, and and how to create basic models and views (controllers/routes).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.