当前位置: 首页>>代码示例>>Python>>正文


Python Utils.enhancedLink方法代码示例

本文整理汇总了Python中utils.Utils.enhancedLink方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.enhancedLink方法的具体用法?Python Utils.enhancedLink怎么用?Python Utils.enhancedLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Utils的用法示例。


在下文中一共展示了Utils.enhancedLink方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Bookmark

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import enhancedLink [as 别名]

#.........这里部分代码省略.........
                    if jobj.has_key('url'):
                        url = jobj['url']
                    records.append(Record('bookmark-' + str(count) + ' | ' + jobj['title'] + ' | ' + url + ' | '))
            else :
                if jobj['parentId'] == pid:
                    count += 1
                    html += self.gen_item(rID, divID, count, jobj, True, form_dict['originFileName'], higtLightText=jobj['title'])
                    url = ''
                    if jobj.has_key('url'):
                        url = jobj['url']
                    records.append(Record('bookmark-' + str(count) + ' | ' + jobj['title'] + ' | ' + url + ' | '))

        html += "</ol></div>"

        if count == 0:
            html = ''
        
        total_page = 0;
        if Config.bookmark_output_data_to_new_tab:
            return self.utils.output2Disk(records, 'bookmark', rTitle, Config.bookmark_output_data_format)
        else:
            if len(records) < page_item_count:
                total_page = 1
            elif len(records) % page_item_count == 0:
                total_page = len(records) / page_item_count
            else:
                total_page = len(records) / page_item_count + 1
            print 'currentPage ' + str(currentPage)

            if total_page > 1 and rID.startswith('loop-b') == False:
                if int(currentPage) == 1:
                    html += '<div style="margin-left:auto; text-align:right;margin-top:2px; margin-right:55px;">'

                    html += self.utils.enhancedLink('', '<font size="1">expand</font>', module='bookmark', library=form_dict['originFileName'], rid=form_dict['rID'], script=self.getPageScript(form_dict, 1, nopage=True), ignoreUrl=True)
                    html += '</div>'

                html += '<div style="margin-left:auto; text-align:center;margin-top:2px; margin-right:auto;">'
                for page in range(0, total_page):
                    print (page + 1)

                    if page == 0 and int(currentPage) > 1:
                        html += self.utils.enhancedLink('', '<font size="5">< </font>', module='bookmark', library=form_dict['originFileName'], rid=form_dict['rID'], script=self.getPageScript(form_dict, int(currentPage) - 1), ignoreUrl=True)
                        html += '&nbsp;&nbsp;&nbsp;&nbsp;'

                    if ((page + 1) == int(currentPage)):
                        html += '<font size="5">' + self.utils.enhancedLink('', str(page + 1), module='bookmark', library=form_dict['originFileName'], rid=form_dict['rID'], script=self.getPageScript(form_dict, page + 1), style="color:#00BFFF;", ignoreUrl=True) + '</font> '
                    else:
                        html += self.utils.enhancedLink('', str(page + 1), module='bookmark', library=form_dict['originFileName'], rid=form_dict['rID'], script=self.getPageScript(form_dict, page + 1), ignoreUrl=True) + ' '
                    
                        
                    if page == total_page - 1 and int(currentPage) < total_page:
                        html += '&nbsp;&nbsp;&nbsp;&nbsp;'
                        html += self.utils.enhancedLink('', '<font size="5"> ></font>', module='bookmark', library=form_dict['originFileName'], rid=form_dict['rID'], script=self.getPageScript(form_dict, int(currentPage) + 1), ignoreUrl=True)
            
                html += '</div>'

        if rID.startswith('loop') == False:
            cloudDivID = divID + '-cloud-' + str(random.randint(0, 1000))
            cloudLinkID = divID + '-cloud-a-' + str(random.randint(0, 1000))

            if total_page > 1 and form_dict['column'] != '1':
                html += '<br>'
            html += '<div id="' + cloudDivID + '" class="ref">'
            aCount = 0
            alias = [rTitle] + alias
     
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:69,代码来源:bookmark.py

示例2: History

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import enhancedLink [as 别名]

#.........这里部分代码省略.........

                        #splitNumber = len(rList) / 3
                        splitNumber = 0#len(rList)
                        return self.utils.toListHtml(titleList, urlList, htmlList, descHtmlList=descHtmlList, splitNumber=splitNumber, moreHtml=True, aidList=aidList, refreshIDList=refreshIDList, orginFilename=form_dict['originFileName'])
                    else:
                        html += '<div class="ref"><ol>'
                        for item in rList:
                            title = item.get_title().strip().replace('%20', ' ')
                            count += 1
                            jobj_record = {}
                            jobj_record['id'] = rID + '-' + str(count)
                            jobj_record['title'] = title
                            jobj_record['url'] = item.get_url().strip()
                            jobj_record['count'] = self.getClickCount(item)
                            jobj_record['desc'] = item.get_describe()
                            jobj_record['parentDesc'] = parentDesc
                            #print jobj_record['desc']
                            appendHtml = ''
                            appendFrontHtml = ''
                            if title.lower() != Config.history_quick_access_name.lower():
                                appendFrontHtml = self.utils.genQuickAcessButton(item, 'history', iconType='remark')

                                appendHtml += self.getDeleteButton(divID, historyFile, item.get_url().strip()) + '&nbsp;'
                            else:
                                #appendHtml = self.utils.getIconHtml('', 'quickaccess')
                                appendFrontHtml = self.utils.genQuickAcessButton(item, 'history')

                                appendHtml += self.genQuickAccessSyncButton(rID, quickAccessHistoryFile, divID, objID) + '&nbsp;'
                            #print jobj_record
                            html += self.gen_item(rID, divID, count, jobj_record, Config.more_button_for_history_module, form_dict['fileName'], form_dict['originFileName'], appendFrontHtml='', appendAfterHtml=appendFrontHtml+appendHtml)

                            '''
                            html += '<li><span>' + str(count) + '.</span>'
                            html += '<p>' + self.utils.enhancedLink(item.get_url().strip(), self.utils.formatTitle(title, Config.smart_link_br_len, []), module='history', library=form_dict['originFileName'], rid=rID) + self.utils.getIconHtml(item.get_url().strip())
                            '''

                        html += "</ol></div>"

                return html
            else:
                self.updateHistory()

                if self.needBR():
                    html += '<br>'
                html += '<div class="ref"><ol>'
                count = 0
                item_dict = {}
                for jobj in self.jobj_list:
                    if self.match_item(jobj, [rTitle]) or self.match_item(jobj, alias):
                        if item_dict.has_key(jobj['title'].strip()):
                            continue
                        item_dict[jobj['title'].strip()] = ''
                        count += 1
                        html += self.gen_item(rID, divID, count, jobj, Config.more_button_for_history_module, form_dict['fileName'], form_dict['originFileName'])

                html += "</ol></div>"

                if count == 0:
                    html = ''
                return html

    def gen_item(self, rID, ref_divID, count, jobj, moreOption, fileName, orginFilename, keywords=[], appendFrontHtml='', appendAfterHtml='', parentDesc=''):
        html = ''
        html += '<li><span>' + str(count) + '.</span>'

        url = ''
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:70,代码来源:history.py

示例3: Reference

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import enhancedLink [as 别名]

#.........这里部分代码省略.........
                    link = a['href']
                print a['href']
                if self.passItem(a.text.strip(), link):
                    continue
                title = a.text.strip().encode('utf-8')
                if title == '':
                    title = link.replace('http://', '').replace('www.', '')
                link_dict[link] = link
                link = self.utils.fixUrl(url, link)
                text = title
                if url.find('youtube') != -1 and link.find('watch') != -1:
                    link = 'https://www.youtube.com' + link[link.rfind('/watch') :]
                    if url.find('playlist') == -1:
                        if a.text.find('Duration') != -1:
                            text = self.formatYoutubeLink(a, True).replace(' ', '%20') 
                            title = self.formatYoutubeLink(a, False)
                        else:
                            text = self.utils.removeDoubleSpace(a.text.strip()).replace(' ', '%20')
                        if title.startswith('/watch'):
                            continue
		    elif url.endswith('playlist') == False:
                        if count == 0:
                            return self.getAllLinks(link, ref_divID, rID)
                count += 1
                print str(count) + ' ' + title + ' ' + link
                ref_divID += '-' + str(count)
                linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
                appendID = str(count)
                script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-" + rID.replace(' ', '-') + '-' + str(appendID), text, link, '-', hidenEnginSection=Config.reference_hiden_engin_section) 
		#if a.img != None and a.img['src'].endswith('gif') == False:
		#    html += '<img width="48" height="48" src="' + a.img['src'] + '">'
                html += '<li><span>' + str(count) + '.</span>'
		if title.find('- Duration') != -1:
		    html += '<p>' + self.utils.enhancedLink(link, self.utils.formatTitle(title[0 : title.find('- Duration')], Config.reference_smart_link_br_len), module='reference') + title[title.find('- Duration') :]
                    records.append(self.toRecord('reference-' + str(count), title[0 : title.find('- Duration')], link))
	        else:
                    html += '<p>' + self.utils.enhancedLink(link, self.utils.formatTitle(title, Config.reference_smart_link_br_len), module='reference')
                    records.append(self.toRecord('reference-' + str(count), title, link))

                if script != "":
                    html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False);
                html += '</p></li>'
            html += '</ol></div>'
        if count == 0:
            html = ''
        
        if Config.reference_output_data_to_new_tab:
            return self.utils.output2Disk(records, 'reference', self.form_dict['rTitle'], Config.reference_output_data_format)
        else:
            return html

    def toRecord(self, rid, title, url):
        return Record(rid + ' | ' + title.replace('\n', '') + ' | ' + url + ' | ')

    def isYoutubeRssUrl(self, url):
        return (url.find('user') != -1 or url.find('channel') != -1) and (url.find('playlists') != -1 or url.find('videos') != -1) and url.find('watch') == -1 and url.find('youtube') != -1

    def youtubeRssHtml(self, url, rid, divid):
        if url.find('playlist') != -1:
            return self.genRssHtml(self.helper.getPlaylists(url), rid, divid)
        elif url.find('video') != -1:
            videos = self.helper.getVideos(url)
            return self.genRssHtml(videos, rid, divid)
        return ''

    def genRssHtml(self, data, key, ref_divID):
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:70,代码来源:reference.py

