Browse Source

Protected status. fixes #199

master
Julio Biason 15 years ago
parent
commit
3f49b6149d
  1. 6
      CHEAT-CODES
  2. 4
      mitterlib/network/networkbase.py
  3. 6
      mitterlib/network/twitter.py
  4. 33
      mitterlib/ui/ui_pygtk.py

6
CHEAT-CODES

@ -142,3 +142,9 @@ options:
The character to indicate that a message is marked as favourite. The
defualt value is '☆', which is a filled star. Beware that not
all HTML charcters are accepted.
*protected_char*
The character to indicate that a message is marked as
protected/private. The default value is
"<small>(protected)</small>", which is the string (protected) with a
smaller font. Beware that not all HTML characters are accepted.

4
mitterlib/network/networkbase.py

@ -152,6 +152,9 @@ class NetworkData(object):
merging information from all networks. *Networks should NEVER fill
this field*
**protected**
Boolean indicating if the message is protected/private or not.
.. [*] Not all fields need to be filled if that would require more than
one network call.
.. [*] Interfaces should be aware that optional fields may not be filled.
@ -169,6 +172,7 @@ class NetworkData(object):
self.parent_owner = ''
self.reposted_by = ''
self.network = ''
self.protected = False
class NetworkBase(object):

6
mitterlib/network/twitter.py

@ -122,12 +122,18 @@ class TwitterNetworkData(NetworkData):
"""Class initialization. Receives a dictionary with a single tweet."""
NetworkData.__init__(self)
_log.debug(str(data))
self.id = data['id']
self.name = data['user']['name']
self.username = data['user']['screen_name']
self.avatar = data['user']['profile_image_url']
self.message_time = _to_datetime(data['created_at'])
if 'protected' in data['user']:
# twitter protects all messages from a user, not per message.
self.protected = data['user']['protected']
if 'favorited' in data:
self.favourited = data['favorited']

33
mitterlib/ui/ui_pygtk.py

@ -39,7 +39,6 @@ from mitterlib.ui.helpers import timesince
# Constants
_log = logging.getLogger('ui.pygtk')
URL_RE = re.compile(r'(https?://[^\s\n\r]+)', re.I)
# ----------------------------------------------------------------------
@ -52,14 +51,16 @@ N_ = t.ngettext
# ----------------------------------------------------------------------
# String with the format to the message
# ----------------------------------------------------------------------
MESSAGE_FORMAT = '%(favourite_star)s' \
'<b>%(full_name)s</b> ' \
'<small>(%(username)s' \
'%(message_type)s' \
')</small>:' \
'%(read_status)s\n' \
'%(message)s\n' \
'<small>%(message_age)s</small>'
MESSAGE_FORMAT = ('%(favourite_star)s'
'<b>%(full_name)s</b> '
'<small>(%(username)s'
'%(message_type)s'
')</small>:'
'%(read_status)s '
'%(protected_status)s '
'\n'
'%(message)s\n'
'<small>%(message_age)s</small>')
# ----------------------------------------------------------------------
@ -626,6 +627,12 @@ class Interface(object):
info.append(_(' &#8212; <i>in reply to %s</i>') %
(data.parent_owner))
if data.protected:
message_values['protected_status'] = (
self._options[self.NAMESPACE]['protected_char'])
else:
message_values['protected_status'] = ''
message_values['message_type'] = ''.join(info)
markup = MESSAGE_FORMAT % (message_values)
@ -1570,3 +1577,11 @@ class Interface(object):
metavar='CHAR',
default='&#9734;',
is_cmd_option=False)
options.add_option(
group=self.NAMESPACE,
option='protected_char',
help='String to be used to indicate that a message is ' \
'protected/private.',
metavar='CHAR',
default=_('<small>(protected)</small>'),
is_cmd_option=False)

Loading…
Cancel
Save