Coder Social home page Coder Social logo

gh-trend.py's Introduction

Listing new trending repo on GitHub

gh-trend.py uses GitHub Trend RSS as the data source and lists new trending repos. Each repo will only be listed once in output.

Usage

gh-trend.py [-h] [-j JSON] [-p {today,this-week,this-month} language [language ...]
  • -j is the saved JSON file, which is used to check if a repo has been listed before.
  • -p the trending period, one of today, this-week, or this-month.
  • language, the names of interested languages.

Examples:

$ gh-trend.py -p this-week all python bash
$ gh-trend.py -j $HOME/.gh-trend.json objective-c common-lisp csharp cpp

You may want to check the RSS URLs for correct language names.

Output looks like:

https://github.com/user/repo
Description
(language)

With cron

It could be a nice idea to use with cron, e.g.

@daily      /path/to/gh-trend.py -j /path/to/saved.json               all python bash >> /path/to/output.txt
@weekly     /path/to/gh-trend.py -j /path/to/saved.json -p this-week  all python bash >> /path/to/output.txt
@monthly    /path/to/gh-trend.py -j /path/to/saved.json -p this-month all python bash >> /path/to/output.txt

Your cron's syntax may differ, check with its manual pages.

Converting to HTML

The following AWK code converts the output into simple HTML code:

gh-trend.py [options] | awk "
/^https/ {
  print(\"<a href='\" \$0 \"'>\"\
        gensub(\"https://github.com/\", \"@\", \"\", \$0)\
        \"</a><br/>\");
  next;
}
/^.+$/ {
  print(\"<span>\" \$0 \"</span><br/>\");
  next;
}
/^$/ {
  print(\"<br/>\");
}
" > output.html

Output looks like:

@user/repo
Description
(language)

Where @user/repo is a hyperlink. Note that there is no specification of encoding since it's only a partial HTML, therefore some Unicode characters may not be displayed correct until manually setting the encoding to UTF-8 in web browser.

Or a more complete HTML output:

echo "<html><head><title>gh-trend.py" > output.html
echo -e '</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="background-color:#000;color:#aaa;font-family:Inconsolata;font-weight:bold">\n' >> output.html
gh-trend.py [options] | awk "
/^https/ {
  print(\"<a href='\" \$0 \"' style='color:lawngreen;text-decoration:none'>\"\
        gensub(\"https://github.com/\", \"@\", \"\", \$0)\
        \"</a><br/>\");
  next;
}
/^\(.*\)$/ {
  print(\"<span style='color:lightblue'>\" \$0 \"</span><br/>\");
  next;
}
/^.+$/ {
  print(\"<span style='color:lightgrey'>\" \$0 \"</span> \");
  next;
}
/^$/ {
  print(\"<br/>\");
}
" >> output.html
echo '</body></html>' >> output.html

The output will look like:

gh-trend html

Bugs and Suggestions

The script is very basic, not even any error checking or messages, like for bozo feeds or incorrect language names.

Feel free to comment below, or fork this Gist and notify me with your modifications.

Related Links

License

This project is licensed under the MIT License, see COPYING.

gh-trend.py's People

Contributors

livibetter avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

mikalv hkamran80

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.