Code Monkey home page Code Monkey logo

siteleaf-gem's Introduction

Siteleaf Gem

Installation

The Siteleaf gem is available for installation on Rubygems. To install run:

gem install siteleaf

Testing sites locally

The Siteleaf gem allows you to test and develop your sites locally. If using Pow or Anvil, your local website will be automatically set up and can be accessed at http://yoursite.dev.

(Optional, Mac-only) Install Pow for extra goodness:

curl get.pow.cx | sh

Set up a new site locally:

siteleaf new yoursite.com

This will create a new theme folder called yoursite.com in the directory where you ran this command. It will also create the site for you in your Siteleaf account. If you prefer not to create a new directory, run siteleaf new yoursite.com . instead.

Configure an existing site:

siteleaf config yoursite.com

Your site should now be accessible at http://yoursite.dev.

or

If you don't want to install Pow, local sites can also be manually run:

siteleaf server

In this case, your local site can be accessed at http://localhost:9292.

Lastly...

Your local folder should contain at least one template file (default.html), for sample themes and documentation see: https://github.com/siteleaf/siteleaf-themes

For new sites, you will also need to create at least one page or post on https://manage.siteleaf.com in order to preview.

Download your theme:

To download your theme (or the default theme for new sites) from Siteleaf, run the following command:

siteleaf pull theme

Upload your theme:

To upload your theme to Siteleaf, run the following command:

siteleaf push theme

To switch Siteleaf users or re-authenticate:

siteleaf auth

Using this gem in your application

To use this gem in your application, add the following to your Gemfile:

gem 'siteleaf', :git => 'git://github.com/siteleaf/siteleaf-gem.git'

Using the API

This gem also allows you to interact with the Siteleaf API.

require 'siteleaf'

# authentication
Siteleaf.api_key    = 'KEY'
Siteleaf.api_secret = 'SECRET'

# get authenticated user
me = Siteleaf::User.find('me')

# get all sites
sites = Siteleaf::Site.all

# create new site
site = Siteleaf::Site.create({
  :title    => 'My Website',
  :domain   => 'mywebsite.com'
})

# get site by id
site = Siteleaf::Site.find('5196f137cc8591956b000001')

# update site
site.title = 'New Title'
site.save

# delete site
site.delete

# delete site by id
Siteleaf::Site.delete('5196f137cc8591956b000001')

# get all pages in site
pages = site.pages

# create new page in site
page = Siteleaf::Page.create({
  :site_id  => site.id,
  :title    => 'My Page',
  :body     => 'This is my first page.'
})

# get page by id
page = Siteleaf::Page.find('519719ddcc85910626000001')

# create new post in page
post = Siteleaf::Post.create({
  :parent_id => page.id,
  :title     => 'My Post',
  :body      => 'This is my first post.'
})

# update page, add metadata, add taxonomy
post.title = 'New Title'
post.meta = [ {"key" => "foo", "value" => "bar"} ]
post.taxonomy = [ {"key" => "Tags", "values" => ["One","Two","Three"]} ]
post.save

# upload asset to post (use site_id, page_id, or theme_id to upload to Site, Page, or Theme instead)
asset = Siteleaf::Asset.create({
  :post_id  => post.id, 
  :file     => File.open("~/image.png"), 
  :filename => "image.png"
})

# delete post
post.delete

# delete page by id
Siteleaf::Page.delete('519719ddcc85910626000001')

Troubleshooting

I can't install the Gem

Try running:

sudo gem install siteleaf

Contributing

Help us improve this gem:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

siteleaf-gem's People

Contributors

sskylar avatar sawyerh avatar larryfox avatar davidmerrique avatar devinhalladay avatar

Watchers

Ethan Turkeltaub avatar James Cloos avatar  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.