Skip to content

Commit

Permalink
Add download links, fixes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Dec 20, 2016
1 parent 0734992 commit 3247b67
Show file tree
Hide file tree
Showing 162 changed files with 3,164 additions and 2,915 deletions.
4 changes: 4 additions & 0 deletions app/models/repositories/cocoa_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def self.documentation_url(name, version = nil)
"http://cocoadocs.org/docsets/#{name}/#{version}"
end

def self.install_instructions(project, version = nil)
"pod try #{project.name}"
end

def self.project_names
get_json("http://cocoapods.libraries.io/pods.json")
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/repositories/elm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def self.package_link(project, version = nil)
"http://package.elm-lang.org/packages/#{project.name}/#{version || 'latest'}"
end

def self.download_url(name, version = 'master')
"https://github.com/#{name}/archive/#{version}.zip"
end

def self.install_instructions(project, version = nil)
"elm-package install #{project.name} #{version}"
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/repositories/hex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def self.package_link(project, version = nil)
"https://hex.pm/packages/#{project.name}/#{version}"
end

def self.download_url(name, version = nil)
"https://repo.hex.pm/tarballs/#{name}-#{version}.tar"
end

def self.documentation_url(name, version = nil)
"http://hexdocs.pm/#{name}/#{version}"
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/repositories/npm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def self.package_link(project, _version = nil)
"https://www.npmjs.com/package/#{project.name}"
end

def self.download_url(name, version = nil)
"https://registry.npmjs.org/#{name}/-/#{name}-#{version}.tgz"
end

def self.install_instructions(project, version = nil)
"npm install #{project.name}" + (version ? "@#{version}" : "")
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/repositories/nu_get.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def self.package_link(project, version = nil)
"https://www.nuget.org/packages/#{project.name}/#{version}"
end

def self.download_url(name, version = nil)
"https://www.nuget.org/api/v2/package/#{name}/#{version}"
end

def self.install_instructions(project, version = nil)
"Install-Package #{project.name}" + (version ? " -Version #{version}" : "")
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/repositories/pub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def self.package_link(project, _version = nil)
"https://pub.dartlang.org/packages/#{project.name}"
end

def self.download_url(name, version = nil)
"https://storage.googleapis.com/pub.dartlang.org/packages/#{name}-#{version}.tar.gz"
end

def self.documentation_url(name, version = nil)
"http://www.dartdocs.org/documentation/#{name}/#{version}"
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/repositories/wordpress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def self.package_link(project, version = nil)
"https://wordpress.org/plugins/#{project.name}/#{version}"
end

def self.download_url(name, version = nil)
"https://downloads.wordpress.org/plugin/#{name}.#{version}.zip"
end

def self.formatted_name
'WordPress'
end
Expand Down
6 changes: 6 additions & 0 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@
</p>
<% end %>

<% if link = @project.download_url(@version.try(:number)) %>
<p>
Direct download link: <%= link_to truncate(link, length: 70), link %>
</p>
<% end %>

<% if @project.install_instructions(@version.try(:number)).present? %>
<p>
Install:
Expand Down
58 changes: 29 additions & 29 deletions spec/cassettes/API_DocController/GET_/api/renders_successfully.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3247b67

Please sign in to comment.