Giter Club home page Giter Club logo

gridiron's Introduction

GridIron

C++ "Code-Beside" framework, modeled after ASP.NET, based on Oat++

See more:

Overview

This project is using oatpp and oatpp-swagger modules.

Project layout

|- CMakeLists.txt                        // projects CMakeLists.txt
|- include/
|   |
|   |- gridiron/                         // GridIron header files
|   |   |- controls/                 // GridIron headers for custom controls
|   |       |- ui/                   // GridIron headers for custom ui controls
| 
|- src/
|   |
|   |- controller/                       // Folder containing UserController where all endpoints are declared
|   |- db/                               // Folder with database mock
|   |- dto/                              // DTOs are declared here
|   |- gridiron/                         // GridIron library root
|   |    |- html/                        // GridIron HTML root for C++ pages
|   |        |- controls/            // GridIron Custom controls root
|   |            |- ui/              // UI controls eg <gi:label>
|   |- SwaggerComponent.hpp              // Swagger-UI config
|   |- AppComponent.hpp                  // Service config
|   |- App.cpp                           // main() is here
|
|- test/                                 // test folder
|- utility/install-oatpp-modules.sh      // utility script to install required oatpp-modules.

Build and Run

Using CMake

Requires

  • oatpp and oatpp-swagger modules installed. You may run utility/install-oatpp-modules.sh script to install required oatpp modules.
$ mkdir build && cd build
$ cmake ..
$ make 
$ ./gridiron-demo        # - run application.

In Docker

$ docker build -t example-crud .
$ docker run -p 8000:8000 -t example-crud

Example endpoint boilerplate (*the render mechanism is about to change)

  ENDPOINT("GET", "/", root) {
    GridIron::Page page("gridiron-demo/testapp.html");
    GridIron::controls::Label lblTest("lblTest", &page);
    page.RegisterVariable("lblTest_Text", lblTest.GetTextPtr());
    lblTest.SetText("these contents were replaced");
    auto response = createResponse(Status::CODE_200, page.render().c_str());
    response->putHeader(Header::CONTENT_TYPE, "text/html");
    return response;
  }

"Code-Beside"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<GridIron::Page lang="en">
<head>
    <meta charset="utf-8" />
    <title>GridIron Test Page</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<h2>GridIron Test Page</h2>
<hr/>
<table border="0" cellpadding="5" cellspacing="5">
    <tr>
        <th align="left" bgcolor="#dedede" colspan="2">Variable Replacement:</th>
    </tr>
    <tr>
        <td align="left"><b>Front Page:</b></td>
        <td align="left"><GridIron::Value key="gridiron.frontPage" /></td>
    </tr>
    <tr>
        <td align="left"><b>Front Page File:</b></td>
        <td align="left"><GridIron::Value key="gridiron.frontPageFile /></td>
    </tr>
    <tr>
        <th align="left" bgcolor="#dedede" colspan="2">GridIron::Label Test<br>
            <small>This will show "default contents" if SetText did not work</small></th>
    </tr>
    <tr>
        <td align="left" colspan="2">
            <GridIron::Label id="lblTest">default contents</GridIron::Label>
        </td>
    </tr>
    <tr>
        <th align="left" bgcolor="#dedede" colspan="2">Variable Replacement with text from lblTest:</th>
    </tr>
    <tr>
        <td align="left"><b>lblTest.Text:</b></td>
        <td align="left"><GridIron::Value key="lblTest.Text" /></td>
    </tr>
    <tr>
        <th align="left" bgcolor="#dedede" colspan="2">Autonomous GridIron::Label Test<br>
            <small>This should show "default auto contents".</small></th>
    </tr>
    <tr>
        <td align="left" colspan="2">
            <GridIron::Label auto="true" id="lblAutoTest">default auto contents</GridIron::Label>
        </td>
    </tr>
    <tr>
        <th align="left" bgcolor="#dedede" colspan="2">Variable Replacement with text from lblAutoTest:</th>
    </tr>
    <tr>
        <td align="left"><b>lblAutoTest.Text:</b></td>
        <td align="left"><GridIron::Value key="lblAutoTest.Text" /></td>
    </tr>
</table>
<a href="swagger/ui">Checkout Swagger-UI page</a>
</body>
</GridIron::Page>

Sample output/test-page

gridiron's People

Contributors

jessicamulein avatar lganzzzo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

gridiron's Issues

Instantiation parsing improvements - reduce to one pass

  • currently, at instantiation of the page, the html is parsed out into node objects, and only autonomous tags are sought out as the calling code may not have constructed all of its objects yet. Then, when render is called, a second pass goes back through and matches standard control tags to the instances that were loaded (and registered automatically with the page instance). The second pass makes all of the standard controls parse their data from the page.

Database autos

I'd like to be able to place a tag with a query string, and tell it to enumerate some rows and give it a template to render. You should be able to fill in a simple table with no C++ code.

  • in order to specify ranges, limit values, etc, a variable replacement will have to happen at initial load time.

More advanced xhtml <gi::Control> cross-component references

Once everything is working again, we will be back to operating by manually placing entries in a hashbucket with a name like {id}.Text, as applicable to each control type, such as a label.

It should be possible to treat that expression more literally and either fetch the property/variable value or execute the function and get the result if it's a function and/or () is appended. A custom control might be referenced by <gi::Value key="{id}.Somefunc()" />

License

I believe the Apache 2.0 license is what everyone is using- that I think is the defacto license for the project at this time unless someone raises an issue here.

@lganzzzo

Resign commits

Resign jessica's commits and force-push.
Accidentally committed using incorrect key for email.

Render engine improvements/integration

The first attempt at bolting onto Oat++ was less than graceful.
There are a couple of possible PR's in progress with pieces of approaches we might use.

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.