Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Porkepix
wantzel
Commits
d927a2a1
Commit
d927a2a1
authored
Mar 30, 2016
by
okhin
Browse files
Fix #23 let's truncate the tweet
parent
07f3d342
Changes
1
Hide whitespace changes
Inline
Side-by-side
wantzel.py
View file @
d927a2a1
...
...
@@ -561,9 +561,17 @@ class Wantzel(object):
# lesser than future
if
today
<
entry
.
published_parsed
<
now
:
if
self
.
last_entry_published
<
entry
.
published_parsed
:
# Let's see if we can truncate the lenght of the tweet
# We have 5 chars for the language, so max-length is 135
title
=
entry
.
title
.
encode
(
"utf-8"
)
link
=
entry
.
link
.
encode
(
"utf-8"
)
if
len
(
title
)
+
len
(
link
)
>
135
:
# What is the number of chars we need to remove
excess
=
len
(
title
)
+
len
(
link
)
-
135
title
=
''
.
join
([
title
[:
-
(
excess
+
4
)],
u
' ...'
])
tweet
(
messages
[
"tweet_rp_%s"
%
language
]
%
(
entry
.
title
.
encode
(
"utf-8"
)
,
entry
.
link
.
encode
(
"utf-8"
)
title
,
link
))
Utils
.
debug
(
entry
.
published_parsed
)
Utils
.
debug
(
entry
.
title
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment