Giter Site home page Giter Site logo

markuso / kleks Goto Github PK

View Code? Open in Web Editor NEW
83.0 10.0 18.0 752 KB

Kleks - Pure CouchDB based CMS as a Couch App using Kanso with CoffeeScript and Stylus. Supports multi-site setup and Markdown authoring.

Home Page: http://markuso.github.io/kleks

License: MIT License

CoffeeScript 51.97% JavaScript 7.12% CSS 19.69% HTML 21.22%

kleks's Introduction

Kleks - Pure CouchDB based CMS

--- PROJECT IS NO LONGER MAINTAINED ---

Kleks is a pure CouchDB based CMS written as a CouchApp using Kanso, Spine.js, CoffeeScript and Stylus. Supports multi-site setup and Markdown authoring. It is fully open-source with a MIT license.

Kleks can be used to power a network of content-based sites with the ability to fully sync/replicate its NoSQL document-based datastore, CouchDB, in real-time to other locations. The admin interface is accessible from desktops and mobile tablets at this time.

It generates fully responsive websites that are optimized for mobile devices as well. The front-end is built as a CouchApp with HTML5/JavaScript that lives and is served from inside the CouchDB database. It means that there is no need for the middle-tier and no other servers are required.

It has been successfully deployed for a network of content-based sites on Cloudant – a scalable hosted CouchDB cloud infrastructure with search features – and replicates to multiple local and remote machines for backups and offline access.

Who Should Use It?

Kleks is meant for moderate to experienced CouchDB developers that are interested in having a CouchApp solution for some of their content-based site deployments. They can use it as a starting point to customize their own solution for their clients.

Philosophy

Kleks was born for the purpose of serving a network of content sites that are managed by the same entity and are considered to be, what I call living books. It revolves around essays that are contained in collections on each site which are served as a simple, mobile-first, and clean design with focus on the content itself. Each collection can be considered to be a book of essays around a theme/topic, and each essay is written around an idea which may have sections that will auto-create its Table of Contents.

The admin interface is a modern web application written as a CouchApp that has a fast and clean interface which is uncluttered and easy on the eye. It uses Markdown to compose and preview the content within for clean publishing of essays — the living content.

There is also the concept of content sponsorships to monetize these living collections and essays with the ability to place the sponsor's name, link, ad image or video on individual essays or collections of choice, or even just place some Google AdSense for monitization. But only a single sponsor per page to keep interface non-cluttered and reader friendly.

Admin App Screeshots

Visit the project site to see some screenshots of the admin app.

Development Technologies Used

Kleks uses few web development technologies to produce the final result of two CouchApps – one that renders the sites, and one that is the admin app to manage all content and sites.

Kanso – Can be described as the NPM for CouchApps. It is the best way to create and share CouchApps on CouchDB.

Spine.js – Build Awesome JavaScript MVC Applications. It is similar and inspired by Backbone.js but written in CoffeeScript.

CoffeeScript – A little clean language that compiles into JavaScript.

Stylus – Expressive, dynamic, robust CSS.

Quick Install - Replicate a fresh database

A fresh and ready copy of Kleks' design documents are pushed to a database named kleks_install on Cloudant. So to get your hands wet, just replicate that database from https://markuso.cloudant.com/kleks_install to your local CouchDB or any cloud service you have.

You can replicate using Futon from your CouchDB instance, or use the command line curl tool to do so:

$ curl http://localhost:5984/_replicate -H 'Content-Type: application/json' -d '{ "source": "https://markuso.cloudant.com/kleks_install", "target": "kleks" }'

VHOSTS are a MUST

After you install Kleks and its design documents into your database, you must create a virtual host to point to the _design/admin CouchApp, and one for every site you create there after to point to a specific path using the _design/site CouchApp.

This is important for many reasons inside Kleks, so it must be done. On your local CouchDB, you can do this easily in Futon > Configuration > vhosts section.

If you are working locally, be sure to also have these custom host domains listed in your /etc/hosts file as an alias to 127.0.0.1. For production domains, be sure to point your chosen domains using a CNAME to your CouchDB hosting account, like USERNAME.cloudant.com.

The admin interface to Kleks should be configured with a virtual host domain of your choice and always pointing to /DATABASE/_design/admin/_rewrite.

Each site has a unique _id which should be set as its full domain name. Like www.exmaple.com or subsite.mydomain.com, etc. Given that, each site must have an entry in your vhosts CouchDB configuration in the format of /DATABASE/_design/site/_rewrite/render/<site_id> – again usually the database is named kleks (but might not if you have multiple DBs running Kleks) and the site_id is the domain name.

For example:

vhosts:
  kleks.example.local = /kleks/_design/admin/_rewrite
  www.example.local   = /kleks/_design/site/_rewrite/render/www.example.com

If your local CouchDB install is still running on the default port 5984 then you can access the admin app above at http://kleks.example.local:5984 and so on. I am running my CouchDB on port 80, so I don't need to use the port number.

On Cloudant, you do the above using their control panel for your account. You will find an option to setup the above under a tab called Virtual Hosts. Make sure to use real domains that you have already changed the DNS for them with a CNAME to point to your Cloudant account similar to USERNAME.cloudant.com.

Other CouchDB hosting providers may use Futon to allow you to do this, or their own control panel.

User Permissions

Your Kleks database must be setup to be read by anyone so the public can view and navigate your sites. For your admin app, a user or more must be created in your CouchDB _users database and give the role manager or admin for them to be able to log in. This is usually done using Futon.

Also, make sure that you update your database security roles for Admins to state ["admin","manager"] as the roles.

On Cloudant

You can use Cloudant's authentication to login to the admin app. Just make sure a Cloudant's user or generated API Key has either the create or admin permission.

But if you want to create and use a _users database to manage access to the admin app, then you must first turn off Cloudant's own security for the Kleks database to manage via _users. To do this you need to PUT a JSON document like the following to the _security endpoint of the database (for example https://USERNAME.cloudant.com/DATABASE/_security):

{
  "cloudant": { "nobody": ["_reader","_creator","_writer","_admin"] },
  "readers": { "names": [], "roles": [] },
  "admins": { "names": [], "roles": ["admin","manager"] }
}

You can achieve that by using the following: (be sure to change the USERNAME and DATABASE where needed below)

$ curl -X PUT -u USERNAME -p https://USERNAME.cloudant.com/DATABASE/_security -d '{"cloudant":{"nobody":["_reader","_creator","_writer","_admin"]}, "readers": {"names": [], "roles": []}, "admins": {"names": [], "roles": ["admin","manager"]}}'

See their own security documentation for more details.

Self Setup & Deployment

This is the approach you will mostly take to customize Kleks to your needs and push its design documents, the CouchApps, to your CouchDB.

The best way to ask a question about deployment, or to report an issue, is to use the GitHub issues section of the main GitHub repository. There is still more to document in the wiki soon to understand the features better.

You will need to use Kanso for managing the CouchApp's packages, build, and deployment. It makes it super easy to manage. To install Kanso, just use NPM as follows given that you have NPM and Node.js already installed:

$ sudo npm install -g kanso

In Kanso, Node.js is used for the command-line tools only. The end result is a pure CouchApp you can host using CouchDB alone. Learn more at Kanso.

Now download or clone the Kleks git repo. You can always get a copy of the latest master branch by using:

$ git clone https://github.com/markuso/kleks.git

That will download and create a folder in your current path named kleks. You may change the folder name as you wish.

Deploy To CouchDB (local or cloud)

Kleks has two CouchApps that need to be pushed to your CouchDB. One is _design/admin for the management of content and sites, and one is _design/site which renders sites according to their configurations and domain for the world to see.

When you first setup Kleks, begin with installing dependencies for each CouchApp and pushing to your destination as follows: (assuming your folder is left named kleks)

