Giter Site home page Giter Site logo

csvaulter's Introduction

CSVaulter: Dynamic, randomized content synergy on a static-site budget

Ever wish you could run a dynamic, fast-moving media startup without any effort or budget? You can, with the power of CSVaulter, which will randomly update your static site page by replacing content based on the information in a CSV (comma seperated value, i.e., spreadsheet). Every time a visitor refreshes the page, they're giving a randomly selected experience, making it feel like your destination has its finger on the pulse of what's hot and always offering something new. Since there's no server required, you can even host your new media empire for free on GitHub Pages.

image

Step 1: Create Your Content™

image

First, ensure you have a CSV file filled with the Content™ you want to dynamically display. This can include headlines, links, image URLs, paragraphs, etc.

Sample CSV format:

variable-id,variable-title,variable-description,variable-image,variable-article-1-url,variable-article-1-headline
1,"Title 1","Description 1","https://example.com/image1.jpg","https://example.com/article1","Headline 1"
2,"Title 2","Description 2","https://example.com/image2.jpg","https://example.com/article2","Headline 2"

Upload this somewhere on the web.

Step 2: Import CSVaulter, the Future of All Media

Include CSVaulter (and Papa Parse) in your HTML.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Your Dynamic Site</title>
</head>
<body>
    <!-- Your content here -->

    <!-- Papa Parse for CSV parsing -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
    <!-- CSVaulter: The hero your website deserves -->
    <script src="path/to/CSVaulter.js" data-csv-url="path_to_your_csv_file.csv"></script>
</body>
</html>

Step 3: Tag content for upgrading

image

Use data-csv-replace attributes to earmark elements for dynamic content replacement. Ensure that the underlying content is something that will work as a fallback in case users have JavaScript disabled.

<h2 data-csv-replace="variable-title">Fallback Title</h2>
<p data-csv-replace="variable-description">Fallback Description</p>
<img data-csv-replace="variable-image" src="fallback-image.jpg" alt="Fallback Image">
<a data-csv-replace="variable-article-1-url" href="fallback-url.html">Fallback Link</a>

Step 4: Synergize

Load your page, and watch as CSVaulter breathes life into your content. With each refresh, a new possibility unfolds. It's like your site is living its best life, thanks to you (and a little CSV magic). Note that due to cross-site scripting restrictions, this probably won't work locally unless you tweak you developer settings.

Bonus: Advanced tips

Want to target a specific row based on whimsy or user interaction, or make it so that people can share specific iterations easily? Toss a #rowId at the end of your URL (e.g., yourdomain.com/#2) and watch CSVaulter fetch content from that specific row like a well-trained retriever.

Vaulter can also be used to update images, links, etc. as in the above examples.

Contribute

This code is an abomination and pox upon the earth. If you want to make it better, feel free to fork and update. Will probably license under MIT at some point.

image

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.