Coder Social home page Coder Social logo

00mjk / bookjar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zackautocracy/bookjar

0.0 0.0 0.0 1019 KB

A small web app that uses XML as its data storage format

License: MIT License

HTML 12.14% CSS 56.65% JavaScript 17.06% XSLT 14.14%

bookjar's Introduction

Book Jar 1.0.0

Book Jar logo

Book Jar is an electronic library powered by XML as a data source storage , validated with an XSD and processed via XSLT to ouput it in a JSON format that Javascript uses afterwards in rendering, it provides a minimalistic sleek user interface with a subtle library theme. Users can browse a collection of books that are generated from one XML file that holds the books hierarchy.

screenshot

About

Design Goals

  • An easily searchable library with a good SPA experience (Single page application)
  • Conjuring the power of Javascript instead of conceiving a Backend architecture
  • Convenience when adding Data , no dabatabase needed , storage rely solely on books.xml
  • Fast data generation from XML via XSLT , revealing a versatile data format baked specifically for APIs (JSON)

Features

  • Book Search is keyword based instead of strictly matched. No you don't need to remember the exact name to find your book again.
  • A big collection of books and their ratings to browse just for you.
  • Search by Author name and/or Book Title name

Dependencies

  • The App uses Handelbars (Template Engine for Javascript) to display books with their respective data It's already added via a CDN , make sure to run it while you're connected to the internet though.
  • You need an XSLT Processor in order to generate the JSON file , for more infos on how to install such a tool checkout this resource

Getting Started

After cloning the repository you should have the following file tree :

Tree:

  • Public directory has the files that should be public to be hosted and contains :
    • index.html an HTML file with the HandleBars template used in a script tag with type="text/x-handlebars-template"

    • CSS directory contains all the stylesheets used by the app.

    • JS directory contains modules of helper functions that are imported in main.js that contains the logic of the app.

    • Data directory the warehouse of the app it has the books.xml file (contains books) , books.xsd (contains the schema), xml2books.JSON.xsl (contains the stylesheet) and books.json (contains the output target in JSON format) tailored specifically for API usage.

    • Img directory contains images that represent book covers.

Steps:

1 - Add a new Book to books.xml:

All books are contained in a single <books> root node rather than storing each book file individually.An Approach that doesn't scale much.

screenshot

2 - Validate the updated file (books.xml) with XML schema

A document that respects xml syntax is called a well formed xml document, Although the syntax is less flexible than HTML it's still exposed to data corruption resulted from the loss of data integrity. That's why we need to define a set of rules that are more explicit about what XML file structure is valid for our usage. Hence the name of a valid XML document.

Use the official W3C validator.

screenshot

3 - Transform the books.xml into a JSON file

A choice we made while designing the app, we could use XSLT templates directly to generate our HTML in the browser (yeah you nailed it !!The browser also contains a XSLT Processor too based mainly on XPATH). The problem with this approach is the scalability and the usability of the App. In a world dominated by Javascript libraries and APIs , The ideal format for data transfert is JSON.

Use xml2booksJSON.xsl, it's a powerful xsl template that can generate a JSON format from any given XML file.(So cool !! Isn't it)

Make sure to have a XSLT processor installed to generate the JSON file I mainly use the default XML plugin in PHPStorm that supports XSL transformation You can you use the official XSLT processor by Saxon

screenshot

4 - You're good to go:

The app has some javascript code that loads the generated JSON file automatically. And now you can see our little library updated. And all that in no time. Hail to JSON !!!

screenshot

5 - If you liked this little project consider giving it a star

bookjar's People

Contributors

zackautocracy avatar

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.