GithubHelp home page GithubHelp logo

timmylindh / chl Goto Github PK

View Code? Open in Web Editor NEW
269.0 16.0 10.0 5.16 MB

C Hypertext Library - A library for writing web applications in C

License: GNU Lesser General Public License v3.0

C 97.67% Makefile 0.31% Shell 0.35% C++ 1.66%
html website development-tools library http webapps

chl's Introduction

CHL

C Hypertext Library - A library for writing web applications in C

#include <chl/chl.h>

int main() {
 chl_set_default_headers();
 chl_print_headers();
 
 printf("Hello world");
 
 return 0;
}

(Simple Hello World in CHL)

See examples
Tutorial, Setup, API, Contribute
FastCGI

What is CHL?

CHL, short for C Hypertext Library, is a library used to write web applications of all sorts in the C programming language. CHL provides you with a lot of useful features:

  • FastCGI implementation
  • MySQL library
  • Parsing and fetching HTTP data, such as POST and GET.
  • Creating and deleting HTTP headers.
  • A dedicated API for creating and deleting cookies.
  • The ability to execute CHL functions within HTML files

and a lot more...

Why CHL?

What makes CHL uniqe is the support for executing functions inside HTML files, much like PHP using the syntax, though CHL uses the <{ }> syntax.

Example

<body>
 <{ import("header.vw"); }>
</body>

How does it work?

Web applications written in C must somehow be executed by the Web server since C is a compiled language. To make this possible CHL is based on CGI (Common Gateway Interface), which in short means that the server executes your program and passes it data through environment variables. CHL does all the parsing and handling of CGI in the background, and provides you with some easy to use functions instead. CHL also provides an interface for FastCGI.

API

The Application Programming Interface is written with Github Wikis: API.

Setup

For a proper guide on how to install and configure CHL on your system, read the following document: https://github.com/it4e/CHL/wiki/Setup.

As of now, CHL is only officially available on Linux, but I am planning to port it to other operating systems as well if the interest is big enough. Otherwise you could of course make a port of it yourself, see contribute.

Tutorial

To read an in depth tutorial on the structure of CHL web applications, and a walk through on how to get started and how to use the CHL API properly see https://github.com/it4e/CHL/wiki/Tutorial.

The tutorial is divided into various sections. The first section is a quick introduction to let you know what CHL is all about and what it can do for you. We will then dig deeper and deeper into the CHL API.

Before you start reading this tutorial, make sure you have CHL installed and that everything is properly set up. Setting up CHL.

There are several ways you can contribute to CHL. Take a look at the issues page for an overview of what you can contribute to. If you have any ideas of your own for new features to implement, feel free to contribute with a pull request.

For a detailed guide on contribution to CHL, see contribute.

See examples, for a page with detailed examples of CHL in use.

chl's People

Contributors

imfalling avatar it4e avatar timmylindh avatar

Stargazers

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

Watchers

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

chl's Issues

File uploading

A feature to upload files to the server through HTTP should be implemented.

String functions

Add functions for handling and parsing strings.

  • strip_tags
  • ....

test server needed

I would use something like mongoose to add test server for development and testing purposes. It'll reduce installation process to something like:

  1. git clone
  2. cd CHL
  3. make
  4. make run_server (stop_sever, restart_server)
    and will not force to install new libs in system path and install and configure Apache, git pull enough for updates, and mongoose is cross platform, header only library (under GPL as well).

Default inline functions

Need to add some default inline functions. (x: finished)

  • (x) Inline import
  • (x) Inline print function
  • ......

Integer and float forms of post, get and args

Need to define functions for fetching integer and float forms of post, get and args. Should do automatic conversion of text to integer and float values.

  • chl_post -> chl_posti(), chl_postf()
  • chl_get -> chl_geti(), chl_getf()
  • chl_next_arg -> chl_next_argi(), chl_next_argf()

CHL Session Implementation

As of now CHL only supports standard HTTP cookies, which of course can be used for most purposes. However, when it comes to security and creating user-login pages, the more safe way would be to implement sessions.

Get started

If you can think of a smart and efficient way of implementing sessions in CHL (see PHP implementation), feel free to take your ideas to the test and create an implementation of it yourself: see contribute.

CHL MySQL API

CHL is in need of a MySQL API written especially for CHL. This API should make use of the standard MySQL API and work as nothing but a wrapper to make functions easier and more efficient to use.

Why not use the official MySQL API already provided by MySQL?

The standard MySQL API is very tedious and abstract to use, therefore we aim to implement a version of the API which is much more user friendly. If you have ever seen the PHP implementation of MySQL then you know what I am talking about.

If you feel like this is a task you can tackle, take a look at the contribute page to get started.

license

followed a reddit post here and am interested, but the GPL3.0 for a library drives me away, sigh. any possibility to consider a different license?

Indentation not aligned properly

When importing a view component from another view, the text is not aligned properly.

For instance, let's assume we have the view component viewc.vc.

<header>
    Hello
</header>

and we import it from view.vw

<html>
    <head>
    </head>
    <body>
        <{ import("viewc.vc"); }>
    </body>
</html>

the end result might look something like this:

<html>
    <head>
    </head>
    <body>
        <header>
Hello
</header>
    </body>
</html>

instead of

<html>
    <head>
    </head>
    <body>
        <header>
             Hello
        </header>
    </body>
</html>

API update

Must update API to cover every single function of CHL

API

FastCGI

I am now working on a FastCGI interface for CHL.

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.