Skip to content

Commit

Permalink
gw.gd URL shortener
Browse files Browse the repository at this point in the history
  • Loading branch information
claudehohl committed May 8, 2012
1 parent ebae3ba commit 77dca63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
17 changes: 8 additions & 9 deletions htdocs/application/config/stikked.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@
$config['combine_assets'] = false;

/**
* Bit.ly config
* Key for Cron
*
* The username & API-Key for bit.ly
* (get one at: http://bitly.com/a/your_api_key)
* The password required to run the cron job
* Example cron: 00, 30 * * * * curl --silent --compressed http://yoursite.com/cron/key &> /dev/null
*
**/
$config['bitly_username'] = '';
$config['bitly_apikey'] = '';
$config['cron_key'] = '';

/**
* Key for Cron
* gw.gd config
*
* The password required to run the cron job
* Example cron: 00, 30 * * * * curl --silent --compressed http://yoursite.com/cron/key &> /dev/null
* Your own instance of the gw.gd URL-shortener (Download: https://github.com/neofutur/gwgd)
* Default: http://gw.gd/
*
**/
$config['cron_key'] = '';
$config['gwgd_url'] = '';

/**
* Credentials for the backup URL
Expand Down
9 changes: 4 additions & 5 deletions htdocs/application/models/pastes.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,15 @@ function createPaste()
{
$url = site_url('view/' . $data['pid']);
$url = urlencode($url);
$bitly_username = $this->config->item('bitly_username');
$bitly_apikey = $this->config->item('bitly_apikey');
$target = 'http://api.bitly.com/v3/shorten?login=' . $bitly_username . '&apiKey=' . $bitly_apikey . '&longUrl=' . $url;
$config_gwgd_url = $this->config->item('gwgd_url');
$gwgd_url = ($config_gwgd_url ? $config_gwgd_url : 'http://gw.gd/');
$target = $gwgd_url . 'api.php?long=' . $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
curl_close($ch);
$resp = json_decode($resp);
$data['snipurl'] = $resp->data->url;
$data['snipurl'] = $resp;

if (empty($data['snipurl']))
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/application/views/defaults/paste_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<div class="item_group">
<div class="item">
<label for="snipurl">Create a bit.ly url
<label for="snipurl">Create Shorturl
<span class="instruction">Create a shorter url that redirects to your paste?</span>
</label>
<div class="text_beside">
Expand Down

0 comments on commit 77dca63

Please sign in to comment.