Browse Source

direct link to messages

master
Julio Biason 15 years ago
parent
commit
751f55b60d
  1. 8
      issues/issue-21bc9efec48c9dec4b4470aed5bedc144abc7f65.yaml
  2. 8
      issues/issue-de26ded9beb48644ce9c18e6cd531333a723b812.yaml
  3. 17
      mitterlib/network/__init__.py
  4. 6
      mitterlib/network/networkbase.py
  5. 5
      mitterlib/network/twitter.py
  6. 22
      mitterlib/ui/ui_pygtk.py

8
issues/issue-21bc9efec48c9dec4b4470aed5bedc144abc7f65.yaml

@ -5,8 +5,8 @@ type: :feature
component: pygtk
release: 1.0.0
reporter: Julio Biason <julio.biason@gmail.com>
status: :unstarted
disposition:
status: :closed
disposition: :fixed
creation_time: 2009-12-21 10:38:11.287314 Z
references: []
@ -16,3 +16,7 @@ log_events:
- Julio Biason <julio.biason@gmail.com>
- created
- ""
- - 2009-12-25 18:59:09.219716 Z
- Julio Biason <julio.biason@gmail.com>
- closed with disposition fixed
- ""

8
issues/issue-de26ded9beb48644ce9c18e6cd531333a723b812.yaml

@ -5,8 +5,8 @@ type: :feature
component: network
release: 1.0.0
reporter: Julio Biason <julio.biason@gmail.com>
status: :unstarted
disposition:
status: :closed
disposition: :fixed
creation_time: 2009-12-22 12:36:09.292341 Z
references:
- pygtk-12
@ -20,3 +20,7 @@ log_events:
- Julio Biason <julio.biason@gmail.com>
- added reference 1
- ""
- - 2009-12-25 18:58:40.275798 Z
- Julio Biason <julio.biason@gmail.com>
- closed with disposition fixed
- ""

17
mitterlib/network/__init__.py

@ -170,6 +170,10 @@ class Networks(object):
results.append(self.networks[shortcut].update(status, reply_to))
return results
def reply_prefix(self, message):
"""Return the prefix to be used in the reply for that message."""
return self.networks[message.network].reply_prefix(message)
def repost(self, message):
"""Repost a message in the user's timeline. The network used is
the same in the message."""
@ -193,6 +197,8 @@ class Networks(object):
def message(self, message_id, network):
"""Return a single NetworkData object for a specified message."""
# TODO: This should probably be named parent() and receive a
# NetworkData. Still returns a single NetworkData object.
if not network in self.networks:
raise NetworksNoSuchNetworkError(network)
@ -200,9 +206,9 @@ class Networks(object):
data.network = network
return data
def reply_prefix(self, message):
"""Return the prefix to be used in the reply for that message."""
return self.networks[message.network].reply_prefix(message)
def link(self, message):
"""Returns a link directly to the message."""
return self.networks[message.network].link(message)
def replies(self, network=None):
"""Return a list of NetworkData objects for the replies for the user
@ -214,11 +220,6 @@ class Networks(object):
result.append(message)
return result
def inbox(self, network=None):
"""Return a list of NetworkData objects for the direct messages/inbox
of the user."""
return []
def available_requests(self, network=None):
"""Return a dictionary with the available requests the user can
make to each network before getting capped."""

6
mitterlib/network/networkbase.py

@ -248,6 +248,12 @@ class NetworkBase(object):
message."""
return None
def link(self, message):
"""Returns a link (as string) to the message in the network site. If
the network doesn't provide a link directly to the message, None shall
be returned. *message* is a :class:`NetworkData` object."""
return None
def replies(self):
"""Return a list of :class:`NetworkData` objects for the replies for
the user messages."""

5
mitterlib/network/twitter.py

@ -352,6 +352,11 @@ class Connection(NetworkBase):
response = self._request('/statuses/show/%d.json' % (message_id))
return TwitterNetworkData(response)
def link(self, message):
"""Return a link directly to the message."""
return 'http://twitter.com/%s/status/%s' % (message.username,
message.id)
def reply_prefix(self, message):
"""Returns the prefix needed for a reply."""
return '@' + message.username + ' '

22
mitterlib/ui/ui_pygtk.py

@ -664,22 +664,26 @@ class Interface(object):
iter = widget.get_model().get_iter(path)
message = widget.get_model().get_value(iter, 0)
popup = gtk.Menu()
items = []
link = self._connection.link(message)
if link:
network = self._connection.name(message.network)
items.append(('Open on %s' % (network), link))
urls = URL_RE.findall(message.message)
if len(urls) == 0:
item = gtk.MenuItem('No URLs in message.')
item.set_property('sensitive', False)
popup.append(item)
popup.show_all()
popup.popup(None, None, None, event.button, event.time)
return True
for url in urls:
if len(url) > 20:
title = url[:20] + '...'
else:
title = url
items.append((title, url))
if len(items) == 0:
return
popup = gtk.Menu()
for url in items:
(title, url) = url
item = gtk.MenuItem(title)
item.connect('activate', self._open_url, url)
popup.append(item)

Loading…
Cancel
Save