•  
      story #7684 access to wiki pages with REST API
    Summary
    phpwiki user
    access to wiki pages with REST API

    I can automate document extraction when building my product

    We need to integrate some wiki pages in batch mode into another portal in order to not duplicate the documentation effort on a project.
    This currently blocks us in authoring further browsable documentation in the codendi wiki, or we may have to duplicate the wiki authoring, which is very unfortunate.

    Add into /v1/projects/:id resources
    
    {
        "type": "phpwiki",
        "uri": "projects/:id/phpwiki"
    }
    
    OPTIONS /v1/projects/:id/phpwiki
    GET /v1/projects/:id/phpwiki
    {
        "pages": [
            {
                "id": 1234,
                "uri": "phpwiki/1234",
                "name": "HomePage",
            },
            {
                "id": 5464,
                "uri": "phpwiki/5464",
                "name": "Some Other Page",
            },
        ]
    }
    WARNING -> This route is paginated
    
    GET /v1/projects/:id/phpwiki?pagename=Some+Other+Page
    {
        "id": 5464,
        "uri": "/wiki/5464",
        "name": "Some Other FPage",
    }
    
    GET /v1/projects/:id/phpwiki?pagename=With
    {  
        "pages": [
          {
            "id": 6100,
            "uri": "phpwiki/6100",
            "name": "With Space"
          },
          {
            "id": 6097,
            "uri": "phpwiki/6097",
            "name": "WithContent"
          }
        ]
    }
    OPTIONS /v1/phpwiki/5464
    GET /v1/phpwiki/5464
    {
        "id": 5464,
        "uri": "/wiki/5464",
        "name": "Some Other Page",
        "last_version": 2,
        "versions": [
            {
                "id": "1",
                "uri": "phpwiki/5464/versions?version_id=1"
            },
            {
                "id": "2",
                "uri": "phpwiki/5464/versions?version_id=2"
            }
        ]
    }
    
    OPTIONS phpwiki/5464/versions?version_id=2
    GET phpwiki/5464/versions?version_id=2

    {

        "id": 5464,
        "uri": "phpwiki/5464/versions?version_id=2",
        "wiki_content": "_My content in italic_",
        "formatted_content": "<div class ....> <i> My content in italic </i> ... </div>"

    }

    In order to have your HTML content, you can simply do a "json_decode" on the formatted content.
    
    Accept: "text/html" GET /wiki/5464/2
    -> returns the content in HTML
    

    WARNING: this route relies on HTTP content negociation (Accept header) to return HTML (instead of param).

    Empty
    Nouha Terzi (terzino), Hanen Ben Elarbi (Hanen)
    Status
    Empty
    Done
    Development
    • [ ] Does it involves User Interface? 
    • [ ] Are there any mockups?
    • [ ] Are permissions checked?
    • [ ] Does it need Javascript development?
    • [ ] Does it need a forge upgrade bucket?
    • [ ] Does it need to execute things in system events?
    • [ ] Does it impact project creation (templates)?
    • [ ] Is it exploratory?
    Empty
    Details
    #7684
    Manuel Vacelet (vaceletm)
    2015-05-26 17:19
    2014-12-11 09:07
    7681

    References

    Follow-ups

    User avatar
    • Acceptance criteria
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thanks @Hanen for your answer.

    Just to keep you informed, we are currently facing a lot of issue regarding the HTML generated content.
    To be simple, PhpWiki does not generate HTML, but some objects that are converted to HTML by the PhpWiki themes ! And requesting a PhpWiki theme outside of Tuleap's PhpWiki scope (REST) is not straightforward and the tool (PhpWiki) is not developed to give some data outside of its scope.

    We will try to find another solution in order to have this HTML content.
    User avatar
    Hello Yannis,

    We would need to have an access to the wiki pages from command line interface.
    We need to integrate some wiki pages in batch mode into another portal in order to not duplicate the documentation effort on a project.
    Thus the requested functionality is to get an HTML interpreted version of a wiki page from the command line


    Best regards,
    Hanen
    User avatar
    last edited by: Yannis ROSSETTO (rossettoy) 2015-05-19 12:07

    Hello STTeam,

    I've got a question about GET wiki/:pageid/version. What kind of content do you want ? Basic content or HTML interpreted content ?

    I ask for this because there is some issues :

    1. We can have HTML interpreted (with a crappy PHPWiki object) only for the page's last version (other version content is linked to PHPWiki theme to retrieve the HTML, whereas last version serialized HTML content is stored in DB)
    2. The HTML have a lot of CSS classes linked to PHPWiki theme. So you will not have the same output as you can see in the screen.

     

    So it's easy for us to give you the content not interpreted, but we are not confident about having HTML result that will be really useful.

     

    In addition of that, to fully understand your needs, can you describe us precisely (step-by-step) what are you doing today manually with these wiki pages that you want to automate with REST ? Because we don't understand what you want to achieve with raw HTML.

    User avatar
    last edited by: Yannis ROSSETTO (rossettoy) 2015-05-15 17:10
    Regarding pages with spaces in name, we propose something with url encode:

    Page = With Space
    curl -XGET "http://sonde.cro.enalean.com/api/v1/projects/255/wiki?pagename=With+Space"
    {
    "pages": [
    {
    "id": 6100,
    "uri": "wiki/6100",
    "name": "With+Space"
    }
    ]
    }

    Example with +

    Page = Page+r
    curl -XGET -"http://sonde.cro.enalean.com/api/v1/projects/255/wiki?pagename=Page%2Br"
    {
    "pages": [
    {
    "id": 6103,
    "uri": "wiki/6103",
    "name": "Page%2Br"
    }
    ]
    }

    Example with no space:

    Page = WithContent
    curl -XGET "http://sonde.cro.enalean.com/api/v1/projects/255/wiki?pagename=WithContent"
    {
    "pages": [
    {
    "id": 6097,
    "uri": "wiki/6097",
    "name": "WithContent"
    }
    ]
    }

    Other question for the version content. Is it OK for you to have something like this ?
    {
    "id": "1",
    "uri": "/wiki/5464/version?id=1"
    "content": "<h1> My content </h1> <p> This is my content <a> with a link </a> </p>"
    }

    The content will contain HTML interpreted version content.
    User avatar
    Hello Yannis,

    1. How to deal with PhpWiki special pages ?
    We have no special recommendation for PhpWiki special pages.
    2. No, we don't need special characters. We want to get a readable page name: "Some/Other/Page" instead of "Some%2FOther%2FPage".
    3. Yes, it's OK.
    4. Yes.

    Best regards,
    Hanen
    User avatar
    Hello ST team,

    I've got few questions:

    * How to deal with PhpWiki special pages ?
    * In your example, you said "Some%2FOther%2FPage". "Some Other Page" is OK for you or your need these '%2F' special characters ?
    * Regarding /wiki/:pageid/ for version, we want to do /wiki/:pageid/version?id=:versionid (in order to match all existing routes behavior). Is it OK for you ?
    * For the route /wiki/:pageid/version?id=:versionid, we want to return something like :

    {
    "id": "1",
    "uri": "/wiki/5464/version?id=1"
    "content": %THE PAGE CONTENT%
    }

    Is it OK ?
    User avatar
    • Acceptance criteria
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes