示例#1
0
    def refresh(self):
        """@reimp"""
        self.newPostButton.setVisible(bool(self.topicId))
        #self.gameButton.setVisible(bool(self.subjectId))

        host = config.API_HOST  # must be the same as rest.coffee for the same origin policy

        user = dataman.manager().user()

        w = self.webView
        w.setHtml(
            rc.haml_template('haml/reader/topicview').render({
                'host':
                host,
                'locale':
                config.language2htmllocale(user.language),
                'title':
                tr_("Topic"),
                'topicId':
                self.topicId,
                'userName':
                user.name if not user.isGuest() else '',
                'userPassword':
                user.password,
                'rc':
                rc,
                'tr':
                tr_,
            }), host)
        self._injectBeans()
示例#2
0
 def onReload(self):
   """@reimp"""
   dm = dataman.manager()
   user =  dm.queryUser(id=self.userId, name=self.userName)
   if not user:
     growl.notify(my.tr("Unknown user. Please try updating the database."))
     return
   self.userId = user.id
   self.userName = user.name
   av = dm.queryUserAvatarUrl(self.userId, hash=self.userHash, cache=True)
   self.setHtml(rc.haml_template('haml/reader/userview').render({
     'user': user,
     'avatar': av,
     'i18n': i18n,
     'rc': rc,
     'tr': tr_,
     'mytr': mytr_,
   }))
示例#3
0
    def refresh(self):
        """@reimp"""
        games = dataman.manager().getGameInfo()
        #games = sorted(games, reverse=True, key=lambda it:
        #    operator.itemgetter('timestamp'))
        import py
        q = self.q
        q.setHtml(
            rc.haml_template('haml/reader/gameboard').render({
                #'cacher': cacheman.UrlCacher,
                'games': games,
                #'i18n': i18n,
                'rc': rc,
                'py': py,
                'tr': tr_,
            }))

        h = q.page().mainFrame()
        h.addToJavaScriptWindowObject('bean', self.bean)
示例#4
0
    def refresh(self):
        """@reimp"""
        q = self.q
        dm = dataman.manager()
        info = self.gameInfo = dm.queryGameInfo(itemId=self.itemId,
                                                id=self.gameId,
                                                cache=False)
        self._gameBean.info = info
        if info:
            if not self.gameId:
                self.gameId = info.gameId
            if not self.itemId:
                self.itemId = info.itemId

        title = info.title if info else ""
        if not title and self.gameId:
            title = dm.queryGameName(id=self.gameId)

        t = title or tr_("Game")
        if info and info.itemId:
            t += " #%s" % info.itemId
        if info:
            if info.upcoming:
                t += u" (未発売)"
            elif info.recent:
                t += u" (新作)"
        q.setWindowTitle(t)

        icon = info.icon if info else None
        q.setWindowIcon(icon or rc.icon('window-gameview'))

        online = netman.manager().isOnline()
        self.editButton.setEnabled(bool(self.gameId))
        self.launchButton.setEnabled(bool(info and info.local))
        self.browseButton.setEnabled(online and bool(info and info.itemId))
        self.topicButton.setEnabled(online and bool(info and info.itemId))
        self.nameButton.setEnabled(bool(info) and info.hasCharacters())

        # Fake base addr that twitter javascript can access document.cookie
        #baseUrl = ''
        #baseUrl = "http://localhost:6100"
        #baseUrl = "http://www.amazon.co.jp" # cross domain so that amazon iframe works
        #baseUrl = 'qrc://'     # would crash QByteArray when refresh
        #baseUrl = 'qrc://any'  # would crash QByteArray when refresh
        #baseUrl = 'file:///'    # would crash QByteArray when refresh
        #baseUrl = 'file:///any' # any place that is local
        needsPost = info and info.gameItem and (
            info.gameItem.overallScoreCount or info.gameItem.ecchiScoreCount)
        if online and needsPost:
            baseUrl = config.API_HOST  # must be the same as rest.coffee for the same origin policy, but this would break getchu
        else:
            baseUrl = 'qrc:///_'  # any place is fine

        user = dataman.manager().user()

        w = self.webView
        w.setHtml(
            rc.haml_template('haml/reader/gameview').render({
                'host':
                config.API_HOST,
                'userName':
                user.name,
                'userPassword':
                user.password,
                'title':
                title,
                'game':
                info,
                'cache':
                cacheman.CacheJinjaUtil,
                'rc':
                rc,
                'py':
                py,
                'tr':
                tr_,
                'i18n':
                i18n,
                #'jlp': mecabman.manager(), # temporarily disabled
                #'settings', settings.global_(),
                'online':
                online,
                'proxy':
                proxy.manager(),
                'mainland':
                features.MAINLAND_CHINA,
            }),
            baseUrl)

        self._injectBeans()
示例#5
0
def renderAppHelp():
  import rc
  return rc.haml_template('haml/reader/help').render()
示例#6
0
def renderCredits():
  import rc
  return rc.haml_template('haml/reader/credits').render()