Commit 0ba11a07 authored by onny's avatar onny

first commit

parent 7611d0e2
# Github Embed
Plugin that allows you to embed details from github just by pasting in the URL as you would any other embed source. Currently supports:
### Repositories
__https://github.com/leewillis77/wp-github-oembed__
![Sample output for repository](https://raw.github.com/leewillis77/wp-github-oembed/master/screenshot-1.png)
### User profiles
__https://github.com/leewillis77/__
![Sample output for a user](https://raw.github.com/leewillis77/wp-github-oembed/master/screenshot-2.png)
### Milestone summaries
__https://github.com/leewillis77/wp-github-oembed/issues?milestone=1&state=open__
![Sample output for a milestone](https://raw.github.com/leewillis77/wp-github-oembed/master/screenshot-3.png)
### Repository contributors
__https://github.com/leewillis77/wp-github-oembed/graphs/contributors__
![Sample output for a list of contributors](https://raw.github.com/leewillis77/wp-github-oembed/master/screenshot-4.png)
Coming soon:
* Gists...
The plugin provides very basic styling, but adds classes so you can style as you see fit. If anyone has some ideas for a better default stylesheet - pull requests welcome!
lugin that allows you to embed details about a github user, or repo just by pasting in the repo URL as you would any other embed source.
## Installation
1. Upload the plugin to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Paste a Github repo, or user URL into a post, or page
## Frequently Asked Questions
### Can I change the layout?
Not yet, we're hoping to add templating - all contributions welcome!
## Screenshots
## Changelog
- 1.3
- Expire the oEmbed cache daily
- 1.2
- Support for milestone summaries
- Support for contributor lists
- 1.1
- Default CSS and more styling
- 1.0
- First release
.github-embed {
padding: 0.5em 2em 0.5em 4em;
background-color: #fdfdfd;
width: 80%;
margin: auto;
margin-bottom: 1em;
background-image: url('https://github.com/github/media/raw/master/octocats/blacktocat-32.png');
background-repeat: no-repeat;
background-position: 1em 1em;
-webkit-box-shadow: 2px 2px 2px #ddd;
-moz-box-shadow: 2px 2px 2px #ddd;
box-shadow: 2px 2px 2px #ddd;
}
li.github-repo-contributor {
clear: both;
display: block;
}
.github-repo-contributor-avatar {
float: left;
margin-right: 1em;
margin-bottom: 0.5em;
}
\ No newline at end of file
#!/bin/bash
# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn
# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo.
# main config
PLUGINSLUG="github-embed"
CURRENTDIR=`pwd`
MAINFILE="github-embed.php" # this should be the name of your main php file in the wordpress plugin
# git config
GITPATH="$CURRENTDIR" # this file should be in the base of your git repository
# svn config
SVNPATH="/tmp/$PLUGINSLUG" # path to a temp SVN repo. No trailing slash required and don't add trunk.
SVNURL="http://plugins.svn.wordpress.org/github-embed/" # Remote SVN repo on wordpress.org, with no trailing slash
SVNUSER="leewillis77" # your svn username
# Let's begin...
echo ".........................................."
echo
echo "Preparing to deploy wordpress plugin"
echo
echo ".........................................."
echo
# Check version in readme.txt is the same as plugin file after translating both to unix line breaks to work around grep's failure to identify mac line breaks
NEWVERSION1=`grep "^Stable tag:" $GITPATH/readme.txt | awk -F' ' '{print $NF}'`
echo "readme.txt version: $NEWVERSION1"
NEWVERSION2=`grep "^Version:" $GITPATH/$MAINFILE | awk -F' ' '{print $NF}'`
echo "$MAINFILE version: $NEWVERSION2"
if [ "$NEWVERSION1" != "$NEWVERSION2" ]; then echo "Version in readme.txt & $MAINFILE don't match. Exiting...."; exit 1; fi
echo "Versions match in readme.txt and $MAINFILE. Let's proceed..."
if git show-ref --tags --quiet --verify -- "refs/tags/$NEWVERSION1"
then
echo "Version $NEWVERSION1 already exists as git tag. Exiting....";
exit 1;
else
echo "Git version does not exist. Let's proceed..."
fi
cd $GITPATH
echo -e "Enter a commit message for this new version: \c"
read COMMITMSG
git commit -am "$COMMITMSG"
echo "Tagging new version in git"
git tag -a "$NEWVERSION1" -m "Tagging version $NEWVERSION1"
echo "Pushing latest commit to origin, with tags"
git push origin master
git push origin master --tags
echo
echo "Creating local copy of SVN repo ..."
svn co $SVNURL $SVNPATH
echo "Exporting the HEAD of master from git to the trunk of SVN"
git checkout-index -a -f --prefix=$SVNPATH/trunk/
echo "Ignoring github specific files and deployment script"
svn propset svn:ignore "deploy.sh
README.md
.git
.gitignore" "$SVNPATH/trunk/"
echo "Changing directory to SVN and committing to trunk"
cd $SVNPATH/trunk/
# Add all new files that are not set to be ignored
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
svn commit --username=$SVNUSER -m "$COMMITMSG"
echo "Creating new SVN tag & committing it"
cd $SVNPATH
svn copy trunk/ tags/$NEWVERSION1/
cd $SVNPATH/tags/$NEWVERSION1
svn commit --username=$SVNUSER -m "Tagging version $NEWVERSION1"
echo "Removing temporary directory $SVNPATH"
rm -fr $SVNPATH/
echo "*** FIN ***"
\ No newline at end of file
<?php
// 0 - none
define( 'GEDEBUG_NONE', 0 );
// 1 - call logging only
define( 'GEDEBUG_CALL', 1 );
// 2 - calls, and responses
define( 'GEDEBUG_RESP', 2 );
// Selected debug level
define( 'GITHUB_API_LEVEL', GEDEBUG_NONE );
/**
* This class contains all the functions that actually retrieve information from the GitHub API
*/
class github_api {
private $client_id = null;
private $client_secret = null;
/**
* Allow the client ID / secret to be set, and used for subsequent calls
*/
function __construct() {
add_action( 'plugins_loaded', array( $this, 'set_credentials' ) );
add_filter( 'http_request_timeout', array( $this, 'http_request_timeout' ) );
}
/**
* Extend the timeout since API calls can easily exceed 5 seconds
* @param int $seconds The current timeout setting
* @return int The revised timeout setting
*/
function http_request_timeout( $seconds ) {
return $seconds < 25 ? 25 : $seconds;
}
/**
* If you find yourself hitting rate limits, then you can register an application
* with GitHub(http://developer.github.com/v3/oauth/) use the filters here to
* provide the credentials.
*/
public function set_credentials() {
$this->client_id = apply_filters( 'github-embed-client-id', $this->client_id );
$this->client_secret = apply_filters( 'github-embed-client-secret', $this->client_id );
}
private function call_api( $url ) {
// Allow users to supply auth details to enable a higher rate limit
if ( ! empty( $this->client_id ) && ! empty( $this->client_secret ) ) {
$url = add_query_arg(
array(
'client_id' => $this->client_id,
'client_secret' => $this->client_secret ),
$url
);
}
$args = array( 'user-agent' => 'WordPress Github oEmbed plugin - https://github.com/leewillis77/wp-github-oembed');
$this->log( __FUNCTION__." : $url", GEDEBUG_CALL );
$results = wp_remote_get( $url, $args );
$this->log( __FUNCTION__ . " : " . print_r( $results,1 ), GEDEBUG_RESP );
if( is_wp_error( $results ) ||
! isset( $results['response']['code'] ) ||
$results['response']['code'] != '200' ) {
header( 'HTTP/1.0 404 Not Found' );
die( 'Octocat is lost, and afraid' );
}
return $results;
}
/**
* Get a repository from the GitHub API
* @param string $owner The repository's owner
* @param string $repository The respository name
* @return object The response from the GitHub API
*/
public function get_repo( $owner, $repository ) {
$this->log( "get_repo( $owner, $repository )", GEDEBUG_CALL );
$owner = trim( $owner, '/' );
$repository = trim( $repository, '/' );
$results = $this->call_api( "https://api.github.com/repos/$owner/$repository" );
return json_decode( $results['body'] );
}
/**
* Get commit information for a repository from the GitHub API
* @param string $owner The repository's owner
* @param string $repository The respository name
* @return object The response from the GitHub API
*/
public function get_repo_commits( $owner, $repository ) {
$this->log( "get_repo_commits( $owner, $repository )", GEDEBUG_CALL );
$owner = trim( $owner, '/' );
$repository = trim( $repository, '/' );
$results = $this->call_api( "https://api.github.com/repos/$owner/$repository/commits" );
return json_decode( $results['body'] );
}
/**
* Get a milestone summary from the GitHub API
* @param string $owner The repository's owner
* @param string $repository The respository name
* @param string $milestone The milestone ID
* @return object The response from the GitHub API
*/
public function get_repo_milestone_summary( $owner, $repository, $milestone ) {
$this->log( "get_repo_milestone_summary( $owner, $repository, $milestone )", GEDEBUG_CALL );
$owner = trim( $owner, '/' );
$repo = trim( $repo, '/' );
$results = $this->call_api( "https://api.github.com/repos/$owner/$repository/milestones/$milestone" );
return json_decode( $results['body'] );
}
public function get_repo_contributors( $owner, $repository ) {
$this->log( "get_repo_contributors( $owner, $repository )", GEDEBUG_CALL );
$owner = trim( $owner, '/' );
$repo = trim( $repository, '/' );
$results = $this->call_api( "https://api.github.com/repos/$owner/$repository/stats/contributors" );
return json_decode( $results['body'] );
}
/**
* Get a user from the GitHub API
* @param string $user The username
* @return object The response from the GitHub API
*/
public function get_user( $user ) {
$this->log( "get_user( $user )", GEDEBUG_CALL );
$user = trim( $user, '/' );
$results = $this->call_api( "https://api.github.com/users/$user" );
return json_decode( $results['body'] );
}
private function log( $msg, $level ) {
if ( GITHUB_API_LEVEL >= $level ) {
error_log( "[GE$level]: ".$msg );
}
}
}
This diff is collapsed.
=== Github Embed ===
Contributors: leewillis77
Donate link: http://www.leewillis.co.uk/wordpress-plugins/?utm_source=wordpress&utm_medium=www&utm_campaign=github-embed
Tags: github, embed, oembed
Requires at least: 3.5
Tested up to: 3.5.1
Stable tag: 1.3
== Description ==
Plugin that allows you to embed details from github just by pasting in the URL as you would any other embed source. Currently supports:
* Repositories
* User profiles
* Project milestone summaries
* Project contributors
Coming soon:
* Gists...
The plugin provides very basic styling, but adds classes so you can style as you see fit. If anyone has some ideas for a better default stylesheet - pull requests welcome!
The main development is all going on on [GitHub](https://github.com/leewillis77/wp-github-oembed).
== Installation ==
1. Upload the plugin to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Paste a Github repo, or user URL into a post, or page
== Frequently Asked Questions ==
= Can I change the layout? =
Not yet, we're hoping to add templating - [all contributions welcome](https://github.com/leewillis77/wp-github-oembed)!
== Screenshots ==
1. GitHub Repository
2. GitHub user profile
3. Project milestone summaries
4. Project contributors
== Changelog ==
= 1.3 =
* Expire the oEmbed cache daily
= 1.2 =
* Split API calls into separate class
* Implement milestone summaries
* Implement contributor lists
= 1.1 =
* Default CSS and more styling
= 1.0 =
* First release
\ No newline at end of file
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
]
}
{
"auto_complete":
{
"selected_items":
[
[
"bo",
"book_result forflow"
],
[
"md",
"md5sum"
],
[
"lib",
"libgen_fileupload function"
],
[
"sea",
"search_results_table statement"
],
[
"Meta",
"Meta"
],
[
"libgen",
"libgen_search function"
],
[
"search_re",
"search_response_table statement"
],
[
"get_",
"get_metadata function"
],
[
"media_",
"media_contentsize"
],
[
"medi",
"media_contentsize statement"
],
[
"soundc",
"soundcloud_artworkurl statement"
],
[
"soun",
"soundcloud_artworkurl statement"
],
[
"sou",
"soundcloud_userid_meta statement"
],
[
"sound",
"soundcloud_userid statement"
],
[
"soud",
"soundcloud_userid_soup statement"
],
[
"str",
"stream_url"
],
[
"error",
"error_message"
],
[
"ebay",
"ebaykleinanzeigen"
],
[
"pub",
"published_parsed"
],
[
"ard",
"ardmediathek_getmedia"
]
]
},
"buffers":
[
{
"file": "/home/onny/todo",
"settings":
{
"buffer_size": 49347,
"line_ending": "Unix"
}
}
],
"build_system": "Packages/Python/Python.sublime-build",
"command_palette":
{
"height": 72.0,
"selected_items":
[
[
"package inst",
"Package Control: Install Package"
],
[
"git add",
"Git: Quick Add"
],
[
"git push",
"Git: Push"
],
[
"git commi",
"Git: Commit"
],
[
"git commit",
"Git: Amend Commit"
],
[
"git ini",
"Git: Init"
],
[
"Package Control: Install Package",
"Package Control: Install Package"
]
],
"width": 449.0
},
"console":
{
"height": 243.0,
"history":
[
"amazon_search(\"test\")",
"import libgenutils",
"from libgenutils import amazon_search",
"print(\"test\")",
"import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) "
]
},
"distraction_free":
{
"menu_visible": true,
"show_minimap": false,
"show_open_files": false,
"show_tabs": false,
"side_bar_visible": false,
"status_bar_visible": false
},
"file_history":
[
"/home/onny/projects/wp-gitlab-embed/gitlab-embed.php",
"/home/onny/projects/wp-gitlab-embed/css/gitlab-embed.css",
"/home/onny/projects/wp-gitlab-embed/gitlab-api.php",
"/home/onny/server/python-telefonhack/main.py",
"/home/onny/server/python-telefonhack/functions.py",
"/home/onny/projects/py-libgenupload/test.html",
"/home/onny/projects/py-libgenupload/test.py",
"/var/www/feeds/testapp.py",
"/var/www/feeds/test.py",
"/var/www/feeds/test_working.py",
"/var/www/feeds/plugins/owncloudapps.py",
"/var/www/feeds/plugins/kitmarkt.py",
"/var/www/feeds/plugins/ardmediathek.py",
"/var/www/feeds/plugins/quoka_test.py",
"/var/www/feeds/plugins/studentenwerk.py",
"/var/www/feeds/plugins/ebaykleinanzeigen.py",
"/var/www/feeds/feeds.py",
"/var/www/feeds/plugins/artemediathek.py",
"/var/www/feeds/plugins/feeds.py",
"/var/www/feeds/ebaykleinanzeigen/ebaykleinanzeigen.py",
"/var/www/feeds/studentenwerk/studentenwerk.py",
"/var/www/feeds/owncloud-apps/owncloud-apps.py",
"/var/www/feeds/kitmarkt/kitmarkt.py",
"/var/www/feeds/ardmediathek/ardmediathek.py",
"/var/www/feeds/owncloud-apps/.owncloud-apps.py.swp",
"/var/www/feeds/ardmediathek/.ardmediathek.py.swp",
"/var/www/feeds/zapp/zapp.py",
"/home/onny/projects/py-pkgcheck/pkgcheck-main.py",
"/home/onny/projects/django-test/tango_with_django_project/templates/rango/about.html",
"/home/onny/projects/django-test/tango_with_django_project/static/test.txt",
"/home/onny/projects/django-test/tango_with_django_project/templates/rango/index.html",
"/home/onny/projects/django-test/tango_with_django_project/rango/admin.py",
"/home/onny/projects/django-test/tango_with_django_project/rango/tests.py"
],
"find":
{
"height": 34.0
},
"find_in_files":
{
"height": 0.0,
"where_history":
[
]
},
"find_state":
{
"case_sensitive": false,
"find_history":
[
"github",
"github_embed_cron",
"github-embed",
"gitlab",
"github-embed",
"''})\n",
"= \"broken\"",
"broken",
"skip",
"re.",
"compile",
"metad",
"fixme",
"strip",
"test.html",
"book",
"re.",
"text",
"epub",
"postdata",
"md5sum",
"uri",
"re.",
"ardmediathek_json",
"ardmediathek",
"twitter",
"ardmediathek",
"()\n",
"5",
"print",
"re.",
"re",
"count",
"image",
"uri",
"maxent",
"minPrice=",
"app",
"request",
"os",
"app",
" \n",
"datetime",
"datetim",
"sys",
"print",
"description",
"os",
"id",
"publish",
"search",
"STATIC",
"template"
],
"highlight": true,
"in_selection": false,
"preserve_case": false,
"regex": false,
"replace_history":
[
],
"reverse": false,
"show_context": true,
"use_buffer2": true,
"whole_word": false,
"wrap": true
},
"groups":
[
{
"selected": 0,
"sheets":
[
{
"buffer": 0,
"file": "/home/onny/todo",
"semi_transient": false,
"settings":
{
"buffer_size": 49347,
"regions":
{
},
"selection":
[
[
15066,
15066
]
],
"settings":
{
"syntax": "Packages/Text/Plain text.tmLanguage",
"translate_tabs_to_spaces": false
},
"translation.x": 0.0,
"translation.y": 4426.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
}
]
}
],
"incremental_find":
{
"height": 23.0