Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

A way to fetch others readme, without them having to manually do it. #672

Open
NS007-dev opened this issue Aug 31, 2021 · 19 comments
Open
Assignees
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@NS007-dev
Copy link
Member

@schmelto , @Panquesito7 , @AvidCoder101 ,

I think this was mentioned, about having a way for a user to simply give a url, and github automatically fetches their readme data.
I am not sure how yet, but couldn't we use the github rest APIs? this is the link: https://docs.github.com/en/rest/reference/users
If we use the users api, in the link we can access their information, to get their readme. Thanks.

@schmelto
Copy link
Contributor

I thing the API for users don't give back the customized readme.

https://github.com/`username`/`username`/blob/main/README.md

although it could be that the readme is in the master instead of the main branch

to get repo data you could use https://docs.github.com/en/rest/reference/repos but I think you cannot get the readme there either..

@NS007-dev
Copy link
Member Author

Ok, I will try to find another way, thanks

@Panquesito7
Copy link
Member

Panquesito7 commented Aug 31, 2021

We could use the Imgur API for that. For example, the Devicon uses the Imgur API to get screenshots and post them in a comment (check it out today to see it). 🙂

@Panquesito7 Panquesito7 added the enhancement New feature or request label Aug 31, 2021
@schmelto
Copy link
Contributor

schmelto commented Aug 31, 2021

what we could do ist with github actions create automatically a screenshot of the readme.
I found there something https://github.com/marketplace/actions/screenshots-ci-action

@NS007-dev
Copy link
Member Author

Yes, good ideas.

@Panquesito7
Copy link
Member

Panquesito7 commented Aug 31, 2021

I am working on this. Great finding, @schmelto! 🙂

@Panquesito7 Panquesito7 self-assigned this Aug 31, 2021
@NS007-dev
Copy link
Member Author

Thanks all!

@schmelto schmelto added the duplicate This issue or pull request already exists label Aug 31, 2021
@Panquesito7
Copy link
Member

Panquesito7 commented Aug 31, 2021

The GitHub action that @schmelto mentioned is very good; it is what we need. But where is the user going to submit the URL? That's what I've been thinking about. Any ideas? 🤔

@schmelto
Copy link
Contributor

The GitHub action that @schmelto mentioned is very good; it is what we need. But where is the user going to submit the URL? That's what I've been thinking about. Any ideas? 🤔

I suggest using GitHub Issues for that

@gptkrsh
Copy link

gptkrsh commented Sep 30, 2021

The GitHub action that @schmelto mentioned is very good; it is what we need. But where is the user going to submit the URL? That's what I've been thinking about. Any ideas? 🤔

I suggest using GitHub Issues for that

we have github issue forms now... So maybe we can use that to ask for a username a join it with 'github.com/'

@gptkrsh
Copy link

gptkrsh commented Oct 18, 2021

@schmelto I have a solution :) Can I work on it?

async function generateWebsiteScreenshot (url, format = 'jpg') {
  const job = await createCloudconvertJob(url, format)
  const file = await getFileFromCloudconvertJob(job)
  return uploadCaptureToStorage(file)
}

async function createCloudconvertJob (url, format = 'jpg') {
  return cloudConvert.jobs.create({
    tasks: {
      'capture-url': {
        operation: 'capture-website',
        url,
        output_format: format
      },
      'export-my-file': {
        operation: 'export/url',
        input: 'capture-url'
      }
    }
  })
}

async function getFileFromCloudconvertJob (job) {
  job = await cloudConvert.jobs.wait(job.id) // Wait for job completion

  const exportTask = job.tasks.filter(
    task => task.operation === 'export/url' && task.status === 'finished'
  )[0]
  return exportTask.result.files[0]
}

async function uploadCaptureToStorage (file) {
  const temp = fs.createWriteStream('./res/' + file.filename)

  https.get(file.url, async function (response) {
    response.pipe(temp)
  })

  return new Promise((resolve, reject) => {
    temp.on('finish', async () => {
        fs.createReadStream(file.filename)
      await fs.unlink(
        file.filename
      )
      resolve()
    })
    temp.on('error', reject)
  })
}

const profiles = require('./data.json')

profiles.forEach(profile => {
  generateWebsiteScreenshot('https://github.com/' + profile.githubUsername, 'jpg')
})

@gptkrsh
Copy link

gptkrsh commented Oct 20, 2021

@schmelto It would create a png file in 'assets' dir in the repo, is that fine?

@eddiejaoude
Copy link
Member

@krishguptadev it would be better if the binary file could be stored somewhere else? Could it be kept in the issue and we use the image url generated? Not sure if possible to automated it, I do this manually for things at the moment

@gptkrsh
Copy link

gptkrsh commented Nov 28, 2021

@krishguptadev it would be better if the binary file could be stored somewhere else? Could it be kept in the issue and we use the image url generated? Not sure if possible to automated it, I do this manually for things at the moment

The only way is to store the files somewhere that would not change... 😅

@github-actions
Copy link
Contributor

Stale issue message

@gptkrsh
Copy link

gptkrsh commented Jan 28, 2022

What has to be done with this feature since the Nextjs Update?

@eddiejaoude
Copy link
Member

The NextJS upgrade was never completed, but I still think this feature can be added before or after

@stemount
Copy link
Member

@krishguptadev it would be better if the binary file could be stored somewhere else? Could it be kept in the issue and we use the image url generated? Not sure if possible to automated it, I do this manually for things at the moment

Absolutely, jpeg/png binary files should ideally be no way near the repo, unless using Git LFS.

If someone was to clone the repo they may have to also download all these PNG files which would need compression and if they change the Git history still has the previous revision, so it's not a "byte for byte replacement"

@gptkrsh
Copy link

gptkrsh commented May 23, 2022

The NextJS upgrade was never completed, but I still think this feature can be added before or after

It would just result in a mess... What I am thinking is that since it is going to be a nextjs website, we can easily just upload them to the site and create a next API which can queried for data?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants