diff --git a/README.md b/README.md index 57e2fa23..c4b6c3f6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Documize Community Edition -Modern Wiki + Docs integrating data from SaaS tools. +The Document IDE for wikis and documents. ![Alt text](screenshot.png "Documize") @@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li ## Latest version -v0.30.0 +v0.31.0 ## OS Support diff --git a/app/app/components/document/document-tab.js b/app/app/components/document/document-tab.js index d8789c17..cecbc867 100644 --- a/app/app/components/document/document-tab.js +++ b/app/app/components/document/document-tab.js @@ -17,6 +17,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { viewMode: true, editMode: false, + didReceiveAttrs(){ + if (this.get('mode') === 'edit') { + this.send('onEdit'); + } + }, + actions: { onEdit() { this.set('viewMode', false); diff --git a/app/app/components/section/github/type-editor.js b/app/app/components/section/github/type-editor.js index 1402c23d..3d665b7d 100644 --- a/app/app/components/section/github/type-editor.js +++ b/app/app/components/section/github/type-editor.js @@ -28,69 +28,67 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, if (is.undefined(this.get('config.clientId')) || is.undefined(this.get('config.callbackUrl'))) { self.get('sectionService').fetch(page, "config", {}) - .then(function (cfg) { - let config = {}; + .then(function (cfg) { + let config = {}; - config = { - clientId: cfg.clientID, - callbackUrl: cfg.authorizationCallbackURL, - owner: null, - owner_name: "", - lists: [], - branchSince: "", - branchLines: "100", - userId: "", - pageId: page.get('id'), - showMilestones: false, - showIssues: false, - showCommits: false, - }; + config = { + clientId: cfg.clientID, + callbackUrl: cfg.authorizationCallbackURL, + owner: null, + owner_name: "", + lists: [], + branchSince: "", + branchLines: "100", + userId: "", + pageId: page.get('id'), + showMilestones: false, + showIssues: false, + showCommits: false, + }; - try { - let metaConfig = JSON.parse(self.get('meta.config')); - config.owner = metaConfig.owner; - config.lists = metaConfig.lists; - config.branchSince = metaConfig.branchSince; - config.userId = metaConfig.userId; - config.pageId = metaConfig.pageId; - config.showMilestones = metaConfig.showMilestones; - config.showIssues = metaConfig.showIssues; - config.showCommits = metaConfig.showCommits; - } catch (e) {} + try { + let metaConfig = JSON.parse(self.get('meta.config')); + config.owner = metaConfig.owner; + config.lists = metaConfig.lists; + config.branchSince = metaConfig.branchSince; + config.userId = metaConfig.userId; + config.pageId = metaConfig.pageId; + config.showMilestones = metaConfig.showMilestones; + config.showIssues = metaConfig.showIssues; + config.showCommits = metaConfig.showCommits; + } catch (e) {} - self.set('config', config); - self.set('config.pageId', page.get('id')); + self.set('config', config); + self.set('config.pageId', page.get('id')); - // On auth callback capture code - let code = window.location.search; + // On auth callback capture code + let code = window.location.search; - if (is.not.undefined(code) && is.not.null(code) && is.not.empty(code) && code !== "") { - let tok = code.replace("?code=", ""); - self.get('sectionService').fetch(page, "saveSecret", { "token": tok }) - .then(function () { - console.log("github auth code saved to db"); - self.send('authStage2'); - }, function (error) { //jshint ignore: line - console.log(error); - self.send('auth'); - }); - } else { - if (config.userId !== self.get("session.session.authenticated.user.id")) { - console.log("github auth wrong user ID, switching"); - self.set('config.userId', self.get("session.session.authenticated.user.id")); - } - self.get('sectionService').fetch(page, "checkAuth", self.get('config')) - .then(function () { - console.log("github auth code valid"); - self.send('authStage2'); - }, function (error) { //jshint ignore: line - console.log(error); - self.send('auth'); // require auth if the db token is invalid - }); + if (is.not.undefined(code) && is.not.null(code) && is.not.empty(code) && code !== "") { + let tok = code.replace("?mode=edit&code=", ""); + self.get('sectionService').fetch(page, "saveSecret", { "token": tok }) + .then(function () { + self.send('authStage2'); + }, function (error) { //jshint ignore: line + console.log(error); + self.send('auth'); + }); + } else { + if (config.userId !== self.get("session.session.authenticated.user.id")) { + console.log("github auth wrong user ID, switching"); + self.set('config.userId', self.get("session.session.authenticated.user.id")); } - }, function (error) { //jshint ignore: line - console.log(error); - }); + self.get('sectionService').fetch(page, "checkAuth", self.get('config')) + .then(function () { + self.send('authStage2'); + }, function (error) { //jshint ignore: line + console.log(error); + self.send('auth'); // require auth if the db token is invalid + }); + } + }, function (error) { //jshint ignore: line + console.log(error); + }); } }, @@ -132,41 +130,41 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let page = this.get('page'); this.get('sectionService').fetch(page, "orgrepos", self.get('config')) - .then(function (lists) { - let savedLists = self.get('config.lists'); - if (savedLists === null) { - savedLists = []; - } + .then(function (lists) { + let savedLists = self.get('config.lists'); + if (savedLists === null) { + savedLists = []; + } - if (lists.length > 0) { - let noIncluded = true; + if (lists.length > 0) { + let noIncluded = true; - lists.forEach(function (list) { - let included = false; - var saved; - if (is.not.undefined(savedLists)) { - saved = savedLists.findBy("id", list.id); - } - if (is.not.undefined(saved)) { - included = saved.included; - noIncluded = false; - } - list.included = included; - }); - - if (noIncluded) { - lists[0].included = true; // make the first entry the default + lists.forEach(function (list) { + let included = false; + var saved; + if (is.not.undefined(savedLists)) { + saved = savedLists.findBy("id", list.id); } - } + if (is.not.undefined(saved)) { + included = saved.included; + noIncluded = false; + } + list.included = included; + }); - self.set('config.lists', lists); - self.set('busy', false); - }, function (error) { //jshint ignore: line - self.set('busy', false); - self.set('authenticated', false); - self.showNotification("Unable to fetch repositories"); - console.log(error); - }); + if (noIncluded) { + lists[0].included = true; // make the first entry the default + } + } + + self.set('config.lists', lists); + self.set('busy', false); + }, function (error) { //jshint ignore: line + self.set('busy', false); + self.set('authenticated', false); + self.showNotification("Unable to fetch repositories"); + console.log(error); + }); }, actions: { @@ -212,11 +210,12 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let self = this; self.set('busy', true); self.set('authenticated', false); + let target = "https://github.com/login/oauth/authorize?client_id=" + self.get('config.clientId') + "&scope=repo&redirect_uri=" + encodeURIComponent(self.get('config.callbackUrl')) + "&state=" + encodeURIComponent(window.location.href); - window.location.href = target; + window.location.href = target; }, onOwnerChange(thisOwner) { @@ -256,4 +255,4 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, }); } } -}); \ No newline at end of file +}); diff --git a/app/app/pods/document/route.js b/app/app/pods/document/route.js index ce0f552e..c8edae3b 100644 --- a/app/app/pods/document/route.js +++ b/app/app/pods/document/route.js @@ -83,6 +83,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { actions: { error(error /*, transition*/ ) { + console.log(error); if (error) { this.transitionTo('/not-found'); return false; diff --git a/app/app/pods/document/section/controller.js b/app/app/pods/document/section/controller.js index e0ebd270..72eb3fc3 100644 --- a/app/app/pods/document/section/controller.js +++ b/app/app/pods/document/section/controller.js @@ -14,6 +14,8 @@ import NotifierMixin from '../../../mixins/notifier'; export default Ember.Controller.extend(NotifierMixin, { documentService: Ember.inject.service('document'), + queryParams: ['mode'], + mode: null, actions: { onAction(page, meta) { diff --git a/app/app/pods/document/section/route.js b/app/app/pods/document/section/route.js index 070e57e6..ad0e9c15 100644 --- a/app/app/pods/document/section/route.js +++ b/app/app/pods/document/section/route.js @@ -17,6 +17,15 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { folderService: Ember.inject.service('folder'), userService: Ember.inject.service('user'), pageId: '', + queryParams: { + mode: { + refreshModel: false + } + }, + + beforeModel(transition) { + this.set('mode', !_.isUndefined(transition.queryParams.mode) ? transition.queryParams.mode : ''); + }, model(params) { let self = this; diff --git a/app/app/pods/document/section/template.hbs b/app/app/pods/document/section/template.hbs index 11cc66db..5c381c71 100644 --- a/app/app/pods/document/section/template.hbs +++ b/app/app/pods/document/section/template.hbs @@ -1 +1 @@ -{{document/document-tab model=model onAction=(action 'onAction') onDelete=(action 'onDelete')}} +{{document/document-tab mode=mode model=model onAction=(action 'onAction') onDelete=(action 'onDelete')}} diff --git a/app/app/pods/document/wizard/controller.js b/app/app/pods/document/wizard/controller.js index eb225ddc..c7c101b5 100644 --- a/app/app/pods/document/wizard/controller.js +++ b/app/app/pods/document/wizard/controller.js @@ -40,12 +40,9 @@ export default Ember.Controller.extend(NotifierMixin, { }; this.get('documentService').addPage(this.get('model.document.id'), model).then((newPage) => { - this.transitionToRoute('document.section', - this.get('model.folder.id'), - this.get('model.folder.slug'), - this.get('model.document.id'), - this.get('model.document.slug'), - newPage.id); + let options = {}; + options['mode'] = 'edit'; + this.transitionToRoute('document.section', newPage.id, { queryParams: options }); }); } } diff --git a/app/app/services/document.js b/app/app/services/document.js index f2fd4877..3a38176c 100644 --- a/app/app/services/document.js +++ b/app/app/services/document.js @@ -124,12 +124,16 @@ export default Ember.Service.extend({ updatePage: function (documentId, pageId, payload, skipRevision) { var revision = skipRevision ? "?r=true" : "?r=false"; let url = `documents/${documentId}/pages/${pageId}${revision}`; + Ember.set(payload.meta, 'id', parseInt(payload.meta.id)); return this.get('ajax').request(url, { method: 'PUT', data: JSON.stringify(payload), contentType: 'json' + }).then((response) => { + let data = this.get('store').normalize('page', response); + return this.get('store').push(data); }); }, @@ -140,6 +144,9 @@ export default Ember.Service.extend({ return this.get('ajax').post(url, { data: JSON.stringify(payload), contentType: 'json' + }).then((response) => { + let data = this.get('store').normalize('page', response); + return this.get('store').push(data); }); }, diff --git a/app/package.json b/app/package.json index ff697d52..a633d086 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "name": "documize", - "version": "0.30.0", - "description": "The Documentation IDE", + "version": "0.31.0", + "description": "The Document IDE", "private": true, "directories": { "doc": "doc", diff --git a/core/product.go b/core/product.go index 4b79ec76..610cf348 100644 --- a/core/product.go +++ b/core/product.go @@ -26,7 +26,7 @@ type ProdInfo struct { // Product returns product edition details func Product() (p ProdInfo) { p.Major = "0" - p.Minor = "30" + p.Minor = "31" p.Patch = "0" p.Version = fmt.Sprintf("%s.%s.%s", p.Major, p.Minor, p.Patch) p.Edition = "Community" diff --git a/core/section/github/auth.go b/core/section/github/auth.go index 34ef803e..34ffc041 100644 --- a/core/section/github/auth.go +++ b/core/section/github/auth.go @@ -102,7 +102,7 @@ func Callback(res http.ResponseWriter, req *http.Request) error { return err } - target := up.Scheme + "://" + up.Host + up.Path + "?code=" + gt.AccessToken + target := up.Scheme + "://" + up.Host + up.Path + "?mode=edit&code=" + gt.AccessToken http.Redirect(res, req, target, http.StatusTemporaryRedirect) diff --git a/core/section/github/commits_template.go b/core/section/github/commits_template.go index c1ba6211..9dd38598 100644 --- a/core/section/github/commits_template.go +++ b/core/section/github/commits_template.go @@ -85,9 +85,8 @@ const commitsTemplate = `
- @{{$commit.Name}} - {{$commit.Name}} - · {{$commit.Date}} + @{{$commit.Name}} + {{$commit.Date}}