示例4: Filefinder

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import enhancedLink [as 别名]

#.........这里部分代码省略.........
        
        result = []
        for k, v in sorted(fileCountDict2.items(), lambda x, y: cmp(x[1], y[1]), reverse=True) :
            result.append(k)
        result2 = []
        for k, v in fileCountDict3.items():
            result2.append(k)
        return result2 + result




    def genFileList(self, dataList, divID='', rID='', url='', higtLightText=''):
        if len(dataList) == 0:
            return ''
        print 'genFileList ' + ' '.join(dataList)
        #print 'higtLightText:' + higtLightText
        html = ''
        count = 0
        log = True
        if rID.startswith('loop'):
            log = False
        if len(dataList) > 0:
            html = '<div class="ref"><ol>'
            for line in dataList:

                if line != '' and (line.find('exclusive') == -1 or line.find('.') != -1):
                    if url != '' and line.strip().replace(' ', '%20') == url.strip():
                        continue
                    if line.endswith('.DS_Store'):
                        continue
                    count += 1
                    html += '<li><span>' + str(count) + '.</span>'
                    url = line
                    title = line[line.rfind('/') + 1 :].replace("'", ' ').replace('"', '')
       
                    openAllHtml = ''
                    if self.isDir(line):
                        icon = self.utils.getIconHtml('quickaccess')
                        js = ''
                        fileCount = 0
                        for f in self.getMatchFiles('', url=url).split('\n'):
                            if f != '' and os.path.exists(f):
                                fileCount += 1
                                js += "exec('open','','" + f + "');"
                        if fileCount > 0:
                            openAllHtml = ' <font size="1">(</font><font size="1" color="#999966">' + str(fileCount) + '</font><font size="1">)</font> <a target="_blank" href="javascript:void(0);" onclick="' + js + '">' + icon + '</a>'



                    if line.startswith('db/') and (line[0 : len(line) - 1].endswith(str(datetime.date.today().year)[0 : 3]) or line.find('(') != -1):
                        countInfo = ''
                        if line.find('(') != -1:
                            countInfo = '(<font color="red"><b>' + line[line.find('(') + 1 : line.find(')')] + '</b></font>)'
                            line = line[0 : line.find('(')]
                            title = title[0 : title.rfind('(')].strip()
                            if title.find('-library') != -1:
                                title = '<font color="red">' + title + '</font>'

                        url = 'http://' + Config.ip_adress + '/?db=' + line[line.find('/') + 1 : line.rfind('/') + 1] + '&key=' + line[line.rfind('/') + 1 :] 
                        if line.find('paper') != -1:
                            url += '&column=1'
                        else:
                            url += '&column=' + Config.column_num + '&width=' + Config.default_width
                        if self.dbFileArgsDict.has_key(line.strip()):
                            url += '&filter=' + self.dbFileArgsDict[line.strip()]

                        
                        showText = title + countInfo
                        if higtLightText != '':
                            showText = self.utils.doHighLight(title, higtLightText, appendValue=False) + countInfo
                        #print showText
                        html += '<p>' + self.utils.enhancedLink(url, title, module='filefinder', rid=self.form_dict['rID'], library=self.form_dict['originFileName'], showText=showText, log=log) + openAllHtml
                    else:
                        showText = title
                        if higtLightText != '':
                            showText = self.utils.doHighLight(title, higtLightText, appendValue=False)
                        #print showText
                        html += '<p>' + self.utils.enhancedLink(line, title, module='filefinder', rid=self.form_dict['rID'], library=self.form_dict['originFileName'], showText=showText, log=log) + openAllHtml + self.utils.getIconHtml(line)
                    

                            #print js
                    if divID != '':
                        divID += '-' + str(count)
                        linkID = 'a-' + divID[divID.find('-') + 1 :]
                        appendID = str(count)
                        url = url.replace(' ', '#space')
                        script = self.utils.genMoreEnginScript(linkID, divID, "loop-f-" + rID.replace(' ', '-') + '-' + str(appendID) , title, url, '-', hidenEnginSection=Config.bookmark_hiden_engin_section)
                        html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', divID, '', False);


                    html += '</p></li>'
            html += "</ol></div>"
        if count == 0:
            html = ''

        return html

    def check(self, form_dict):
        return True
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:104,代码来源:filefinder.py

