Skip to content

Commit

Permalink
Fix thumbs for new uploads to private repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver committed Jan 8, 2018
1 parent aa1e75f commit c5ffb18
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@
"contributions": [
"doc"
]
},
{
"login": "Quicksaver",
"name": "Luís Miguel",
"avatar_url": "https://avatars3.githubusercontent.com/u/802086?v=4",
"profile": "https://github.com/Quicksaver",
"contributions": [
"bug",
"code"
]
}
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Netlify CMS
[![All Contributors](https://img.shields.io/badge/all_contributors-56-orange.svg)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-57-orange.svg)](#contributors)
[![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms)

A CMS for static site generators. Give non-technical users a simple way to edit
Expand Down Expand Up @@ -57,6 +57,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
| [<img src="https://avatars1.githubusercontent.com/u/979966?v=4" width="100px;"/><br /><sub><b>Artem Govorov</b></sub>](http://dm.gl)<br /> | [<img src="https://avatars3.githubusercontent.com/u/2683300?v=4" width="100px;"/><br /><sub><b>Cédric Delpoux</b></sub>](http://xuopled.netlify.com/)<br /> | [<img src="https://avatars3.githubusercontent.com/u/83225?v=4" width="100px;"/><br /><sub><b>imorente</b></sub>](https://github.com/imorente)<br /> | [<img src="https://avatars3.githubusercontent.com/u/5230460?v=4" width="100px;"/><br /><sub><b>David Francoeur</b></sub>](http://davidfrancoeur.com)<br /> | [<img src="https://avatars3.githubusercontent.com/u/1954977?v=4" width="100px;"/><br /><sub><b>Rusta</b></sub>](https://github.com/Rusta)<br /> | [<img src="https://avatars1.githubusercontent.com/u/1299786?v=4" width="100px;"/><br /><sub><b>Henrik Lau Eriksson</b></sub>](http://henrik.laueriksson.com)<br /> | [<img src="https://avatars0.githubusercontent.com/u/1294877?v=4" width="100px;"/><br /><sub><b>Kraig Walker</b></sub>](https://www.kraigwalker.com)<br /> |
| [<img src="https://avatars1.githubusercontent.com/u/2994311?v=4" width="100px;"/><br /><sub><b>Rich Cook</b></sub>](http://www.TalesofMurder.com)<br /> | [<img src="https://avatars3.githubusercontent.com/u/1309950?v=4" width="100px;"/><br /><sub><b>Damien Van Der Windt</b></sub>](https://github.com/damienvdw)<br /> | [<img src="https://avatars2.githubusercontent.com/u/1571899?v=4" width="100px;"/><br /><sub><b>Matt Jared</b></sub>](http://mattjared.github.io/)<br /> | [<img src="https://avatars1.githubusercontent.com/u/1100280?v=4" width="100px;"/><br /><sub><b>bruce-one</b></sub>](https://github.com/bruce-one)<br /> | [<img src="https://avatars3.githubusercontent.com/u/103008?v=4" width="100px;"/><br /><sub><b>Frank Taillandier</b></sub>](https://frank.taillandier.me)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=DirtyF "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/2936813?v=4" width="100px;"/><br /><sub><b>Aquib Master</b></sub>](http://aquibm.com/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=aquibm "Code") | [<img src="https://avatars0.githubusercontent.com/u/3147296?v=4" width="100px;"/><br /><sub><b>Eric Jinks</b></sub>](http://ericjinks.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=Jinksi "Code") |
| [<img src="https://avatars3.githubusercontent.com/u/784848?v=4" width="100px;"/><br /><sub><b>Tony Alves</b></sub>](https://github.com/talves)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=talves "Code") | [<img src="https://avatars3.githubusercontent.com/u/782?v=4" width="100px;"/><br /><sub><b>Ernie Bello</b></sub>](http://ern.me)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Aebello "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/6202476?v=4" width="100px;"/><br /><sub><b>Alexander Kushi-Willis</b></sub>](https://ackushiw.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=ackushiw "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/54089?v=4" width="100px;"/><br /><sub><b>Igor Kuznetsov</b></sub>](http://www.igk.ru)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Aigk1972 "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=igk1972 "Code") [🔌](#plugin-igk1972 "Plugin/utility libraries") | [<img src="https://avatars2.githubusercontent.com/u/1312538?v=4" width="100px;"/><br /><sub><b>Tim Erickson</b></sub>](http://neutyp.com)<br />[🎨](#design-neutyp "Design") | [<img src="https://avatars0.githubusercontent.com/u/871552?v=4" width="100px;"/><br /><sub><b>David Jones</b></sub>](http://davidejones.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=davidejones "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/27744332?v=4" width="100px;"/><br /><sub><b>Henrique Cavalieri</b></sub>](https://kaordica.com.br)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=hcavalieri "Documentation") |
| [<img src="https://avatars3.githubusercontent.com/u/802086?v=4" width="100px;"/><br /><sub><b>Luís Miguel</b></sub>](https://github.com/Quicksaver)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
14 changes: 12 additions & 2 deletions src/backends/github/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,18 @@ export default class GitHub {
const response = await this.api.persistFiles(null, [mediaFile], options);
const repo = this.repo || this.getRepoFromResponseUrl(response.url);
const { value, size, path, fileObj } = mediaFile;
const url = `https://raw.githubusercontent.com/${repo}/${this.branch}${path}`;
return { id: response.sha, name: value, size: fileObj.size, url, path: trimStart(path, '/') };
let url = `https://raw.githubusercontent.com/${repo}/${this.branch}${path}`;

// Assets uploaded to private repos will need valid access tokens.
const files = await this.api.listFiles(this.config.get('media_folder'));
for (let file of files) {
if (file.sha === mediaFile.sha) {
url = file.download_url;
break;
}
}

return { id: mediaFile.sha, name: value, size: fileObj.size, url, path: trimStart(path, '/') };
}
catch(error) {
console.error(error);
Expand Down

0 comments on commit c5ffb18

Please sign in to comment.