Skip to content

Commit

Permalink
Finalizing for v0.2 (fails in readme, example instance, PEP8)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekSuchanek committed Oct 15, 2016
1 parent e7592b2 commit e55e53b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Twitter Wall

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
;[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Version](https://img.shields.io/badge/release-v0.2-orange.svg)


Twitter Wall is simple [Python](https://www.python.org) powered app for
Expand Down Expand Up @@ -52,7 +53,7 @@ API key & secret!

## Usage

First you need config file with your API key & secret (default path is `config/auth.cfg`,
First you need config file with your API key & secret. Default path is `config/auth.cfg`,
can be set different via `--config` option:

```
Expand Down Expand Up @@ -156,10 +157,12 @@ just refresh the page. For each tweet there is button for hide/show details that
consists of entities: hashtags, mentions, links and photos. For nicer photos browsing
is used Lightbox.

_Example_: [mareksuchanek.pythonanywhere.com](http://mareksuchanek.pythonanywhere.com/)

#### Routes

* `/` = landing
* `/u/<query>[/<lang>]` = web interface for requested query in defined language
* `/q/<query>[/<lang>]` = web interface for requested query in defined language
* `/api/<lid>/<query[/<lang>]` = API used by AJAX for loading additional tweets

#### Web launch example
Expand Down Expand Up @@ -189,15 +192,15 @@ python twitterwall web --debug

#### Screenshots

Basic Twitter Wall with "@hroncok" query:
Basic Twitter Wall with **@hroncok** query:

![Basic tweets list with "@hroncok" query](http://marsu.9e.cz/github/twitterwall-basic.png)

Tweets with "#photoshoot" query with one tweet details shown (2 hashtags, 1 mention, 0 links and 1 picture):
Tweets with **#photoshoot** query with one tweet details shown (2 hashtags, 1 mention, 0 links and 1 picture):

![Tweets list with "#photoshoot" query with one tweet details shown ](http://marsu.9e.cz/github/twitterwall-details.png)

Enlarged photo of cat (:smiley_cat:) via [Lightbox](http://lokeshdhakar.com/projects/lightbox2/):
Enlarged photo of cat :smiley_cat: via [Lightbox](http://lokeshdhakar.com/projects/lightbox2/):

![Enlarged photo of cat via Lightbox](http://marsu.9e.cz/github/twitterwall-lightbox.png)

Expand Down
2 changes: 1 addition & 1 deletion twitterwall/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def print_bye(self, text):
@click.group()
@click.option('--config', '-c', default='config/auth.cfg',
type=click.File('r'), help='App config file path.')
@click.version_option(version='0.2', prog_name='TwitterWall')
def twitter_wall(config):
"""Twitter Wall for loading and printing desired tweets"""
global twitter
Expand Down Expand Up @@ -170,7 +171,6 @@ def twitter_wall(config):
help='Max number of followers.')
@click.option('--swag/--no-swag', is_flag=True, default=True,
help='Style (or not) with colors and bold/underline on output.')
@click.version_option(version='0.1.1', prog_name='TwitterWall CLI')
def cli(query, count, interval, lang, no_retweets,
retweets_min, retweets_max, followers_min, followers_max,
author, blocked_author, swag):
Expand Down
7 changes: 5 additions & 2 deletions twitterwall/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<a class="navbar-brand" href="{{ url_for('index') }}">
<img alt="Brand" src="{{ url_for('static', filename='icon.png') }}"> Twitter Wall
</a>
</div>
Expand All @@ -48,7 +48,10 @@
{% block body %}{% endblock %}
</div>
<footer class="footer-sticky">
<p class="text-muted"><a href="http://webdev.fit.cvut.cz/~suchama4/" target="_blank">Marek Suchánek</a> &copy; 2016 | MI-PYT @ FIT CTU</p>
<p class="text-muted">
<a href="http://webdev.fit.cvut.cz/~suchama4/" target="_blank">Marek Suchánek</a> &copy; 2016 |
<a href="https://github.com/cvut/MI-PYT" target="_blank">MI-PYT @ FIT CTU</a>
</p>
</footer>
</main>
<script src="{{ url_for('static', filename='jquery.min.js') }}"></script>
Expand Down
19 changes: 6 additions & 13 deletions twitterwall/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def api(lid, query, lang=''):
if len(tweets) > 0:
lid = tweets[-1]['id']
res = [flask.render_template('tweet.html', tweet=t) for t in tweets]
return json.dumps({'lid':lid, 'tweets': res})
return json.dumps({'lid': lid, 'tweets': res})


@app.template_filter('author_avatar')
Expand Down Expand Up @@ -68,19 +68,13 @@ def hashtag_link(hashtag):


@app.template_filter('media_img')
def media_img(media, author ,id):
def media_img(media, author, id):
img = '<img src="{}" alt="{}" />'.format(
media['media_url'],
media['display_url']
media['media_url'], media['display_url']
)
link = '<a href="{}" target="_blank" ' \
'data-lightbox="{}" data-title="@{} - {}">{}</a>'.format(
media['media_url'],
id,
author,
media['display_url'],
img
)
media['media_url'], id, author, media['display_url'], img)
return jinja2.Markup(link)


Expand All @@ -95,9 +89,7 @@ def enhance_text(tweet):
for i, w in enumerate(words):
if Tweet.is_hashtag(w):
words[i] = '<a href="{}" target="_blank">{}</a>'.format(
'https://twitter.com/hashtag/{}'.format(w[1:]),
w
)
'https://twitter.com/hashtag/{}'.format(w[1:]), w)
elif Tweet.is_mention(w):
words[i] = author_link(w[1:])
elif Tweet.is_hyperref(w):
Expand Down Expand Up @@ -153,6 +145,7 @@ def start_web(debug, count, interval, tw):
app.config['TEMPLATES_AUTO_RELOAD'] = debug
app.run(debug=debug)


if __name__ == '__main__':
authcfg = configparser.ConfigParser()
authcfg.read('config/auth.cfg')
Expand Down

0 comments on commit e55e53b

Please sign in to comment.