示例5: Content

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import enhancedLink [as 别名]

#.........这里部分代码省略.........
            if contentref != None:

                return contentref.strip()
        return ''


    def write(self, html):
        f = open('temp/test.html', 'w')
        for line in html:
            f.write(line)
        #print 'write ' + html + ' to file'
        f.close

    def genContentHtml(self, key, content_divID, defaultLinks, library):
        return self.genMetadataHtml(key, content_divID, defaultLinks, library)

    def genMetadataHtml(self, key, content_divID, defaultLinks, library):
        html = '<div class="ref"><ol>'
        if self.form_dict['column'] == '3' and int(self.form_dict['extension_count']) > 10:
            html = '<div class="ref"><br><ol>'

        count = 0
        #print 'key:' + key
        #print self.datafile_content
        if self.datafile_content.has_key(key):
            self.record_content = self.datafile_content
        elif self.optional_content.has_key(key):
            self.record_content = self.optional_content

        if self.record_content.has_key(key):
            #print key
            for r in self.record_content[key]:
                count += 1
                format_index = ''
                pRecord = None
                pid = r.get_parentid().strip()
                if self.record_content.has_key(pid) and key.find('-') != -1:
                    pRecord = self.record_content[pid] 
		    if content_divID.find(self.data_type) == content_divID.rfind(self.data_type):
                        format_index = str(count)
		    else:
                        format_index = pid[pid.rfind('-') + 1 :] + '.' + str(count)
                elif r.get_id().find('-') != -1:
                    format_index = r.get_id()[r.get_id().rfind('-') + 1 : ].strip()
		while format_index.find('-') != -1:
		    format_index = format_index[format_index.find('-') + 1 :]
                html += '<li><span>' + format_index + '</span>'
                if len(format_index) > 5:
                    html += '</li><br/><li>'
                
                content_divID += '-' + str(count)
                linkID = 'a-' + content_divID[content_divID.find('-') + 1 :]
                title = r.get_title().strip().replace(' ', '%20')
                desc = r.get_describe().strip()
                script = self.utils.genMoreEnginScript(linkID, content_divID, r.get_id().strip(), self.utils.clearHtmlTag(title), r.get_url().strip(), '-', hidenEnginSection=Config.content_hiden_engin_section)
                
                descHtml = ''

                if desc != '':

                    descHtml = self.utils.genDescHtml(desc, Config.course_name_len, self.tag.tag_list, iconKeyword=True, fontScala=1, module='history')
            


                moreHtml = self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', content_divID, '', False, descHtml=descHtml);
                if self.record_content.has_key(r.get_id().strip()) or r.get_url().strip() == '':
                    if r.get_url().strip() != '':
                        html += '<p>' + self.genMetadataLink(r.get_title().strip(), r.get_url().strip())
                    else:
                        html += '<p>' + self.utils.toSmartLink(r.get_title().strip(), 45, module='content', rid=self.form_dict['rID'], library=library)
                    #html += self.utils.getDefaultEnginHtml(title, defaultLinks)
                    if moreHtml != "":
                        html += moreHtml
                    html += '</p>'
                elif r.get_url().strip() != '':
                    html += '<p>' + self.genMetadataLink(r.get_title().strip(), r.get_url().strip())  + moreHtml + '</p>'
                html += '</li>'
        else:
            return ''

        html += "</ol></div>"
        return html


    def genMetadataLink(self, title, url):
        if url.find('[') != -1:
            ft = url.replace('[', '').replace(']', '').strip()
            r = self.utils.getRecord(ft, '','', False, False)
            key = r.get_path()[r.get_path().find(default_subject) + len(default_subject) + 1 :]
            url = 'http://' + Config.ip_adress + '?db=' + default_subject + '/&key=' + key + '&filter=' + ft  + '&desc=true'

        return self.genMetadataLinkEx(title, url)


    def genMetadataLinkEx(self, title, url):
        if title.find('<a>') != -1:
            title = title.replace('<a>', '<a target="_blank" href="' + url + '">')
        else:
            title = self.utils.enhancedLink(url, self.utils.formatTitle(title, 45), module='content', rid=self.form_dict['rID'], library=self.form_dict['originFileName'])
        return title
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:104,代码来源:content.py


注:本文中的utils.Utils.enhancedLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。