# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import re
-import copy
+import codecs
from bbs_type_exception import BbsTypeError
from bbs_type_base import BaseType
+# default name for morningcoffee
+moco_name = u'\u540d\u7121\u3057\u52df\u96c6\u4e2d\u3002\u3002\u3002'
_base_reg_expr = re.compile("http://(?P<host>[^./]+\.2ch\.net)/(?P<board>[^/]+)/$")
_cgi_reg_expr = re.compile("http://(?P<host>[^./]+\.2ch\.net)/test/read.cgi/(?P<board>[^/]+)/(?P<thread>[^/]+)/.*")
_base_reg = _base_reg_expr
_cgi_reg = _cgi_reg_expr
+ def is_same_board(self, another):
+ return self.bbs_type == another.bbs_type \
+ and self.board == another.board
+
+ def set_extra_post(self, post_dict):
+ post_dict["hana"] = "mogera"
+
+ if self.board == "morningcoffee":
+ if "FROM" not in post_dict or not post_dict["FROM"]:
+ post_dict["FROM"] = moco_name.encode("cp932", "replace")
+
+ return post_dict
+
def get_board_dir_path(self):
"""Returns board dir path from logs dir downward, not full path"""
def is_thread(self):
return self.thread
+ def is_same_board(self, another):
+ return self.bbs_type == another.bbs_type \
+ and self.host == another.host \
+ and self.board == another.board
+
def clone_with_thread(self, thread):
if not thread:
raise ValueError, "parameter must not be empty"
return "http://" + self.host + "/test/read.cgi/" + \
self.board + "/" + self.thread + "/"
+ def set_extra_post(self, post_dict):
+ return post_dict
+
def get_board_dir_path(self):
"""Returns board dir path from logs dir downward, not full path"""
self.bbs_type = bbs_type_judge_uri.get_type(uri)
board_data.BoardData.__init__(self, self.bbs_type)
- self.bbs = self.bbs_type.bbs_type
- self.host = self.bbs_type.host
- self.board = self.bbs_type.board
- self.uri = self.bbs_type.uri
glade_path = os.path.join(GLADE_DIR, GLADE_FILENAME)
self.widget_tree = gtk.glade.XML(glade_path)
self.window = self.widget_tree.get_widget("board_window")
- self.window.set_title(self.uri)
+ self.window.set_title(self.bbs_type.uri)
self.treeview = self.widget_tree.get_widget("treeview")
self.treeview.set_model(ThreadListModel())
# nothing to do if thread_uri does not belong to this board.
bbs_type = bbs_type_judge_uri.get_type(thread_uri)
- if bbs_type.bbs_type != self.bbs \
- or bbs_type.board != self.board or not bbs_type.is_thread():
+ if not bbs_type.is_thread() \
+ or not bbs_type.is_same_board(self.bbs_type):
return
thread = bbs_type.thread
self.post_dict["bbs"] = self.bbs_type.board
self.post_dict["key"] = self.bbs_type.thread
self.post_dict["time"] = str(int(time.time()))
- self.post_dict["hana"] = "mogera"
self.post_dict["submit"] = u"\u66f8\u304d\u8fbc\u3080".encode(
"cp932", "replace")
def on_submit_activate(self, widget):
name = self.entry_name.get_text()
- if self.bbs_type.bbs_type == "2ch" \
- and self.bbs_type.board == "morningcoffee" \
- and not name:
- name = u'\u540d\u7121\u3057\u52df\u96c6\u4e2d\u3002\u3002\u3002'
mail = self.entry_mail.get_text()
msg = self.textbuffer.get_text(
self.textbuffer.get_start_iter(), self.textbuffer.get_end_iter())
self.post_dict["mail"] = mail.encode("cp932", "replace")
self.post_dict["MESSAGE"] = msg.encode("cp932", "replace")
+ self.post_dict = self.bbs_type.set_extra_post(self.post_dict)
+
self.do_submit()
def do_submit(self):
if not self.bbs_type.is_thread():
raise bbs_type_exception.BbsTypeError, \
"the uri does not represent thread: " + uri
- self.bbs = self.bbs_type.bbs_type
- self.board = self.bbs_type.board
- self.thread = self.bbs_type.thread
- self.host = self.bbs_type.host
- self.uri = self.bbs_type.uri
self.size = 0
self.num = 0
self.title = ""