Permalink
Browse files

Added webactions

  • Loading branch information...
1 parent 47083d3 commit 4ceb0e7d5a3efb3b68060df28761c56e7e49802d @kylewm committed May 15, 2014
@@ -266,6 +266,10 @@ nav li {
float: right;
}
+.webactions {
+ float: right;
+}
+
form .heading {
width: 150px;
display: inline-block;
@@ -1,6 +1,7 @@
{% if post.like_contexts %}
<div class="like-context">
{% for like in post.like_contexts %}
+
<i class="fa fa-thumbs-up"></i> Liked
<a class="u-like u-like-of" href="{{ like.permalink }}">
{% if like.title or like.content %}
@@ -9,6 +10,7 @@
{{ like.permalink | prettify_url }}
{% endif %}
</a>
+
{% endfor %}
</div>
{% endif %}
@@ -18,6 +18,25 @@
{% endif %}
<a class="u-url" href="{{ post.permalink }}"><time class="dt-published" datetime="{{ post.pub_date | isotime }}">{{ post.pub_date | human_time }}</time></a>
+
{% if post.location %}
-at <a href="http://www.openstreetmap.org/#map=18/{{post.location.latitude}}/{{post.location.longitude}}">{{post.location.name or 'Unnamed place'}}</a>
+at <a class="p-location h-geo" href="http://www.openstreetmap.org/#map=18/{{post.location.latitude}}/{{post.location.longitude}}" title="{{post.location.latitude}},{{post.location.longitude}}">
+ <data class="p-latitude" value="{{post.location.latitude}}"></data>
+ <data class="p-longitude" value="{{post.location.longitude}}"></data>
+ <span class="p-name">
+ {{post.location.name or 'an unnamed location'}}
+ </span>
+</a>
{% endif %}
+
+<div class="webactions">
+ <action do="reply" with="{{post.permalink}}">
+ <a href="https://twitter.com/intent/tweet?in_reply_to={{post.tweet_id}}">reply</a>
+ </action>
+ <action do="repost" with="{{post.permalink}}">
+ <a href="https://twitter.com/intent/retweet?tweet_id={{post.tweet_id}}">retweet</a>
+ </action>
+ <action do="favorite" with="{{post.permalink}}">
+ <a href="https://twitter.com/intent/favorite?tweet_id={{post.tweet_id}}">favorite</a>
+ </action>
+</div>
@@ -45,7 +45,6 @@
{% if current_user.is_anonymous() %}
<form id="indie_auth_form" action="http://indieauth.com/auth" method="get">
<input id="indie_auth_url" type="text" name="me" placeholder="yourdomain.com" />
- <!-- <input id="indie_auth_url" type="hidden" name="me" value="http://kylewm.com"/> -->
<button id="sign_in_button" type="submit">Sign In</button>
<input type="hidden" name="redirect_uri" value="{{ url_for('indieauth', _external=True) }}" />
</form>
@@ -59,6 +58,7 @@
<li><span class="site-name">kylewm.com</span></li>
<li><a href="{{ url_for('index') }}">stream</a></li>
<li><a href="{{ url_for('articles') }}">articles</a></li>
+ <li><a href="{{ url_for('everything') }}">everything</a></li>
<li><a href="{{ url_for('archive') }}">archive</a></li>
</ul>
@@ -28,7 +28,7 @@
<textarea name="preview" id="preview" style="height: 75px; width:100%; background-color: #eeeeff">{% if post.title %}
{{ post.title }} {{ post.permalink }}{% else %}
-{{ post.content | format_markdown_as_text }}{% endif %}
+{{ post.content | format_markdown_as_text(link_twitter_names=False) }}{% endif %}
</textarea><br/>
<span size="8" type="text" name="char_count" id="char_count">&nbsp;</span>
View
@@ -65,11 +65,12 @@ def download_resource(url, path):
LINK_REGEX = r'\b(?<!=.)https?://([a-zA-Z0-9/\.\-_:%?@$#&=]+)'
-def autolink(plain):
+def autolink(plain, twitter_names=True):
plain = re.sub(LINK_REGEX,
r'<a href="\g<0>">\g<1></a>', plain)
- plain = re.sub(TWITTER_USERNAME_REGEX,
- r'<a href="http://twitter.com/\g<1>">\g<0></a>', plain)
+ if twitter_names:
+ plain = re.sub(TWITTER_USERNAME_REGEX,
+ r'<a href="http://twitter.com/\g<1>">\g<0></a>', plain)
return plain
View
@@ -97,6 +97,14 @@ def get_share_preview(self):
@property
@reraise_attribute_errors
+ def tweet_id(self):
+ for url in self.syndication:
+ match = TWITTER_RE.match(url)
+ if match:
+ return match.group(2)
+
+ @property
+ @reraise_attribute_errors
def reply_contexts(self):
if not self.in_reply_to:
return []
@@ -242,7 +250,13 @@ def __init__(self, url):
blob = archiver.load_json_from_archive(url)
if not blob:
return
- self.entry = mf2util.interpret(blob, url)
+
+ try:
+ self.entry = mf2util.interpret(blob, url)
+ except:
+ app.logger.exception('error interpreting {}', url)
+ return
+
if not self.entry:
return
@@ -284,7 +298,12 @@ def __init__(self, post, url):
else:
target_urls = []
- self.entry = mf2util.interpret_comment(blob, url, target_urls)
+ try:
+ self.entry = mf2util.interpret_comment(blob, url, target_urls)
+ except:
+ app.logger.exception('error interpreting {}', url)
+ return
+
if not self.entry:
return
@@ -710,8 +729,8 @@ def bleach_html(html):
@app.template_filter('format_markdown_as_text')
-def format_markdown_as_text(content, remove_imgs=True):
- html = markdown_filter(content)
+def format_markdown_as_text(content, remove_imgs=True, link_twitter_names=True):
+ html = markdown_filter(content, link_twitter_names=link_twitter_names)
return format_as_text(html, remove_imgs)
@@ -734,19 +753,19 @@ def format_as_text(html, remove_imgs=True):
@app.template_filter('markdown')
-def markdown_filter(data):
+def markdown_filter(data, link_twitter_names=True):
from markdown import markdown
from smartypants import smartypants
result = markdown(data, extensions=['codehilite', 'fenced_code'])
- result = util.autolink(result)
+ result = util.autolink(result, twitter_names=link_twitter_names)
result = smartypants(result)
return result
@app.template_filter('autolink')
-def autolink(plain):
- return util.autolink(plain)
+def autolink(plain, twitter_names=True):
+ return util.autolink(plain, twitter_names)
@app.template_filter('prettify_url')

0 comments on commit 4ceb0e7

Please sign in to comment.