An open API service indexing awesome lists of open source software.

https://github.com/baylorrae/gist-php-class

A class that provides an easy interface for embedding and caching gists.
https://github.com/baylorrae/gist-php-class

Last synced: 9 months ago
JSON representation

A class that provides an easy interface for embedding and caching gists.

Awesome Lists containing this project

README

          

# What is the Gist Class [![Build Status](https://secure.travis-ci.org/BaylorRae/Gist-PHP-Class.png?branch=master)](https://travis-ci.org/BaylorRae/Gist-PHP-Class)
The `Gist` class provides an interface for easily

1. Embedding gists
2. Caching gists
3. Adding the gist's source to `` tags in case JS is disabled

## How to Use it

```php
render();
?>
```

# Available Methods

## Gist::__construct

Gist::__construct($gist_id[, $file_name = null[, $cache = true]])

Prepares the class for adding gists to the page

### Parameters


$gist_id
string
The ID of the gist to add



$file_name
string (optional)
Which file to display; if empty it will embed all files



$cache
boolean (optional) (default=true)
Cache the gist source in a file and display it in `<noscript>` tags

## Gist::script\_tag()

Gist::script_tag()

Creates the script tag for embedding gists

### Return

```html

```

## Gist::noscript\_tag()

Gist::noscript_tag()

If caching is enabled then download
and display the gist content in
`` tags

### Return

```html

The source gist

```

## Gist::render()

Create the script and noscript tags
in one go

### Return

```html

The source gist

```

## (private) Gist::download\_raw\_source()

Attempt to download a gist
and cache it into a file

### Return
{null}

## (private) Gist::get\_cache\_name()

Returns the path for where the file
should be cached

### Return

./gists_cache/58abasdf4858asadf58