Skip to content

Commit

Permalink
feat(package/trend): simple GitHub module results
Browse files Browse the repository at this point in the history
  • Loading branch information
louistiti committed Mar 24, 2019
1 parent 14de24f commit 5baec07
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leon",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "Server, packages and web app of the Leon personal assistant",
"author": {
"name": "Louis Grenard",
Expand Down
9 changes: 6 additions & 3 deletions packages/trend/data/answers/en.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"github": {
"reaching": [
"I'm reaching the GitHub trends..."
"I'm reaching the GitHub trends...",
"I'm finding what's trending on GitHub...",
"Let me find it for you...",
"Let me tell you in a second..."
],
"unreachable": [
"GitHub is unreachable for the moment, please retry later.",
"I'm having difficulties to reach GitHub, please retry later.",
"GitHub seems to be down, please try again later."
],
"test": [
"Here it is: <a href=\"%url%\">%name%</a>"
"simple": [
"%rank%. <a href=\"%repository_url%\" target=\"_blank\">%repository_name%</a> created by <a href=\"%author_url%\" target=\"_blank\">%author_username%</a>."
]
},
"producthunt": {
Expand Down
21 changes: 15 additions & 6 deletions packages/trend/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@ def github(string, entities):
r = utils.http('GET', 'https://github.com/trending')
soup = BeautifulSoup(r.text, features='html.parser')
limit = 5
reponames = soup.select('.repo-list h3', limit=limit)
authornames = ''
elements = soup.select('.repo-list li', limit=limit)
authors = soup.select('.repo-list img')

# print('reponames', reponames)
# print('authornames', authornames)
for i, element in enumerate(elements):
repository = element.h3.get_text(strip=True).replace(' ', '')
author = element.img.get('alt')[1:]

utils.output('inter', 'simple', utils.translate('simple', {
'rank': i + 1,
'repository_url': 'https://github.com/' + repository,
'repository_name': repository,
'author_url': 'https://github.com/' + author,
'author_username': author
}
)
)
except requests.exceptions.RequestException as e:
return utils.output('end', 'unreachable', utils.translate('unreachable'))

utils.output('inter', 'test', utils.translate('test', { 'url': 'https://getleon.ai', 'name': 'getleon.ai' }))

return utils.output('end', 'done')

0 comments on commit 5baec07

Please sign in to comment.