Skip to content

Latest commit

 

History

History

cde-json-viewer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

cde-json-viewer example

A CDE-style (Common Desktop Environment) system monitor page, built entirely in C: a mock JSON document is parsed with cJSON, turned into an HTML table with the HTML builder (cwist_html_element_*), and styled with a generated stylesheet from the CSS composer (cwist_css_generate_stylesheet).

The single route GET / renders the page; there is no other endpoint and no external asset — the CSS is inlined into a <style> tag.

Build

Build the library first, from the repository root:

make

Then build the example:

make -C example/cde-json-viewer

The directory Makefile produces cde_json_viewer. The root Makefile also has a rule for the same program under a dashed name:

make example/cde-json-viewer/cde-json-viewer

make examples-check builds it as well.

Run

./example/cde-json-viewer/cde_json_viewer     # or ./example/cde-json-viewer/cde-json-viewer

The server listens on port 8080. Open http://localhost:8080/ in a browser, or fetch the page with curl:

curl http://localhost:8080/

The response is a text/html page titled "System Monitor": a table with one row per string field of the embedded mock JSON (host sun-sparc-station, uptime 42 days, load average, and so on), styled with the generated CSS variables in a Solaris-ish blue palette.

Clean

make -C example/cde-json-viewer clean
rm -f example/cde-json-viewer/cde-json-viewer