⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wikiengine.java

📁 wiki建站资源 java编写的 很好用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public String getHTML( WikiContext context, WikiPage page )    {        String pagedata = null;        pagedata = getPureText( page.getName(), page.getVersion() );        String res = textToHTML( context, pagedata );        return res;    }        /**     *  Returns the converted HTML of the page.     *     *  @param page WikiName of the page to convert.     */    public String getHTML( String page )    {        return getHTML( page, WikiPageProvider.LATEST_VERSION );    }    /**     *  Returns the converted HTML of the page's specific version.     *  The version must be a positive integer, otherwise the current     *  version is returned.     *     *  @param pagename WikiName of the page to convert.     *  @param version Version number to fetch     */    public String getHTML( String pagename, int version )    {        WikiPage page = getPage( pagename, version );        WikiContext context = new WikiContext( this,                                               page );        context.setRequestContext( WikiContext.NONE );                String res = getHTML( context, page );        return res;    }    /**     *  Converts raw page data to HTML.     *     *  @param pagedata Raw page data to convert to HTML     */    public String textToHTML( WikiContext context, String pagedata )    {        return textToHTML( context, pagedata, null, null );    }    /**     *  Reads a WikiPageful of data from a String and returns all links     *  internal to this Wiki in a Collection.     */    protected Collection scanWikiLinks( WikiPage page, String pagedata )    {        LinkCollector localCollector = new LinkCollector();                textToHTML( new WikiContext(this,page),                    pagedata,                    localCollector,                    null,                    localCollector,                    false );        return localCollector.getLinks();    }    /**     *  Just convert WikiText to HTML.     */    public String textToHTML( WikiContext context,                               String pagedata,                               StringTransmutator localLinkHook,                              StringTransmutator extLinkHook )    {        return textToHTML( context, pagedata, localLinkHook, extLinkHook, null, true );    }    /**     *  Just convert WikiText to HTML.     */    public String textToHTML( WikiContext context,                               String pagedata,                               StringTransmutator localLinkHook,                              StringTransmutator extLinkHook,                              StringTransmutator attLinkHook )    {        return textToHTML( context, pagedata, localLinkHook, extLinkHook, attLinkHook, true );    }    /**     *  Helper method for doing the HTML translation.     */    private String textToHTML( WikiContext context,                                String pagedata,                                StringTransmutator localLinkHook,                               StringTransmutator extLinkHook,                               StringTransmutator attLinkHook,                               boolean            parseAccessRules )    {        String result = "";        if( pagedata == null )         {            log.error("NULL pagedata to textToHTML()");            return null;        }        TranslatorReader in = null;        Collection links = null;        boolean runFilters = "true".equals(m_variableManager.getValue(context,PROP_RUNFILTERS,"true"));                try        {            if( runFilters )                pagedata = m_filterManager.doPreTranslateFiltering( context, pagedata );            in = new TranslatorReader( context,                                       new StringReader( pagedata ) );            in.addLocalLinkHook( localLinkHook );            in.addExternalLinkHook( extLinkHook );            in.addAttachmentLinkHook( attLinkHook );            if( !parseAccessRules ) in.disableAccessRules();            result = FileUtil.readContents( in );            if( runFilters )                result = m_filterManager.doPostTranslateFiltering( context, result );        }        catch( IOException e )        {            log.error("Failed to scan page data: ", e);        }        catch( FilterException e )        {            // FIXME: Don't yet know what to do        }        finally        {            try            {                if( in  != null ) in.close();            }            catch( Exception e )             {                log.fatal("Closing failed",e);            }        }        return( result );    }    /**     *  Updates all references for the given page.     */    public void updateReferences( WikiPage page )    {        String pageData = getPureText( page.getName(), WikiProvider.LATEST_VERSION );        m_referenceManager.updateReferences( page.getName(),                                             scanWikiLinks( page, pageData ) );    }    /**     *  Writes the WikiText of a page into the     *  page repository.     *     *  @since 2.1.28     *  @param context The current WikiContext     *  @param text    The Wiki markup for the page.     */    public void saveText( WikiContext context, String text )        throws WikiException    {        WikiPage page = context.getPage();        if( page.getAuthor() == null )        {            UserProfile wup = context.getCurrentUser();            if( wup != null ) page.setAuthor( wup.getName() );        }        text = TextUtil.normalizePostData(text);        text = m_filterManager.doPreSaveFiltering( context, text );        // Hook into cross reference collection.                m_pageManager.putPageText( page, text );        m_filterManager.doPostSaveFiltering( context, text );    }    /**     *  Returns the number of pages in this Wiki     */    public int getPageCount()    {        return m_pageManager.getTotalPageCount();    }    /**     *  Returns the provider name     */    public String getCurrentProvider()    {        return m_pageManager.getProvider().getClass().getName();    }    /**     *  return information about current provider.     *  @since 1.6.4     */    public String getCurrentProviderInfo()    {        return m_pageManager.getProviderDescription();    }    /**     *  Returns a Collection of WikiPages, sorted in time     *  order of last change.     */    // FIXME: Should really get a Date object and do proper comparisons.    //        This is terribly wasteful.    public Collection getRecentChanges()    {        try        {            Collection pages = m_pageManager.getAllPages();            Collection  atts = m_attachmentManager.getAllAttachments();            TreeSet sortedPages = new TreeSet( new PageTimeComparator() );            sortedPages.addAll( pages );            sortedPages.addAll( atts );            return sortedPages;        }        catch( ProviderException e )        {            log.error( "Unable to fetch all pages: ",e);            return null;        }    }    /**     *  Parses an incoming search request, then     *  does a search.     *  <P>     *  The query is dependent on the actual chosen search provider - each one of them has     *  a language of its own.     */    //    // FIXME: Should also have attributes attached.    //    public Collection findPages( String query )        throws ProviderException, IOException    {        Collection results = m_searchManager.findPages( query );                return results;    }    /**     *  Return a bunch of information from the web page.     */    public WikiPage getPage( String pagereq )    {        return getPage( pagereq, WikiProvider.LATEST_VERSION );    }    /**     *  Returns specific information about a Wiki page.     *  @since 1.6.7.     */    public WikiPage getPage( String pagereq, int version )    {        try        {            WikiPage p = m_pageManager.getPageInfo( pagereq, version );            if( p == null )            {                p = m_attachmentManager.getAttachmentInfo( (WikiContext)null, pagereq );            }            return p;        }        catch( ProviderException e )        {            log.error( "Unable to fetch page info",e);            return null;        }    }    /**     *  Returns a Collection of WikiPages containing the     *  version history of a page.     */    public List getVersionHistory( String page )    {        List c = null;        try        {            c = m_pageManager.getVersionHistory( page );            if( c == null )            {                c = m_attachmentManager.getVersionHistory( page );            }        }        catch( ProviderException e )        {            log.error("FIXME");        }        return c;    }    /**     *  Returns a diff of two versions of a page.     *     *  @param page Page to return     *  @param version1 Version number of the old page.  If      *         WikiPageProvider.LATEST_VERSION (-1), then uses current page.     *  @param version2 Version number of the new page.  If      *         WikiPageProvider.LATEST_VERSION (-1), then uses current page.     *     *  @return A HTML-ized difference between two pages.  If there is no difference,     *          returns an empty string.     */    public String getDiff( String page, int version1, int version2 )    {        String page1 = getPureText( page, version1 );        String page2 = getPureText( page, version2 );        // Kludge to make diffs for new pages to work this way.        if( version1 == WikiPageProvider.LATEST_VERSION )        {            page1 = "";        }        String diff  = m_differenceManager.makeDiff( page1, page2 );        return diff;    }    /**     *  Returns this object's ReferenceManager.     *  @since 1.6.1     */    // (FIXME: We may want to protect this, though...)    public ReferenceManager getReferenceManager()    {        return m_referenceManager;    }    /**           *  Returns the current plugin manager.     *  @since 1.6.1     */    public PluginManager getPluginManager()    {        return m_pluginManager;    }    public VariableManager getVariableManager()    {        return m_variableManager;    }    /**     *  Shortcut to getVariableManager().getValue(). However, this method does not      *  throw a NoSuchVariableException, but returns null in case the variable does     *  not exist.     *     *  @since 2.2     */    public String getVariable( WikiContext context, String name )    {        try        {            return m_variableManager.getValue( context, name );        }        catch( NoSuchVariableException e )        {            return null;        }    }    /**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -