All Projects โ†’ AUTplayed โ†’ ldf

AUTplayed / ldf

Licence: GPL-2.0 license
LDF - Lightweight Dynamic Framework for making Single Page Applications

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ldf

DLL-INJECTOR
I created a dll injector I am going to Open source its Code. But remember one thing that is any one can use it only for Educational purpose .I again say do not use it to damage anyone's Computer.But one thing if you are using it for some good purpose like to help someone who really need help then I permit you to use it.
Stars: โœญ 14 (-51.72%)
Mutual labels:  simple
QArchive
Async C++ Cross-Platform library that modernizes libarchive using Qt5 ๐Ÿš€. Simply extracts 7z ๐Ÿ”, Tarballs ๐ŸŽฑ and other supported formats by libarchive. โค๏ธ
Stars: โœญ 66 (+127.59%)
Mutual labels:  simple
mohusman360.github.io
Simple Resume Template with Tailwind CSS
Stars: โœญ 38 (+31.03%)
Mutual labels:  simple
nstate
A simple but powerful react state management library with low mind burden
Stars: โœญ 11 (-62.07%)
Mutual labels:  simple
llb
Dead simple event-driven load-balancer
Stars: โœญ 27 (-6.9%)
Mutual labels:  simple
Artal
A .PSD parsing library for Lร–VE
Stars: โœญ 41 (+41.38%)
Mutual labels:  simple
onion-pi
Configures your Raspberry Pi as portable WiFi-WiFi Tor proxy.
Stars: โœญ 13 (-55.17%)
Mutual labels:  simple
game-map-editor
game-map-editor
Stars: โœญ 17 (-41.38%)
Mutual labels:  simple
Simple-Slack-Bot
Simple Python library for creating Slack bots.
Stars: โœญ 26 (-10.34%)
Mutual labels:  simple
simplenetes
The sns tool is used to manage the full life cycle of your Simplenetes clusters. It integrates with the Simplenetes Podcompiler project podc to compile pods.
Stars: โœญ 731 (+2420.69%)
Mutual labels:  simple
Simple-Game-ERC-721-Token-Template
๐Ÿ”ฎ Very Simple ERC-721 Smart Contract Template to create your own ERC-721 Tokens on the Ethereum Blockchain, with many customizable Options ๐Ÿ”ฎ
Stars: โœญ 83 (+186.21%)
Mutual labels:  simple
dice-simulator
A Python simple Dice Simulator just for fun
Stars: โœญ 17 (-41.38%)
Mutual labels:  simple
xml.nim
Simple XML parser in pure Nim
Stars: โœญ 16 (-44.83%)
Mutual labels:  simple
Hexo-Theme-MengD
A simple, lightweight Hexo theme๏ผˆๆ”ฏๆŒ๏ผšpjaxใ€discussใ€twikooใ€walineใ€valine่ฏ„่ฎบ๏ผ‰
Stars: โœญ 69 (+137.93%)
Mutual labels:  simple
youtube-lite
No more wasting time on watching random, irrelevant videos on Youtube. https://youtube-lite.js.org
Stars: โœญ 22 (-24.14%)
Mutual labels:  simple
finddups
Find duplicate files on your computer
Stars: โœญ 22 (-24.14%)
Mutual labels:  simple
VPAutoComplete
A simple Auto Complete UITextField also support UITableView written in swift 4.2
Stars: โœญ 20 (-31.03%)
Mutual labels:  simple
graph-client
light zero dependency graphql-client, supporting cache and SSR
Stars: โœญ 27 (-6.9%)
Mutual labels:  simple
SimpleList
A simple linked list for Arduino projects
Stars: โœญ 43 (+48.28%)
Mutual labels:  simple
base64.c
Base64 Library in C
Stars: โœญ 60 (+106.9%)
Mutual labels:  simple

LDF - Little Dynamic Framework for making Single-Page Applications

Tired of giant frameworks like Angular?

Trying to avoid complicated stuff like MVC, Typescript or JSX and just want to create a website in good old plain JS HTML CSS?

Want to make a small website feel 100x better because it's a Single-Page Application?

Then this is the framework for you!

Table of Contents

Features

Navigating your website with a tags like this

<a href="login">Login</a>

