Skip to content

Instantly share code, notes, and snippets.

@bsag
Last active December 16, 2015 11:18
Show Gist options
  • Select an option

  • Save bsag/5426377 to your computer and use it in GitHub Desktop.

Select an option

Save bsag/5426377 to your computer and use it in GitHub Desktop.

Revisions

  1. bsag revised this gist Apr 20, 2013. 2 changed files with 8 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ URI.LV checks at regular intervals (about once an hour) to check whether your Oc
    ## Setting up

    1. You need to make a new API app. Go to http://uri.lv/api and select 'New app'. Fill in the relevant details (you can call the app whatever you like) and create it. At the top of the page you'll see your API key and token listed. Make a note of these, because we need to supply them when using the API.
    2. There are various ways to store the API credentials, but I prefer to store them as environment variables in a hidden file in my home directory called `~/.secrets`. See file 'secrets' for details, replacing 'YOURKEYHERE' and 'YOURTOKENHERE' with the actual values of yours, of course. If you add the lines shown below to your `.bashrc` or `.zshrc` then your credentials will be in your environment each time you start your shell. For now run `source ~/.secrets` to set it up. You can check that it worked with the commands `echo $URILV_KEY` and `echo $URILV_TOKEN`, and you should see your key and token printed.
    2. There are various ways to store the API credentials, but I prefer to store them as environment variables in a hidden file in my home directory called `~/.secrets`. See file 'secrets' for details, replacing 'YOURKEYHERE' and 'YOURTOKENHERE' with the actual values of yours, of course. If you add the lines shown in 'zhsrc' below to your `.bashrc` or `.zshrc` then your credentials will be in your environment each time you start your shell. For now run `source ~/.secrets` to set it up. You can check that it worked with the commands `echo $URILV_KEY` and `echo $URILV_TOKEN`, and you should see your key and token printed.
    3. You need to have the gem `httparty` installed to add the following line to your Gemfile, inside the development group: `gem 'httparty'`. Then you should run `bundle install` inside your blog directory to install httparty.
    4. Add lines listed below in the file 'Rakefile' to your Rakefile.

    7 changes: 7 additions & 0 deletions zshrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # use ~/.secrets file to hold secret API keys etc.
    # Put these lines in your .zshrc or .bashrc

    if [[ -a ~/.secrets ]]
    then
    source ~/.secrets
    fi
  2. bsag revised this gist Apr 20, 2013. 1 changed file with 2 additions and 6 deletions.
    8 changes: 2 additions & 6 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -11,12 +11,8 @@ URI.LV checks at regular intervals (about once an hour) to check whether your Oc

    1. You need to make a new API app. Go to http://uri.lv/api and select 'New app'. Fill in the relevant details (you can call the app whatever you like) and create it. At the top of the page you'll see your API key and token listed. Make a note of these, because we need to supply them when using the API.
    2. There are various ways to store the API credentials, but I prefer to store them as environment variables in a hidden file in my home directory called `~/.secrets`. See file 'secrets' for details, replacing 'YOURKEYHERE' and 'YOURTOKENHERE' with the actual values of yours, of course. If you add the lines shown below to your `.bashrc` or `.zshrc` then your credentials will be in your environment each time you start your shell. For now run `source ~/.secrets` to set it up. You can check that it worked with the commands `echo $URILV_KEY` and `echo $URILV_TOKEN`, and you should see your key and token printed.
    3. You need to have the gem `httparty` installed to add the following line to your Gemfile, inside the development group:

    gem 'httparty'

    Then you should run `bundle install` inside your blog directory to install httparty.
    4. Add lines listed below to your Rakefile.
    3. You need to have the gem `httparty` installed to add the following line to your Gemfile, inside the development group: `gem 'httparty'`. Then you should run `bundle install` inside your blog directory to install httparty.
    4. Add lines listed below in the file 'Rakefile' to your Rakefile.

    ## Usage

  3. bsag created this gist Apr 20, 2013.
    23 changes: 23 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # Instructions for setting up Octopress to ping URI.LV

    URI.LV checks at regular intervals (about once an hour) to check whether your Octopress Atom or RSS feed has been updated. However, if you'd like to notify URI.LV _as soon as you publish_, and you have a Premium URI.LV account, you can set up Octopress to ping URI.LV when you deploy.

    ## Requirements

    1. You use Octopress
    2. You use URI.LV to manage your Octopress Atom or RSS feed and have a Premium URI.LV account

    ## Setting up

    1. You need to make a new API app. Go to http://uri.lv/api and select 'New app'. Fill in the relevant details (you can call the app whatever you like) and create it. At the top of the page you'll see your API key and token listed. Make a note of these, because we need to supply them when using the API.
    2. There are various ways to store the API credentials, but I prefer to store them as environment variables in a hidden file in my home directory called `~/.secrets`. See file 'secrets' for details, replacing 'YOURKEYHERE' and 'YOURTOKENHERE' with the actual values of yours, of course. If you add the lines shown below to your `.bashrc` or `.zshrc` then your credentials will be in your environment each time you start your shell. For now run `source ~/.secrets` to set it up. You can check that it worked with the commands `echo $URILV_KEY` and `echo $URILV_TOKEN`, and you should see your key and token printed.
    3. You need to have the gem `httparty` installed to add the following line to your Gemfile, inside the development group:

    gem 'httparty'

    Then you should run `bundle install` inside your blog directory to install httparty.
    4. Add lines listed below to your Rakefile.

    ## Usage

    When you deploy your site, instead of running `rake deploy`, run `rake ping_deploy`. This will first deploy your site by whatever method you usually use (pushing to Github Pages or using rsync) and will then ping URI.LV. If you load the URI for your feed in a browser, you should see that it is immediately updated with your new content. If you want to ping URI.LV separately from deploying, you can just run `rake ping`.
    27 changes: 27 additions & 0 deletions Rakefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    # Insert this code in your Rakefile after the deploy task
    desc "Ping URI.LV to notify about new content"
    task :ping do
    require 'httparty'

    # Ping URI.LV to notify of updated feed
    # Add the URI.LV key and token as environmental variables in your shell
    # via a ~/.secrets file that you source in .bashrc or .zshrc
    # Specify urilv_name (short feed code). When you visit http://uri.lv/admin/feeds
    # this is what is listed in the table under the heading 'Code'
    mykey = ENV['URILV_KEY']
    mytoken = ENV['URILV_TOKEN']
    urilv_name = "yourshortfeedcode" # the short feed code for your feed in URI.LV

    ping = HTTParty.get( 'http://api.uri.lv/feeds/ping.json', {:query => {:key => mykey, :token => mytoken, :feed => urilv_name}} )

    if ping.code == 200
    puts "==> Pinged URI.LV successfully. #{ping['message']}"
    else
    puts "Error: Ping rejected (#{ping.code} - #{ping.message})"
    end

    end

    desc "Ping and deploy"
    task :ping_deploy => [:deploy, :ping] do
    end
    3 changes: 3 additions & 0 deletions secrets
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # URI.LV key and token
    export URILV_KEY='YOURKEYHERE'
    export URILV_TOKEN='YOURTOKENHERE'