Merge lp:~behrooz/gwibber/rtl-support into lp:gwibber

Proposed by Behrooz
Status: Rejected
Rejected by: Ken VanDine
Proposed branch: lp:~behrooz/gwibber/rtl-support
Merge into: lp:gwibber
Diff against target: 95 lines (+39/-0)
3 files modified
gwibber/microblog/dispatcher.py (+29/-0)
ui/templates/base.mako (+4/-0)
ui/templates/css.mako (+6/-0)
To merge this branch: bzr merge lp:~behrooz/gwibber/rtl-support
Reviewer Review Type Date Requested Status
Ken VanDine Disapprove
Review via email: mp+21240@code.launchpad.net

Description of the change

added right to left direction support in core instead of themes

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Sorry this took so long to get reviewed, this no longer applies to trunk.

Thanks for your submission.

review: Disapprove

Unmerged revisions

669. By Behrooz

RTL support in core

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/microblog/dispatcher.py'
2--- gwibber/microblog/dispatcher.py 2010-03-07 04:35:40 +0000
3+++ gwibber/microblog/dispatcher.py 2010-03-12 14:21:27 +0000
4@@ -1,4 +1,5 @@
5 #!/usr/bin/env python
6+# -*- coding: utf-8 -*-
7
8 import multiprocessing, threading, traceback, json, time
9 import gobject, dbus, dbus.service, mx.DateTime
10@@ -13,6 +14,7 @@
11 from util.couch import RecordMonitor
12 from desktopcouch.records.server import CouchDatabase
13 from desktopcouch.records.record import Record as CouchRecord
14+import re
15
16 from util.const import *
17
18@@ -53,6 +55,7 @@
19 args = dict((str(k), v) for k, v in args.items())
20 message_data = PROTOCOLS[account["protocol"]].Client(account)(opname, **args)
21 new_messages = []
22+ text_cleaner = re.compile(u"[: \n\t\r♻♺]+|@[^ ]+|![^ ]+|#[^ ]+") # signs, @nickname, !group, #tag
23
24 for m in message_data:
25 key = (m["id"], m["account"], opname, transient)
26@@ -61,6 +64,7 @@
27 m["operation"] = opname
28 m["stream"] = stream
29 m["transient"] = transient
30+ m["rtl"] = isRTL(re.sub(text_cleaner, "", m["text"].decode('utf-8')))
31
32 log.logger.debug("%s Adding record", logtext)
33 new_messages.append(m)
34@@ -74,6 +78,31 @@
35 log.logger.debug("Traceback:\n%s", traceback.format_exc())
36 return ("Failure", traceback.format_exc())
37
38+def isRTL(s):
39+ """ is given text a RTL content? """
40+ if len(s)==0 :
41+ return False
42+ cc = ord(s[0]) # character code
43+ if cc>=1536 and cc<=1791 : # arabic, persian, ...
44+ return True
45+ if cc>=65136 and cc<=65279 : # arabic peresent 2
46+ return True
47+ if cc>=64336 and cc<=65023 : # arabic peresent 1
48+ return True
49+ if cc>=1424 and cc<=1535 : # hebrew
50+ return True
51+ if cc>=64256 and cc<=64335 : # hebrew peresent
52+ return True
53+ if cc>=1792 and cc<=1871 : # Syriac
54+ return True
55+ if cc>=1920 and cc<=1983 : # Thaana
56+ return True
57+ if cc>=1984 and cc<=2047 : # NKo
58+ return True
59+ if cc>=11568 and cc<=11647 : # Tifinagh
60+ return True
61+ return False
62+
63 class OperationCollector:
64 def __init__(self):
65 self.accounts = CouchDatabase(COUCH_DB_ACCOUNTS, create=True)
66
67=== modified file 'ui/templates/base.mako'
68--- ui/templates/base.mako 2010-02-14 03:59:00 +0000
69+++ ui/templates/base.mako 2010-03-12 14:21:27 +0000
70@@ -132,7 +132,11 @@
71 ${sigil(data)}
72 ${title(data)}
73 <span class="time"> (${timestring(data)})</span><br />
74+ % if data.get("rtl", False):
75+ <span class="text rtl">${data.get('content', '')}</span>
76+ % else:
77 <span class="text">${data.get('content', '')}</span>
78+ % endif
79 </p>
80 </%def>
81
82
83=== modified file 'ui/templates/css.mako'
84--- ui/templates/css.mako 2009-08-16 03:20:57 +0000
85+++ ui/templates/css.mako 2010-03-12 14:21:27 +0000
86@@ -27,3 +27,9 @@
87 .viewmore p {
88 text-align: center;
89 }
90+
91+span.rtl {
92+ text-align: right;
93+ direction: rtl;
94+ display: block;
95+}

Subscribers

People subscribed via source and target branches