Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes the extension issue for -t syntax highlighting, and the filename for stdin #95

Closed
wants to merge 2 commits into from

5 participants

@ddd

Its a cheap fix, man, but it does work :)

I tested all these permutations:

cat blah | gist -t rb
gist -t sh blah.rb
rvm info | gist -t sh

Of course if no extension is given, or if there is none on the file, the gist isn't syntax highlighted on GH.
As I said, cheap and dirty but its working.

Deryl R. Dou... added some commits
@solsticedhiver

+1
so much issues with this software that you have to hunt for every PR or commit to get it right :-(

@jgoulah

+1 this works

@goodell

I think a simpler version of this is 8482139

@goodell

nevermind, this doesn't handle your second test case correctly (gist -t sh blah.rb)

@dentarg

+1

@ConradIrwin ConradIrwin closed this pull request from a commit
@ConradIrwin ConradIrwin Merge jist with gist!
After some time as a fork, and a lot of vetting from users, we have
decided to merge the projects together.

The key change is to use OAuth tokens for authentication instead of
requiring you to hard-code your password. Please use `gist --login`
to exchange your username and password for a token.

Close #137  Gist API now requires user-agent be set, and some versions of Net::HTTP don't 3 ↑
Close #136  SSL error (w/ Homebrew & Ruby 2.0.0-p0 from rbenv)
Close #135  Moved authentication over to OAuth tokens. 1 ↑
Close #134  Trying to use gist inside a directory with dashes in the name on a file inside a subdirectory of that results in 422 errors.... 3
Close #133  SSL cert cached in /tmp
Close #132  --open doesn't works
Close #131  Replace slashes with dashes to avoid 422 errors ↑
Close #130  FEATURE: Multiple API Providers 2 ↑
Close #125  Preventing gist from throwing errors when xclip is installed but X11 isn't present (forwarding or otherwise) ↑
Close #120  Add link shortening with --shorten / -s option ↑
Close #118  Use tokens instead of username / password 4
Close #117  Integrate with git.io
Close #116  man page typos & feature request
Close #115  Creating gist failed: 500 Internal Server Error 1
Close #112  Refactor reading from stdin so --type option works 3 ↑
Close #111  Allow gist to work against different githubs 2 ↑
Close #109  fix error on windows. ↑
Close #108  set Content-Type. 5 ↑
Close #107  Add update support. 1 ↑
Close #106  Add anonymous gisting. 1 ↑
Close #103  fix some bugs.  make gist rock in vim/editor via "highlight lines - :!gist" ↑
Close #98  SSL... 23
Close #96  Creating gist failed: 422 Unprocessable Entity 2
Close #95  Fixes the extension issue for -t syntax highlighting, and the filename for stdin 5 ↑
Close #94  show JSON response when create fails ↑
Close #93  use file basename by default 4 ↑
Close #91  Support using an oauth token rather than a username+password 7 ↑
Close #90  3.1.0 fails to authenticate 3
Close #88  Current (3.1.0) no longer respects -t flag 3
Close #85  Copy to clipboard in Windows ↑
Close #84  use oauth now that there are no tokens 14
Close #78  Strip directory from arguments 2
Close #76  Some README.markdown nitpicks...
Close #75  Does not open in browser by default — documentation disagrees 3
Close #74  Set description from CLI (for issue #73) 1 ↑
Close #73  Should be able to set gist description from commandline 1
Close #69  Failed gist creation should raise instead of puts and exit.
Close #67  Use the github api and allow gist url override. 1 ↑
Close #65  Handle lowercased versions of HTTP_PROXY and HTTPS_PROXY. 1 ↑
Close #64  When generating the man page (-m/--man), skip the usage instructions ↑
Close #61  Instructions for setting github.token to a command don't work for me 1
Close #58  support for anonymous gists
Close #53  Add support for GitHub:FI 4
Close #25  Support for updating gists [feature] 1
a05092f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 25, 2012
  1. Cheap fix but, guess what, it works! Once again supports extensions, …

    Deryl R. Doucette authored
    …and again handles when you pass -t
  2. Same fix as 2a13189304a941f16da90662a3c259d67cf0c6b5 - Fixes extensio…

    Deryl R. Doucette authored
    …n issue
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 8 deletions.
  1. +5 −4 gist
  2. +5 −4 lib/gist.rb
View
9 gist
@@ -1137,7 +1137,7 @@ module Gist
def execute(*args)
private_gist = defaults["private"]
gist_filename = nil
- gist_extension = defaults["extension"]
+ @gist_extension = defaults["extension"]
browse_enabled = defaults["browse"]
description = nil
@@ -1151,7 +1151,7 @@ module Gist
t_desc = 'Set syntax highlighting of the Gist by file extension'
opts.on('-t', '--type [EXTENSION]', t_desc) do |extension|
- gist_extension = '.' + extension
+ @gist_extension = '.' + extension
end
opts.on('-d','--description DESCRIPTION', 'Set description of the new gist') do |d|
@@ -1200,7 +1200,7 @@ module Gist
else
input = $stdin.read
- files = [{:input => input, :extension => gist_extension}]
+ files = [{:input => input, :extension => @gist_extension}]
end
url = write(files, private_gist, description)
@@ -1283,7 +1283,8 @@ private
file_data = {}
files.each do |file|
i = i + 1
- filename = file[:filename] ? file[:filename] : "gistfile#{i}"
+ filename = "#{filename}#{file[:extension]}" if file[:extension]
+ filename = file[:filename] ? "#{file[:filename]}#{@gist_extension}" : "gist_content#{i}#{@gist_extension}"
file_data[filename] = {:content => file[:input]}
end
View
9 lib/gist.rb
@@ -43,7 +43,7 @@ module Gist
def execute(*args)
private_gist = defaults["private"]
gist_filename = nil
- gist_extension = defaults["extension"]
+ @gist_extension = defaults["extension"]
browse_enabled = defaults["browse"]
description = nil
@@ -57,7 +57,7 @@ def execute(*args)
t_desc = 'Set syntax highlighting of the Gist by file extension'
opts.on('-t', '--type [EXTENSION]', t_desc) do |extension|
- gist_extension = '.' + extension
+ @gist_extension = '.' + extension
end
opts.on('-d','--description DESCRIPTION', 'Set description of the new gist') do |d|
@@ -110,7 +110,7 @@ def execute(*args)
else
# Read from standard input.
input = $stdin.read
- files = [{:input => input, :extension => gist_extension}]
+ files = [{:input => input, :extension => @gist_extension}]
end
url = write(files, private_gist, description)
@@ -200,7 +200,8 @@ def data(files, private_gist, description)
file_data = {}
files.each do |file|
i = i + 1
- filename = file[:filename] ? file[:filename] : "gistfile#{i}"
+ filename = "#{filename}#{file[:extension]}" if file[:extension]
+ filename = file[:filename] ? "#{file[:filename]}#{@gist_extension}" : "gist_content#{i}#{@gist_extension}"
file_data[filename] = {:content => file[:input]}
end
Something went wrong with that request. Please try again.