             @scope.projectId = data.project
             return data
 
-        promise.then null, =>
+          promise.then null, =>
             @location.path("/project/#{@params.pslug}/wiki/#{@params.slug}/edit")
+
+    loadWiki: ->
+        if @scope.wikiId
+            return @rs.wiki.get(@scope.wikiId).then (wiki) =>
+                @scope.wiki = wiki
+        else
+            return @scope.wiki = {
+                content: ""
+            }
+
+    loadWikiLinks: ->
+        return @rs.wiki.listLinks(@scope.projectId).then (wikiLinks) =>
+            @scope.wikiLinks = wikiLinks
+
+    loadInitialData: ->
+        # Resolve project slug
+        promise = @repo.resolve({pslug: @params.pslug}).then (data) =>
+            @scope.projectId = data.project
+            return data
 
         return promise.then(=> @.loadProject())
                       .then(=> @.loadUsersAndRoles())
                       .then(=> @.loadWikiLinks())
+                      .then(=> @.loadWikiSlug())
                       .then(=> @.loadWiki())
                       .then(=> @.loadAttachments(@scope.wikiId))
 

            @scope.membersById = groupBy(project.memberships, (x) -> x.user)
            return project

    loadWiki: ->
        return @rs.wiki.get(@scope.wikiId).then (wiki) =>
            @scope.wiki = wiki

    loadWikiLinks: ->
        return @rs.wiki.listLinks(@scope.projectId).then (wikiLinks) =>
            @scope.wikiLinks = wikiLinks

    loadInitialData: ->
        params = {
            pslug: @params.pslug
            wikipage: @params.slug

#############################################################################

class WikiEditController extends WikiDetailController
    save: ->
        onSuccess = =>
            @confirm.notify("success")
