Giter Site home page Giter Site logo

seams's Introduction

Seams is a minimal, markup-driven, static-site CMS.

Installation

npm i seams

Seams persists content using MongoDB. A mongodb:// URI is required.

Usage

Seams is markup-driven, meaning that the user can create standard, valid HTML pages using specific data attributes that will later be injected with dynamic content when served. For example:

<html>
  <body>
    <h1 data-content="header">This is the default header</h1>
  </body>
</html>

Tells Seams to inject the header content for the current page into this h1 tag. If no such content exists, the h1 will default to the This is the default header text.

Unlike most content management systems, Seams has no backend other than a single admin login page. All content editing is done directly on the pages one wishes to edit.

Starting a Seams server is as easy as:

const http = require('http');
const path = require('path');
const seams = require('seams');

const server = http.createServer(
  seams({
    secret: 'my secret key',
    dir: path.join(__dirname, 'web'),
    db: 'mongodb://my:mongo@database'
  })
);

server.listen(8080);

This will serve static content from the web/ directory while injecting dynamic content wherever a Seams data attribute is found. Valid Seams attributes are:

  • data-content - Renders the innerHTML of the element it is found on.
  • data-src - Sets the src attribute of the element it is found on (useful for img tags).
  • data-href - Sets the href attribute of the element it is found on (useful for a tags).
  • data-text - Sets the innerText of the element it is found on.
  • data-background - Sets the background-image style property.

Getting started

After creating a directory with static HTML/CSS/JS files and acquiring a MongoDB URI, create a server.js file as shown above. The seams function takes in an options object and returns a HTTP request/response handler function. The options object can have the following properties:

{
  db: <string>,
  dir: <string>,
  secret: <string>,
  [expires: <number>]
}

Where db is the URI for the MongoDB, dir is the path to the directory containing the static files to be served, secret is the secret key used for hashing admin webtokens, and expires is an optional number to change the time (in milliseconds) until cached pages expire. The default cache expiration time is 5 minutes.

Creating an admin

Initially running the server with the flags --seams-admin-name and --seams-admin-password will create an admin account. For example:

node server.js --seams-admin-name=MyAdmin --seams-admin-password=password123

Editing content

Once the server is running, navigate to /seams and log in with the credentials created from the command line. Once logged in, navigate to the page to edit, click on a content area (a bubble will appear around the cursor when hovering over an editable content area) and edit it with the panel that appears. Saving these changes will persist it to the database and the page will then render with the new content.

Elements given the data-content attribute are editable with basic markdown syntax:

  • #This is an h1#
  • ##This is an h2#
  • _This is italicized_
  • *This is bold*
  • [This is a link to](http://www.google.com)
  • ![This is alt text](for-some-image.jpg)

seams's People

Contributors

joshlgrossman avatar

Watchers

 avatar

seams's Issues

Can't click on stacked elements with seams attributes

In the following scenario, if both elements are the same size, you'll be unable to edit the href attribute, because the span will always be in the way.

<a data-href="main-menu-1" href="/">
<span data-content="main-menu-1">Home</span>
</a>

Ideally, every element that exists where we clicked would become editable in the seams side menu, with appropriate labels.

Unable to turn off cache

setting cache to 0 or 1 ms does not seem to disable it. Would like to have it turned off while developing locally.

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.