$ cd ~/path/to/kleks/admin
$ kanso install
$ kanso push

$ cd ~/path/to/kleks/site
$ kanso install
$ kanso push

Once a .kansorc file is created (see below) with a production config setting named live then we can deploy to production using:

$ cd ~/path/to/kleks/admin
$ kanso push live

$ cd ~/path/to/kleks/site
$ kanso push live

Or you can even push to any arbitrary destination if you like:

$ kanso push http://your-couch-server.com/dbname

Example .kansorc File

You should create a .kansorc like the example below. The example assumes your database is name kleks but it could be anything you want, and for your live database it assumes you are hosting it on Cloudant. Be sure to modify by providing your information instead. This file should stay private and is ignored in .gitignore so to not commit it to Git.

exports.env = {
  'default': {
    db: 'http://user:password@localhost:5984/kleks'
  },
  'live': {
    db: 'https://user:[email protected]/kleks',
    baseURL: '/.',
    minify: true
  }
};

Please note that the baseURL: '/.' is needed when deploying a Kanso CouchApp to Cloudant so file references, like js and css files, can work properly.

You will need the same .kansorc file in both locations, .../kleks/admin and .../kleks/site so that when you use kanso push or kanso push live you will be pushing to correct database on your CouchDB (local or cloud).

You can of course add more deployment destinations beyond the default and live destinations you see above. Refer to Kanso documentation on this for more info.

How To Use Kleks

There is still more to document in the wiki soon to understand all the features of Kleks better. There are some features that are hidden and do need documentation to benefit from them until they become part of the UI and easily used.

The wiki will be the next order of focus to create a User Manual essentially.

TODO

  • Deal with large data sets rendering
  • Write as many tests as possible
  • Documentation of all the features of Kleks
  • Possibly rewrite the admin app using AngularJS framework

MIT License

(The MIT License)

Copyright (C) 2012 by Markuso

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kleks's People

Contributors

markuso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kleks's Issues

Fix editing in fullscreen mode on iPad / mobile devices

The content textarea in the fullscreen edit mode is covered by the side nav bar and is not accessible for editing and can't be exited from since the button happens to land underneath that main nav layer. This is most likely a CSS bug on mobile as it does not happen on desktop.

Make admin app support offline and crash recovery

For those people that have a intermittent connection or just want to work offline, it will be cool to have the admin app support offline editing and such. Being on CouchDB, it is possible to use something like PouchDB to accomplish this.

Possibly rewrite the admin app using AngularJS framework

Many improvements could be achieved if the admin app was rewritten in AngularJS so less boilerplate code is needed to bind UI with data and such. This will go nicely with the angular-ui module that could provide some useful interfaces to the app.

Make it easier to insert images into content

Right now, it is possible to insert images into content by formatting the image URL in a certain way. But it would be very helpful and clearer to support it by maybe copying an image embed URL or even auto paste it at the current cursor within the content box.

Renaming the slug of a collection after it has child documents

Because of the way that the collection slug is embed within an document's record, it is hard to rename a collection where the slug needs to be changed too. Each essay that is classified under that collection will need to be visited and the so called collection be selected again as it is considered to be like a new collection with a new slug.

Should either come up with a different way or create a script that goes through the children of a collection to also rename the slugs they are holding of the collection.

Rework the File Upload feature - make clearer

The file upload feature now might be a bit confusing where when you upload a file you must save the record before you can actually use it inside the content. Plus it is not clear that you can double-click on an image to remove it from the attachements of the document, and that with a single-click on an image you are designating that image as the primary one.

Maybe just documenting those facts somewhere around the upload feature is more than enough, but it can surely be clearer.

Deal with large data sets rendering

What is need most likely is a paging system that doesn't pull down large amounts of data at once. This needs some thinking as it effects the current state of lookup search since it uses what is only on the client and in its model collection.

Search can be rebuilt like it is on the website rendering, where it uses Cloudant / CouchDB full-text search instead (and much better).

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.