will, instead of fully refreshing the page, dynamically load the requested content (in this caselogin.html), and switch out the old content with the new one.

Additionally, LDF will wait for external resources (like stylesheets or images) to load before displaying the page. Demonstration with a throttled connection and cpu:

demo

The script will also change the browser's navigation bar via the History-API, so that the page can be refreshed and browser-features like back and forward will work.

If you want to navigate your page via Javascript, all you have to do is call the nav function of the global ldf object like this, with the parameter being the page you want to navigate to:

ldf.nav("login");

You can include css and js in your html files just like normal, they will also be dynamically loaded.

For a small demonstration, check out the demo directory, or check it out live.

Notes:

If you dynamically add a tags via Javascript (not by changing the page with ldf but with for example document.createElement), you'll have to invoke ldf.updatePageLinks() in order for a tags to not reload the page.

Getting started

Just include the script in your index page like this:

<script src="ldf.js"></script>

You also have to add a div element with the id "ldf"(configurable) in your index.html where you want your content to be like this:

<div id="ldf"></div>

LDF expects a folder structure like this (directory name can be configured):

index.html                                    required
pages/                                        required
โ”œโ”€โ”€ index/                                    required
โ”‚   โ”œโ”€โ”€ index.html                            required
โ”‚   โ”œโ”€โ”€ index.css
โ”‚   โ””โ”€โ”€ index.js
โ””โ”€โ”€ examplepage/
    โ”œโ”€โ”€ examplepage.html
    โ””โ”€โ”€ styles.css

Each folder in the pages directory represents a page (duh) and will be loaded if a user navigates to the route named after the folder. So, for example if a user clicks on an a tag with href="examplepage", LDF will attempt to load pages/examplepage/examplepage.html. The page index is required, and is the default content you'll see without any navigation.

Configuration

LDF currently allows for some configuration.

// The selector for which content should be switched out on page change
ldf.mainselector = "#ldf";
// The content displayed when LDF receives a 404 from the server while requesting a page
// Set this to undefined if you want LDF to display the error page it received from your server
ldf.notfound = "<div>Page not Found</div>";
// The directory your pages are stored on the server, default is /pages
ldf.pagedir = "/pages";
// A base url that is prepended for every navigation
// Used in my case for github pages since that has a required base url
ldf.baseurl = "";
// The css selector string LDF will wait on before displaying the page.
// By default it waits for all stylesheets and all elements with a src attribute (like images), but not scripts.
ldf.waitselector = "link[rel='stylesheet'],:not(script)[src]";
// Use hash urls, by default it's true. Hash urls look like this: domain.com/#login
// The advantage of these is that you don't need a web server to handle refresh events, but the url doesn't look that good.
ldf.hash = true;

Component swapping

You can also use the functions provided by ldf to load pages into other elements like demonstrated here: demo

Methods you can use:

ldf.load(selector, location, \<optional\>query);
ldf.load("#header", "/header", "?fancy=true");
// external content will be waited on before the content is changed just like switching pages
ldf.change(selector, htmlContent);
ldf.change("#footer", "<div>new footer</div><script src='...'/>");

If you want to have an example that shows the potential uses for this, you can find one here

Non-hash url

If you don't want to use hash urls (more info a few lines above), then here's the instruction for you:

In order for the refresh function to work, you will have to include a special case in your web server.

You have to look at the request if it's not / but a request to a page, and send back your index.html. But you can't just always send back index.html when the requested file isn't found, unless you want your site to break if a user visits a missing page, since LDF relies on getting an error from a request to a missing page.

A small implementation of this I used in the demo/example project (with nodejs and express) looks like this:

// Static resources
app.use(express.static(__dirname));
// Special case, always sends back index.html if the request is only 1 level.
// This works because requests to resources are 3 levels deep (pages/resource/resource.html)
app.get("/:page", (req, res) => {
	res.sendFile(require("path").join(__dirname, "index.html"));
});

Quickstart with java server

I wrote a java library to quickstart development with ldf and the templating engine mustache. It also solves the problems with non-hash url as mentioned above. You can find information about the library here

Final Notes

This project was just thrown together in a few hours based on a way messier implementation, which I used in my diploma thesis. If you find a bug or want to add an improvement, please open an issue/pull request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].