mirror of
https://github.com/documize/community.git
synced 2025-07-23 07:09:43 +02:00
Merge branch 'master' into db-auto-upgrade
This commit is contained in:
commit
a6873f807c
205 changed files with 15328 additions and 1771 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -17,7 +17,7 @@ _convert
|
||||||
# Documize build artifacts
|
# Documize build artifacts
|
||||||
bin/*
|
bin/*
|
||||||
dist/*
|
dist/*
|
||||||
/documize/web/bindata/*
|
embed/bindata/*
|
||||||
app/dist/*
|
app/dist/*
|
||||||
app/dist-prod/*
|
app/dist-prod/*
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@ _testmain.go
|
||||||
/app/testem.log
|
/app/testem.log
|
||||||
|
|
||||||
# Misc.
|
# Misc.
|
||||||
documize/web/bindata_assetfs.go
|
|
||||||
build
|
build
|
||||||
plugin-msword/plugin-msword
|
plugin-msword/plugin-msword
|
||||||
plugin-msword/plugin-msword-osx
|
plugin-msword/plugin-msword-osx
|
||||||
|
|
26
README.md
26
README.md
|
@ -2,25 +2,17 @@
|
||||||
|
|
||||||
Documentation that integrates and snapshots data from the tools you use.
|
Documentation that integrates and snapshots data from the tools you use.
|
||||||
|
|
||||||
v0.14.0
|
|
||||||
|
|
||||||
## Why?
|
|
||||||
|
|
||||||
In my previous startup, we sold “project management” software to businesses of all shapes and sizes. Our customers would complain that developers and business folks fought pitched battles over work visibility and deliverables. Being a developer & CTO by trade, I saw the same thing myself many times over.
|
|
||||||
|
|
||||||
Developers just want to code, and generally speaking documenting a chore.
|
|
||||||
|
|
||||||
It really hit home when staring at Google Docs. I struggled to pull together a coherent document explaining what happened during the latest development cycle. I wanted to share code commits, deployment logs, customer tickets, tasks with co-workers and customers. I just couldn’t do it without cut-pasting screenshots and emailing app links with sketchy instructions.
|
|
||||||
|
|
||||||
At that moment, I realized the way we produce documentation was fundamentally broken because more and more of our data was in the cloud. And it was getting worse each time we adopted a new SaaS tool — more SaaS tools, more data silos, more screenshots and even more app links to send round.
|
|
||||||
|
|
||||||
So we set about building Documize — it allows people to point-click-integrate their SaaS data into a different kind of “document”. You can think of the end result as a unified team inbox for any deliverable (that kills the hassle of juggling the ever-growing SaaS footprint).
|
|
||||||
|
|
||||||
Our mission is simple: to help businesses to snapshot, track and integrate their cloud-based data to compose a new kind of document.
|
|
||||||
|
|
||||||
**Don’t write documents. Compose them.**
|
**Don’t write documents. Compose them.**
|
||||||
|
|
||||||
@HarveyKandola, Founder, Documize Inc.
|
## Latest version
|
||||||
|
|
||||||
|
v0.15.0
|
||||||
|
|
||||||
|
## OS Support
|
||||||
|
|
||||||
|
* Windows
|
||||||
|
* Linux
|
||||||
|
* OSX
|
||||||
|
|
||||||
## Tech stack
|
## Tech stack
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import Ember from 'ember';
|
||||||
import TooltipMixin from '../../mixins/tooltip';
|
import TooltipMixin from '../../mixins/tooltip';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
computed: { oneWay, or, notEmpty },
|
|
||||||
computed
|
computed
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
|
@ -52,4 +51,4 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
this.attrs.onDeletePage(id, this.get('deleteChildren'));
|
this.attrs.onDeletePage(id, this.get('deleteChildren'));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default Ember.Component.extend({
|
||||||
targetOffset: "10px 0",
|
targetOffset: "10px 0",
|
||||||
constrainToWindow: true,
|
constrainToWindow: true,
|
||||||
constrainToScrollParent: true,
|
constrainToScrollParent: true,
|
||||||
|
tether: Ember.inject.service(),
|
||||||
|
|
||||||
hasSecondButton: Ember.computed('button2', 'color2', function () {
|
hasSecondButton: Ember.computed('button2', 'color2', function () {
|
||||||
return is.not.empty(this.get('button2')) && is.not.empty(this.get('color2'));
|
return is.not.empty(this.get('button2')) && is.not.empty(this.get('color2'));
|
||||||
|
@ -43,9 +44,10 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
// TODO: refactor to eliminate self
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
let drop = new Drop({
|
let drop = this.get('tether').createDrop({
|
||||||
target: document.getElementById(self.get('target')),
|
target: document.getElementById(self.get('target')),
|
||||||
content: self.$(".dropdown-dialog")[0],
|
content: self.$(".dropdown-dialog")[0],
|
||||||
classes: 'drop-theme-basic',
|
classes: 'drop-theme-basic',
|
||||||
|
@ -65,30 +67,38 @@ export default Ember.Component.extend({
|
||||||
remove: true
|
remove: true
|
||||||
});
|
});
|
||||||
|
|
||||||
self.set('drop', drop);
|
if (drop) {
|
||||||
|
drop.on('open', function () {
|
||||||
|
if (is.not.null(self.get("focusOn"))) {
|
||||||
|
document.getElementById(self.get("focusOn")).focus();
|
||||||
|
}
|
||||||
|
|
||||||
drop.on('open', function () {
|
if (is.not.null(self.get("selectOn"))) {
|
||||||
if (is.not.null(self.get("focusOn"))) {
|
document.getElementById(self.get("selectOn")).select();
|
||||||
document.getElementById(self.get("focusOn")).focus();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (is.not.null(self.get("selectOn"))) {
|
if (is.not.null(self.get("onOpenCallback"))) {
|
||||||
document.getElementById(self.get("selectOn")).select();
|
self.attrs.onOpenCallback(drop);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
self.set('drop', drop);
|
||||||
|
}
|
||||||
|
|
||||||
if (is.not.null(self.get("onOpenCallback"))) {
|
|
||||||
self.attrs.onOpenCallback(drop);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this.get('drop').destroy();
|
let drop = this.get('drop');
|
||||||
|
if (drop) {
|
||||||
|
drop.destroy();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
onCancel() {
|
onCancel() {
|
||||||
this.get('drop').close();
|
let drop = this.get('drop');
|
||||||
|
if (drop) {
|
||||||
|
drop.close();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onAction() {
|
onAction() {
|
||||||
|
@ -98,8 +108,9 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
let close = this.attrs.onAction();
|
let close = this.attrs.onAction();
|
||||||
|
|
||||||
if (close) {
|
let drop = this.get('drop');
|
||||||
this.get('drop').close();
|
if (close && drop) {
|
||||||
|
drop.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,9 +121,10 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
let close = this.attrs.onAction2();
|
let close = this.attrs.onAction2();
|
||||||
|
|
||||||
if (close) {
|
let drop = this.get('drop');
|
||||||
this.get('drop').close();
|
if (close && drop) {
|
||||||
|
drop.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -13,40 +13,44 @@ import Ember from 'ember';
|
||||||
import stringUtil from '../utils/string';
|
import stringUtil from '../utils/string';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
target: null,
|
target: null,
|
||||||
open: "click",
|
open: "click",
|
||||||
position: 'bottom right',
|
position: 'bottom right',
|
||||||
contentId: "",
|
contentId: "",
|
||||||
drop: null,
|
drop: null,
|
||||||
|
tether: Ember.inject.service(),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10));
|
this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10));
|
||||||
|
|
||||||
// if (this.session.get('isMobile')) {
|
// if (this.session.get('isMobile')) {
|
||||||
// this.set('open', "click");
|
// this.set('open', "click");
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
let drop = new Drop({
|
let drop = this.get('tether').createDrop({
|
||||||
target: document.getElementById(self.get('target')),
|
target: document.getElementById(self.get('target')),
|
||||||
content: self.$(".dropdown-menu")[0],
|
content: self.$(".dropdown-menu")[0],
|
||||||
classes: 'drop-theme-menu',
|
classes: 'drop-theme-menu',
|
||||||
position: self.get('position'),
|
position: self.get('position'),
|
||||||
openOn: self.get('open'),
|
openOn: self.get('open'),
|
||||||
tetherOptions: {
|
tetherOptions: {
|
||||||
offset: "5px 0",
|
offset: "5px 0",
|
||||||
targetOffset: "10px 0"
|
targetOffset: "10px 0"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.set('drop', drop);
|
self.set('drop', drop);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this.get('drop').destroy();
|
let drop = this.get('drop');
|
||||||
}
|
if (drop) {
|
||||||
});
|
drop.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -151,4 +151,4 @@ export default Ember.Route.extend(NotifierMixin, {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,8 +21,8 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
session: service(),
|
session: service(),
|
||||||
|
|
||||||
beforeModel() {
|
beforeModel(transition) {
|
||||||
return this.get('appMeta').boot().then(data => {
|
return this.get('appMeta').boot(transition.targetName).then(data => {
|
||||||
if (this.get('session.session.authenticator') !== "authenticator:documize" && data.allowAnonymousAccess) {
|
if (this.get('session.session.authenticator') !== "authenticator:documize" && data.allowAnonymousAccess) {
|
||||||
return this.get('session').authenticate('authenticator:anonymous', data);
|
return this.get('session').authenticate('authenticator:anonymous', data);
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,4 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@ export default Ember.Service.extend({
|
||||||
setupMode: false,
|
setupMode: false,
|
||||||
|
|
||||||
getBaseUrl(endpoint) {
|
getBaseUrl(endpoint) {
|
||||||
return [this.get('host'), endpoint].join('/');
|
return [this.get('endpoint'), endpoint].join('/');
|
||||||
},
|
},
|
||||||
|
|
||||||
boot() {
|
boot(/*requestedUrl*/) {
|
||||||
let dbhash;
|
let dbhash;
|
||||||
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
|
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
|
||||||
dbhash = document.head.querySelector("[property=dbhash]").content;
|
dbhash = document.head.querySelector("[property=dbhash]").content;
|
||||||
|
@ -57,4 +57,4 @@ export default Ember.Service.extend({
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,8 @@ import netUtil from '../utils/net';
|
||||||
import config from '../config/environment';
|
import config from '../config/environment';
|
||||||
|
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
sessionService: Ember.inject.service('session'),
|
session: Ember.inject.service('session'),
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
ready: false,
|
ready: false,
|
||||||
enabled: config.APP.auditEnabled,
|
enabled: config.APP.auditEnabled,
|
||||||
appId: config.APP.intercomKey,
|
appId: config.APP.intercomKey,
|
||||||
|
@ -45,9 +46,10 @@ export default Ember.Service.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
let session = this.get('sessionService');
|
let self = this;
|
||||||
|
let user = this.get('session.user');
|
||||||
|
|
||||||
if (this.get('appId') === "" || !this.get('enabled') || !session.authenticated || this.get('ready')) {
|
if (is.undefined(user) || this.get('appId') === "" || !this.get('enabled') || !this.get('session.authenticated') || this.get('ready')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,19 +57,19 @@ export default Ember.Service.extend({
|
||||||
|
|
||||||
window.intercomSettings = {
|
window.intercomSettings = {
|
||||||
app_id: this.get('appId'),
|
app_id: this.get('appId'),
|
||||||
name: session.user.firstname + " " + session.user.lastname,
|
name: user.fullname,
|
||||||
email: session.user.email,
|
email: user.email,
|
||||||
user_id: session.user.id,
|
user_id: user.id,
|
||||||
"administrator": session.user.admin,
|
"administrator": user.admin,
|
||||||
company: {
|
company: {
|
||||||
id: session.get('appMeta.orgId'),
|
id: self.get('appMeta.orgId'),
|
||||||
name: session.get('appMeta.title').string,
|
name: self.get('appMeta.title'),
|
||||||
"domain": netUtil.getSubdomain(),
|
"domain": netUtil.getSubdomain(),
|
||||||
"version": session.get('appMeta.version')
|
"version": self.get('appMeta.version')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!session.get('isMobile')) {
|
if (!this.get('session.isMobile')) {
|
||||||
window.intercomSettings.widget = {
|
window.intercomSettings.widget = {
|
||||||
activator: "#IntercomDefaultWidget"
|
activator: "#IntercomDefaultWidget"
|
||||||
};
|
};
|
||||||
|
@ -75,4 +77,4 @@ export default Ember.Service.extend({
|
||||||
|
|
||||||
window.Intercom('boot', window.intercomSettings);
|
window.Intercom('boot', window.intercomSettings);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
33
app/app/services/tether.js
Normal file
33
app/app/services/tether.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a work around problems that tether introduces into testing.
|
||||||
|
* TODO: remove this code and refactor in favour of ember-tether
|
||||||
|
*/
|
||||||
|
export default Ember.Service.extend({
|
||||||
|
createDrop() {
|
||||||
|
if (Ember.testing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Drop(...arguments);
|
||||||
|
},
|
||||||
|
createTooltip() {
|
||||||
|
if (Ember.testing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Tooltip(...arguments);
|
||||||
|
}
|
||||||
|
});
|
|
@ -13,117 +13,117 @@ import Ember from 'ember';
|
||||||
import models from '../utils/model';
|
import models from '../utils/model';
|
||||||
|
|
||||||
export default Ember.Service.extend({
|
export default Ember.Service.extend({
|
||||||
sessionService: Ember.inject.service('session'),
|
sessionService: Ember.inject.service('session'),
|
||||||
ajax: Ember.inject.service(),
|
ajax: Ember.inject.service(),
|
||||||
|
|
||||||
// Adds a new user.
|
// Adds a new user.
|
||||||
add(user) {
|
add(user) {
|
||||||
|
|
||||||
return this.get('ajax').request(`users`, {
|
return this.get('ajax').request(`users`, {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: JSON.stringify(user),
|
data: JSON.stringify(user),
|
||||||
contentType: 'json'
|
contentType: 'json'
|
||||||
}).then(function(response){
|
}).then(function (response) {
|
||||||
return models.UserModel.create(response);
|
return models.UserModel.create(response);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns user model for specified user id.
|
// Returns user model for specified user id.
|
||||||
getUser(userId) {
|
getUser(userId) {
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
type: 'GET'
|
type: 'GET'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
return models.UserModel.create(response);
|
return models.UserModel.create(response);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns all users for organization.
|
// Returns all users for organization.
|
||||||
getAll() {
|
getAll() {
|
||||||
return this.get('ajax').request(`users`).then((response) => {
|
return this.get('ajax').request(`users`).then((response) => {
|
||||||
return response.map(function(obj){
|
return response.map(function (obj) {
|
||||||
return models.UserModel.create(obj);
|
return models.UserModel.create(obj);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns all users that can see folder.
|
// Returns all users that can see folder.
|
||||||
getFolderUsers(folderId) {
|
getFolderUsers(folderId) {
|
||||||
let url = `users/folder/${folderId}`;
|
let url = `users/folder/${folderId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: "GET"
|
method: "GET"
|
||||||
}).then((response)=>{
|
}).then((response) => {
|
||||||
let data = [];
|
let data = [];
|
||||||
_.each(response, function(obj) {
|
_.each(response, function (obj) {
|
||||||
data.pushObject(models.UserModel.create(obj));
|
data.pushObject(models.UserModel.create(obj));
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Updates an existing user record.
|
// Updates an existing user record.
|
||||||
save(user) {
|
save(user) {
|
||||||
let userId = user.get('id');
|
let userId = user.get('id');
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: JSON.stringify(user),
|
data: JSON.stringify(user),
|
||||||
contentType: 'json'
|
contentType: 'json'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// updatePassword changes the password for the specified user.
|
// updatePassword changes the password for the specified user.
|
||||||
updatePassword(userId, password) {
|
updatePassword(userId, password) {
|
||||||
let url = `users/${userId}/password`;
|
let url = `users/${userId}/password`;
|
||||||
|
|
||||||
return this.get('ajax').post(url, {
|
return this.get('ajax').post(url, {
|
||||||
data: password
|
data: password
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Removes the specified user.
|
// Removes the specified user.
|
||||||
remove(userId) {
|
remove(userId) {
|
||||||
let url = `users/${userId}`;
|
let url = `users/${userId}`;
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Request password reset.
|
// Request password reset.
|
||||||
forgotPassword(email) {
|
forgotPassword(email) {
|
||||||
let url = `public/forgot`;
|
let url = `public/forgot`;
|
||||||
|
|
||||||
if (is.empty(email)) {
|
if (is.empty(email)) {
|
||||||
return Ember.RSVP.reject("invalid");
|
return Ember.RSVP.reject("invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = JSON.stringify({
|
let data = JSON.stringify({
|
||||||
Email: email
|
email: email
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set new password.
|
// Set new password.
|
||||||
resetPassword(token, password) {
|
resetPassword(token, password) {
|
||||||
var url = `public/reset/${token}`;
|
var url = `public/reset/${token}`;
|
||||||
|
|
||||||
if (is.empty(token) || is.empty(password)) {
|
if (is.empty(token) || is.empty(password)) {
|
||||||
return Ember.RSVP.reject("invalid");
|
return Ember.RSVP.reject("invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.get('ajax').request(url, {
|
return this.get('ajax').request(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: password
|
data: password
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -26,7 +26,7 @@
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
> .login {
|
> .login {
|
||||||
padding: 15px 0 0 0;
|
padding: 0;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
> a {
|
> a {
|
||||||
|
@ -125,4 +125,4 @@
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
color: $color-gray;
|
color: $color-gray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="document-structure">
|
<div class="document-structure">
|
||||||
{{#if this.session.authenticated}}
|
{{#if this.session.authenticated}}
|
||||||
<div id="tocToolbar" class="toc-controls {{if state.actionablePage 'current-page' ''}}">
|
<div id="tocToolbar" class="hidden-xs hidden-sm toc-controls {{if state.actionablePage 'current-page' ''}}">
|
||||||
<div id="toc-up-button" class="round-button-mono {{if state.upDisabled 'disabled'}}" data-tooltip="Move up" data-tooltip-position="top center" {{action 'pageUp'}}>
|
<div id="toc-up-button" class="round-button-mono {{if state.upDisabled 'disabled'}}" data-tooltip="Move up" data-tooltip-position="top center" {{action 'pageUp'}}>
|
||||||
<i class="material-icons">arrow_upward</i>
|
<i class="material-icons">arrow_upward</i>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="document-sidebar">
|
<div class="document-sidebar">
|
||||||
{{#if session.authenticated}}
|
{{#if session.authenticated}}
|
||||||
<div class="summary-line">
|
<div class="summary-line hidden-xs hidden-sm">
|
||||||
<ul class="items">
|
<ul class="items">
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<div id="owner-avatar" class="avatar" data-tooltip="{{owner.fullname}}" data-tooltip-position="right middle">{{owner.initials}}</div>
|
<div id="owner-avatar" class="avatar" data-tooltip="{{owner.fullname}}" data-tooltip-position="right middle">{{owner.initials}}</div>
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
import Mirage from 'ember-cli-mirage';
|
import Mirage from 'ember-cli-mirage';
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
@ -13,48 +24,6 @@ export default function () {
|
||||||
return schema.db.meta[0];
|
return schema.db.meta[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/public/validate', function (schema, request) {
|
|
||||||
let serverToken = request.queryParams.token;
|
|
||||||
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";
|
|
||||||
|
|
||||||
if (token = serverToken) {
|
|
||||||
return {
|
|
||||||
"id": "VzMuyEw_3WqiafcE",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"firstname": "Lennex",
|
|
||||||
"lastname": "Zinyando",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"initials": "LZ",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": true,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMuyEw_3WqiafcF",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"admin": true,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.get('/users/0/permissions', function () {
|
|
||||||
return [{
|
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
|
||||||
"userId": "",
|
|
||||||
"canView": true,
|
|
||||||
"canEdit": false
|
|
||||||
}];
|
|
||||||
});
|
|
||||||
|
|
||||||
this.get('/templates', function () {
|
this.get('/templates', function () {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
@ -63,55 +32,231 @@ export default function () {
|
||||||
let folder_id = request.queryParams.folder;
|
let folder_id = request.queryParams.folder;
|
||||||
|
|
||||||
if (folder_id = "VzMuyEw_3WqiafcG") {
|
if (folder_id = "VzMuyEw_3WqiafcG") {
|
||||||
return [{
|
return schema.db.documents.where({ folderId: folder_id });
|
||||||
"id": "VzMwX0w_3WrtFztd",
|
}
|
||||||
"created": "2016-05-11T13:15:11Z",
|
|
||||||
"revised": "2016-05-11T13:22:16Z",
|
if (folder_id = 'V0Vy5Uw_3QeDAMW9') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/documents/:id', function (schema, request) {
|
||||||
|
let id = request.params.id;
|
||||||
|
return schema.db.documents.where({ id: `${id}` })[0];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/documents/:id/pages', function () {
|
||||||
|
return [{
|
||||||
|
"id": "VzMzBUw_3WrtFztw",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"revised": "2016-05-11T13:26:29Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "wysiwyg",
|
||||||
|
"level": 1,
|
||||||
|
"sequence": 1024,
|
||||||
|
"title": "README",
|
||||||
|
"body": "",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "VzMzBUw_3WrtFztx",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"revised": "2016-05-11T13:26:29Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "wysiwyg",
|
||||||
|
"level": 2,
|
||||||
|
"sequence": 2048,
|
||||||
|
"title": "To Document / Instructions ",
|
||||||
|
"body": "\n\n\u003cp\u003eThe build process around go get github.com/elazarl/go-bindata-assetfs\u003c/p\u003e\n\n",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "VzMzBUw_3WrtFzty",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"revised": "2016-05-11T13:26:29Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "wysiwyg",
|
||||||
|
"level": 3,
|
||||||
|
"sequence": 3072,
|
||||||
|
"title": "GO ",
|
||||||
|
"body": "\n\n\u003cp\u003egobin / go env\u003c/p\u003e\n\n",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "VzMzBUw_3WrtFztz",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"revised": "2016-05-11T13:26:29Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "wysiwyg",
|
||||||
|
"level": 3,
|
||||||
|
"sequence": 4096,
|
||||||
|
"title": "go-bindata-assetsfs ",
|
||||||
|
"body": "\n\n\u003cp\u003emake sure you do install cmd from inside go-* folder where main.go lives\u003c/p\u003e\n\n",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "VzMzBUw_3WrtFzt0",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"revised": "2016-05-11T13:26:29Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "wysiwyg",
|
||||||
|
"level": 3,
|
||||||
|
"sequence": 5120,
|
||||||
|
"title": "SSL ",
|
||||||
|
"body": "\n\n\u003cp\u003eselfcert generation and avoiding red lock\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://www.accuweaver.com/2014/09/19/make-chrome-accept-a-self-signed-certificate-on-osx/\"\u003ehttps://www.accuweaver.com/2014/09/19/make-chrome-accept-a-self-signed-certificate-on-osx/\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003echrome://restart\u003c/p\u003e\n\n\u003cp\u003ego run generate_cert.go -host demo1.dev\u003c/p\u003e\n\n\u003cp\u003eport number not required\nbut browser restart is!\u003c/p\u003e\n\n",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "VzMzBUw_3WrtFzt1",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"revised": "2016-05-11T13:26:29Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "wysiwyg",
|
||||||
|
"level": 3,
|
||||||
|
"sequence": 6144,
|
||||||
|
"title": "after clone ",
|
||||||
|
"body": "\n\n\u003cul\u003e\n\u003cli\u003ecd app\u003c/li\u003e\n\u003cli\u003enpm install\u003c/li\u003e\n\u003cli\u003ebower install\u003c/li\u003e\n\u003cli\u003ecd ..\u003c/li\u003e\n\u003cli\u003e./build.sh\u003c/li\u003e\n\u003c/ul\u003e\n",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "V1qnNUw_3QRDs13j",
|
||||||
|
"created": "2016-06-10T11:40:37Z",
|
||||||
|
"revised": "2016-06-10T11:40:37Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "github",
|
||||||
|
"level": 2,
|
||||||
|
"sequence": 12288,
|
||||||
|
"title": "GitHub Section",
|
||||||
|
"body": "\n\u003cdiv class=\"section-github-render\"\u003e\n\t\u003cp\u003eThere are 0 commits for branch \u003ca href=\"\"\u003e\u003c/a\u003e of repository \u003ca href=\"\"\u003e.\u003c/a\u003e\u003c/p\u003e\n\t\u003cdiv class=\"github-board\"\u003e\n\t\t\n\t\u003c/div\u003e\n\u003c/div\u003e\n",
|
||||||
|
"revisions": 0
|
||||||
|
}, {
|
||||||
|
"id": "V1qqJkw_3RXs3w1D",
|
||||||
|
"created": "2016-06-10T11:53:10Z",
|
||||||
|
"revised": "2016-06-10T11:53:10Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"documentId": "VzMzBUw_3WrtFztv",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"contentType": "github",
|
||||||
|
"level": 2,
|
||||||
|
"sequence": 24576,
|
||||||
|
"title": "GitHub Section",
|
||||||
|
"body": "\n\u003cdiv class=\"section-github-render\"\u003e\n\t\u003cp\u003eThere are 0 commits for branch \u003ca href=\"\"\u003e\u003c/a\u003e of repository \u003ca href=\"\"\u003e.\u003c/a\u003e\u003c/p\u003e\n\t\u003cdiv class=\"github-board\"\u003e\n\t\t\n\t\u003c/div\u003e\n\u003c/div\u003e\n",
|
||||||
|
"revisions": 0
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
|
||||||
|
this.post('/templates/0/folder/VzMuyEw_3WqiafcG', function (schema, request) {
|
||||||
|
let type = request.queryParams.type;
|
||||||
|
if (type === 'saved') {
|
||||||
|
return schema.db.documents.insert({
|
||||||
|
"id": "V4y7jkw_3QvCDSeS",
|
||||||
|
"created": "2016-07-18T11:20:47Z",
|
||||||
|
"revised": "2016-07-18T11:20:47Z",
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
"folderId": "VzMuyEw_3WqiafcG",
|
"folderId": "VzMuyEw_3WqiafcG",
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
"job": "",
|
"job": "",
|
||||||
"location": "template-0",
|
"location": "template-0",
|
||||||
"name": "Empty Document",
|
"name": "New Document",
|
||||||
"excerpt": "My test document",
|
"excerpt": "A new document",
|
||||||
"tags": "",
|
"tags": "",
|
||||||
"template": false
|
"template": false
|
||||||
}, {
|
});
|
||||||
"id": "VzMvJEw_3WqiafcI",
|
|
||||||
"created": "2016-05-11T13:09:56Z",
|
|
||||||
"revised": "2016-05-11T13:09:56Z",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"folderId": "VzMuyEw_3WqiafcG",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"job": "0bf9b076-cb74-4e8e-75be-8ee2d24a8171",
|
|
||||||
"location": "/var/folders/d6/kr81d2fs5bsbm8rz2p092fy80000gn/T/documize/_uploads/0bf9b076-cb74-4e8e-75be-8ee2d24a8171/README.md",
|
|
||||||
"name": "README",
|
|
||||||
"excerpt": "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.",
|
|
||||||
"tags": "",
|
|
||||||
"template": false
|
|
||||||
}];
|
|
||||||
} else if (folder_id = "VzMygEw_3WrtFzto") {
|
|
||||||
return {
|
|
||||||
"id": "VzMygEw_3WrtFzto",
|
|
||||||
"created": "2016-05-11T13:24:17Z",
|
|
||||||
"revised": "2016-05-11T13:25:51Z",
|
|
||||||
"name": "Test",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"folderType": 1
|
|
||||||
};
|
|
||||||
} else if (folder_id = 'V0Vy5Uw_3QeDAMW9') {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.delete('/documents/:id', function (schema, request) {
|
||||||
|
let id = request.params.id;
|
||||||
|
return schema.db.documents.remove(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/documents/:id/attachments', function () {
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/documents/:id/meta', function () {
|
||||||
|
return {
|
||||||
|
"viewers": [{
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"created": "2016-07-14T13:46:24Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}],
|
||||||
|
"editors": [{
|
||||||
|
"pageId": "V1qqJkw_3RXs3w1D",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-06-10T11:53:10Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "V1qnNUw_3QRDs13j",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-06-10T11:40:37Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "VzMzBUw_3WrtFztw",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "VzMzBUw_3WrtFztx",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "VzMzBUw_3WrtFzty",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "VzMzBUw_3WrtFztz",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "VzMzBUw_3WrtFzt0",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}, {
|
||||||
|
"pageId": "VzMzBUw_3WrtFzt1",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"action": "add-page",
|
||||||
|
"created": "2016-05-11T13:26:29Z",
|
||||||
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando"
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
this.get('/folders', function (schema) {
|
this.get('/folders', function (schema) {
|
||||||
return schema.db.folders;
|
return schema.db.folders;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.post('/folders', function (schema, request) {
|
this.post('/folders', function (schema, request) {
|
||||||
var name = JSON.parse(request.requestBody).name;
|
var name = JSON.parse(request.requestBody).name;
|
||||||
let newFolder = {
|
let folder = {
|
||||||
"id": "V0Vy5Uw_3QeDAMW9",
|
"id": "V0Vy5Uw_3QeDAMW9",
|
||||||
"created": "2016-05-25T09:39:49Z",
|
"created": "2016-05-25T09:39:49Z",
|
||||||
"revised": "2016-05-25T09:39:49Z",
|
"revised": "2016-05-25T09:39:49Z",
|
||||||
|
@ -121,43 +266,19 @@ export default function () {
|
||||||
"folderType": 2
|
"folderType": 2
|
||||||
};
|
};
|
||||||
|
|
||||||
let folder = schema.db.folders.insert(newFolder);
|
return schema.db.folders.insert(folder);
|
||||||
return folder;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.post('/public/authenticate', (schema, request) => {
|
this.post('/public/authenticate', (schema, request) => {
|
||||||
let authorization = request.requestHeaders.Authorization;
|
let authorization = request.requestHeaders.Authorization;
|
||||||
let expectedAuthorization = "Basic OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==";
|
let expectedAuthorization = "Basic OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==";
|
||||||
|
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";
|
||||||
|
let user = schema.db.users.where({ id: "VzMuyEw_3WqiafcE" });
|
||||||
|
|
||||||
if (expectedAuthorization === authorization) {
|
if (expectedAuthorization === authorization) {
|
||||||
console.log("SSO login success");
|
|
||||||
return {
|
return {
|
||||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
"token": `${token}`,
|
||||||
"user": {
|
"user": user[0]
|
||||||
"id": "VzMuyEw_3WqiafcE",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"firstname": "Lennex",
|
|
||||||
"lastname": "Zinyando",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"initials": "LZ",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": true,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMuyEw_3WqiafcF",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"admin": true,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,78 +287,49 @@ export default function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
|
"token": `${token}`,
|
||||||
"user": {
|
"user": user[0]
|
||||||
"id": "VzMuyEw_3WqiafcE",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"firstname": "Lennex",
|
|
||||||
"lastname": "Zinyando",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"initials": "LZ",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": true,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMuyEw_3WqiafcF",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"admin": true,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/users/VzMuyEw_3WqiafcE/permissions', (schema) => {
|
this.get('/users/:id/permissions', (schema, request) => {
|
||||||
return schema.db.permissions;
|
let userId = request.params.id;
|
||||||
|
return schema.db.permissions.where({ userId: `${userId}` });
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/folders/VzMuyEw_3WqiafcG/permissions', () => {
|
this.get('/folders/:id/permissions', (schema, request) => {
|
||||||
|
let id = request.params.id;
|
||||||
|
return schema.db.folderPermissions.where({ id: `${id}` });
|
||||||
|
});
|
||||||
|
|
||||||
|
this.put('/folders/:id/permissions', () => {
|
||||||
|
// let id = request.params.id;
|
||||||
|
// let attrs = JSON.parse(request.requestBody).Roles;
|
||||||
|
// return schema.db.folderPermissions.update('VzMygEw_3WrtFzto', attrs[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.get('/users/folder/:id', () => {
|
||||||
return [{
|
return [{
|
||||||
"folderId": "VzMuyEw_3WqiafcG",
|
"id": "VzMuyEw_3WqiafcE",
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
"created": "2016-05-11T15:08:24Z",
|
||||||
"canView": true,
|
"revised": "2016-07-04T10:24:41Z",
|
||||||
"canEdit": true
|
"firstname": "Lennex",
|
||||||
|
"lastname": "Zinyando",
|
||||||
|
"email": "brizdigital@gmail.com",
|
||||||
|
"initials": "LZ",
|
||||||
|
"active": true,
|
||||||
|
"editor": false,
|
||||||
|
"admin": false,
|
||||||
|
"accounts": null
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
this.get('/sections/refresh', (schema, request) => {
|
||||||
return [{
|
let documentID = request.queryParams.documentID;
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
if (documentID) {
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
return {};
|
||||||
"userId": "",
|
}
|
||||||
"canEdit": true,
|
|
||||||
"canView": true
|
|
||||||
}, {
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
|
||||||
"userId": "VzMyp0w_3WrtFztq",
|
|
||||||
"canEdit": false,
|
|
||||||
"canView": false
|
|
||||||
}, {
|
|
||||||
"orgId": "",
|
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"canEdit": true,
|
|
||||||
"canView": true
|
|
||||||
}];
|
|
||||||
});
|
|
||||||
|
|
||||||
this.get('/folders/VzMygEw_3WrtFzto/permissions', () => {
|
|
||||||
return [{
|
|
||||||
"folderId": "VzMygEw_3WrtFzto",
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"canView": true,
|
|
||||||
"canEdit": true
|
|
||||||
}];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/folders/:id', (schema, request) => {
|
this.put('/folders/:id', (schema, request) => {
|
||||||
|
@ -264,18 +356,8 @@ export default function () {
|
||||||
return schema.db.folders.find(id);
|
return schema.db.folders.find(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/organizations/VzMuyEw_3WqiafcD', () => {
|
this.get('/organizations/VzMuyEw_3WqiafcD', (schema) => {
|
||||||
return {
|
return schema.db.organizations[0];
|
||||||
"id": "VzMuyEw_3WqiafcD",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-23T11:23:20Z",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"url": "",
|
|
||||||
"domain": "",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"allowAnonymousAccess": false
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/organizations/VzMuyEw_3WqiafcD', (schema, request) => {
|
this.put('/organizations/VzMuyEw_3WqiafcD', (schema, request) => {
|
||||||
|
@ -283,69 +365,15 @@ export default function () {
|
||||||
let message = JSON.parse(request.requestBody).title;
|
let message = JSON.parse(request.requestBody).title;
|
||||||
let allowAnonymousAccess = JSON.parse(request.requestBody).allowAnonymousAccess;
|
let allowAnonymousAccess = JSON.parse(request.requestBody).allowAnonymousAccess;
|
||||||
|
|
||||||
return {
|
return schema.db.organizations.update('VzMuyEw_3WqiafcD', {
|
||||||
"id": "VzMuyEw_3WqiafcD",
|
title: `${title}`,
|
||||||
"created": "2016-05-11T15:08:24Z",
|
message: `${message}`,
|
||||||
"revised": "2016-05-23T11:23:20Z",
|
allowAnonymousAccess: `${allowAnonymousAccess}`
|
||||||
"title": `${title}`,
|
});
|
||||||
"message": `${message}`,
|
|
||||||
"url": "",
|
|
||||||
"domain": "",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"allowAnonymousAccess": `${allowAnonymousAccess}`
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/users', () => {
|
this.get('/users', (schema) => {
|
||||||
return [{
|
return schema.db.users;
|
||||||
"id": "VzMyp0w_3WrtFztq",
|
|
||||||
"created": "2016-05-11T13:24:55Z",
|
|
||||||
"revised": "2016-05-11T13:33:47Z",
|
|
||||||
"firstname": "Len",
|
|
||||||
"lastname": "Random",
|
|
||||||
"email": "zinyando@gmail.com",
|
|
||||||
"initials": "LR",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": false,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMyp0w_3WrtFztr",
|
|
||||||
"created": "2016-05-11T13:24:55Z",
|
|
||||||
"revised": "2016-05-11T13:24:55Z",
|
|
||||||
"admin": false,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMyp0w_3WrtFztq",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
}, {
|
|
||||||
"id": "VzMuyEw_3WqiafcE",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"firstname": "Lennex",
|
|
||||||
"lastname": "Zinyando",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"initials": "LZ",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": true,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMuyEw_3WqiafcF",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"admin": true,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
}];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.post('/users', (schema, request) => {
|
this.post('/users', (schema, request) => {
|
||||||
|
@ -353,7 +381,7 @@ export default function () {
|
||||||
let lastname = JSON.parse(request.requestBody).lastname;
|
let lastname = JSON.parse(request.requestBody).lastname;
|
||||||
let email = JSON.parse(request.requestBody).email;
|
let email = JSON.parse(request.requestBody).email;
|
||||||
|
|
||||||
return {
|
let user = {
|
||||||
"id": "V0RmtUw_3QeDAMW7",
|
"id": "V0RmtUw_3QeDAMW7",
|
||||||
"created": "2016-05-24T14:35:33Z",
|
"created": "2016-05-24T14:35:33Z",
|
||||||
"revised": "2016-05-24T14:35:33Z",
|
"revised": "2016-05-24T14:35:33Z",
|
||||||
|
@ -378,35 +406,14 @@ export default function () {
|
||||||
"domain": ""
|
"domain": ""
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return schema.db.users.insert(user);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get('/users/VzMuyEw_3WqiafcE', () => {
|
this.get('/users/:id', (schema, request) => {
|
||||||
|
let id = request.params.id;
|
||||||
return {
|
let user = schema.db.users.where({ id: `${id}` });
|
||||||
"id": "VzMuyEw_3WqiafcE",
|
return user[0];
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"firstname": "Lennex",
|
|
||||||
"lastname": "Zinyando",
|
|
||||||
"email": "brizdigital@gmail.com",
|
|
||||||
"initials": "LZ",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": true,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMuyEw_3WqiafcF",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"admin": true,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
|
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
|
||||||
|
@ -414,35 +421,15 @@ export default function () {
|
||||||
let lastname = JSON.parse(request.requestBody).lastname;
|
let lastname = JSON.parse(request.requestBody).lastname;
|
||||||
let email = JSON.parse(request.requestBody).email;
|
let email = JSON.parse(request.requestBody).email;
|
||||||
|
|
||||||
return {
|
return schema.db.users.update('VzMuyEw_3WqiafcE', {
|
||||||
"id": "VzMuyEw_3WqiafcE",
|
firstname: `${firstname}`,
|
||||||
"created": "2016-05-11T15:08:24Z",
|
lastname: `${lastname}`,
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
email: `${email}`
|
||||||
"firstname": `${firstname}`,
|
});
|
||||||
"lastname": `${lastname}`,
|
|
||||||
"email": `${email}`,
|
|
||||||
"initials": "LZ",
|
|
||||||
"active": true,
|
|
||||||
"editor": true,
|
|
||||||
"admin": true,
|
|
||||||
"accounts": [{
|
|
||||||
"id": "VzMuyEw_3WqiafcF",
|
|
||||||
"created": "2016-05-11T15:08:24Z",
|
|
||||||
"revised": "2016-05-11T15:08:24Z",
|
|
||||||
"admin": true,
|
|
||||||
"editor": true,
|
|
||||||
"userId": "VzMuyEw_3WqiafcE",
|
|
||||||
"orgId": "VzMuyEw_3WqiafcD",
|
|
||||||
"company": "EmberSherpa",
|
|
||||||
"title": "EmberSherpa",
|
|
||||||
"message": "This Documize instance contains all our team documentation",
|
|
||||||
"domain": ""
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => {
|
this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => {
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,31 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is an example factory definition.
|
This is an example factory definition.
|
||||||
|
|
||||||
Create more files in this directory to define additional factories.
|
Create more files in this directory to define additional factories.
|
||||||
*/
|
*/
|
||||||
import Mirage/*, {faker} */ from 'ember-cli-mirage';
|
import Mirage /*, {faker} */ from 'ember-cli-mirage';
|
||||||
|
|
||||||
export default Mirage.Factory.extend({
|
export default Mirage.Factory.extend({
|
||||||
// name: 'Pete', // strings
|
// name: 'Pete', // strings
|
||||||
// age: 20, // numbers
|
// age: 20, // numbers
|
||||||
// tall: true, // booleans
|
// tall: true, // booleans
|
||||||
|
|
||||||
// email: function(i) { // and functions
|
// email: function(i) { // and functions
|
||||||
// return 'person' + i + '@test.com';
|
// return 'person' + i + '@test.com';
|
||||||
// },
|
// },
|
||||||
|
|
||||||
// firstName: faker.name.firstName, // using faker
|
// firstName: faker.name.firstName, // using faker
|
||||||
// lastName: faker.name.firstName,
|
// lastName: faker.name.firstName,
|
||||||
// zipCode: faker.address.zipCode
|
// zipCode: faker.address.zipCode
|
||||||
});
|
});
|
||||||
|
|
27
app/mirage/factories/document.js
Normal file
27
app/mirage/factories/document.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import { Factory, faker } from 'ember-cli-mirage';
|
||||||
|
|
||||||
|
export default Factory.extend({
|
||||||
|
"id": faker.list.cycle("VzMwX0w_3WrtFztd", "VzMvJEw_3WqiafcI", "VzMzBUw_3WrtFztv"),
|
||||||
|
"created": "2016-05-11T13:15:11Z",
|
||||||
|
"revised": "2016-05-11T13:22:16Z",
|
||||||
|
"orgId": "VzMuyEw_3WqiafcD",
|
||||||
|
"folderId": "VzMuyEw_3WqiafcG",
|
||||||
|
"userId": "VzMuyEw_3WqiafcE",
|
||||||
|
"job": faker.list.cycle("", "0bf9b076-cb74-4e8e-75be-8ee2d24a8171", "3004c449-b053-49a6-4abc-72688136184d"),
|
||||||
|
"location": faker.list.cycle("template-0", "/var/folders/README.md", "/var/folders/d6/3004c449-b053-49a6-4abc-72688136184d/README.md"),
|
||||||
|
"name": faker.list.cycle("Empty Document", "README", "README"),
|
||||||
|
"excerpt": faker.list.cycle("My test document", "To Document/ Instructions. GO. go- bindata- assetsfs. SSL.", "To Document/ Instructions. GO. go- bindata- assetsfs. SSL."),
|
||||||
|
"tags": "",
|
||||||
|
"template": false
|
||||||
|
});
|
19
app/mirage/factories/folder-permission.js
Normal file
19
app/mirage/factories/folder-permission.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import { Factory, faker } from 'ember-cli-mirage';
|
||||||
|
|
||||||
|
export default Factory.extend({
|
||||||
|
"folderId": faker.list.cycle("VzMuyEw_3WqiafcG", "VzMygEw_3WrtFzto"),
|
||||||
|
"userId": faker.list.cycle("VzMuyEw_3WqiafcE", "VzMuyEw_3WqiafcE"),
|
||||||
|
"canView": true,
|
||||||
|
"canEdit": true
|
||||||
|
});
|
24
app/mirage/factories/organization.js
Normal file
24
app/mirage/factories/organization.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import { Factory } from 'ember-cli-mirage';
|
||||||
|
|
||||||
|
export default Factory.extend({
|
||||||
|
"id": "VzMuyEw_3WqiafcD",
|
||||||
|
"created": "2016-05-11T15:08:24Z",
|
||||||
|
"revised": "2016-05-23T11:23:20Z",
|
||||||
|
"title": "EmberSherpa",
|
||||||
|
"message": "This Documize instance contains all our team documentation",
|
||||||
|
"url": "",
|
||||||
|
"domain": "",
|
||||||
|
"email": "brizdigital@gmail.com",
|
||||||
|
"allowAnonymousAccess": false
|
||||||
|
});
|
|
@ -1,19 +1,19 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
import Mirage, { faker } from 'ember-cli-mirage';
|
import Mirage, { faker } from 'ember-cli-mirage';
|
||||||
|
|
||||||
export default Mirage.Factory.extend({
|
export default Mirage.Factory.extend({
|
||||||
"folderId": faker.list.cycle('V0Vy5Uw_3QeDAMW9', 'VzMuyEw_3WqiafcG', 'VzMygEw_3WrtFzto', 'VzMygEw_3WrtFzto'),
|
"folderId": faker.list.cycle('V0Vy5Uw_3QeDAMW9', 'VzMuyEw_3WqiafcG', 'VzMygEw_3WrtFzto', 'VzMygEw_3WrtFzto', "VzMygEw_3WrtFzto"),
|
||||||
"userId": faker.list.cycle('VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', ''),
|
"userId": faker.list.cycle('VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', '', 0),
|
||||||
"canView": true,
|
"canView": true,
|
||||||
"canEdit": faker.list.cycle(true, true, true, false)
|
"canEdit": faker.list.cycle(true, true, true, false, false)
|
||||||
});
|
});
|
||||||
|
|
38
app/mirage/factories/user.js
Normal file
38
app/mirage/factories/user.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import { Factory, faker } from 'ember-cli-mirage';
|
||||||
|
|
||||||
|
export default Factory.extend({
|
||||||
|
"id": faker.list.cycle("VzMyp0w_3WrtFztq", "VzMuyEw_3WqiafcE"),
|
||||||
|
"created": faker.list.cycle("2016-05-11T13:24:55Z", "2016-05-11T15:08:24Z"),
|
||||||
|
"revised": faker.list.cycle("2016-05-11T13:33:47Z", "2016-05-11T15:08:24Z"),
|
||||||
|
"firstname": faker.list.cycle("Len", "Lennex"),
|
||||||
|
"lastname": faker.list.cycle("Random", "Zinyando"),
|
||||||
|
"email": faker.list.cycle("zinyando@gmail.com", "brizdigital@gmail.com"),
|
||||||
|
"initials": faker.list.cycle("LR", "LZ"),
|
||||||
|
"active": true,
|
||||||
|
"editor": true,
|
||||||
|
"admin": faker.list.cycle(false, true),
|
||||||
|
"accounts": [{
|
||||||
|
"id": faker.list.cycle("VzMyp0w_3WrtFztr", "VzMuyEw_3WqiafcF"),
|
||||||
|
"created": faker.list.cycle("2016-05-11T13:24:55Z", "2016-05-11T15:08:24Z"),
|
||||||
|
"revised": faker.list.cycle("2016-05-11T13:24:55Z", "2016-05-11T15:08:24Z"),
|
||||||
|
"admin": faker.list.cycle(false, true),
|
||||||
|
"editor": faker.list.cycle(true, true),
|
||||||
|
"userId": faker.list.cycle("VzMyp0w_3WrtFztq", "VzMuyEw_3WqiafcE"),
|
||||||
|
"orgId": faker.list.cycle("VzMuyEw_3WqiafcD", "VzMuyEw_3WqiafcD"),
|
||||||
|
"company": "EmberSherpa",
|
||||||
|
"title": "EmberSherpa",
|
||||||
|
"message": "This Documize instance contains all our team documentation",
|
||||||
|
"domain": ""
|
||||||
|
}]
|
||||||
|
});
|
|
@ -32,7 +32,8 @@
|
||||||
"waitToAppear",
|
"waitToAppear",
|
||||||
"stubUserNotification",
|
"stubUserNotification",
|
||||||
"is",
|
"is",
|
||||||
"authenticateUser"
|
"authenticateUser",
|
||||||
|
"localStorage"
|
||||||
],
|
],
|
||||||
"node": false,
|
"node": false,
|
||||||
"browser": false,
|
"browser": false,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Anon access disabled');
|
||||||
|
|
||||||
test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', function (assert) {
|
test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
visit('/');
|
visit('/');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
|
@ -25,4 +24,4 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: false }
|
||||||
findWithAssert('#authPassword');
|
findWithAssert('#authPassword');
|
||||||
findWithAssert('button');
|
findWithAssert('button');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Anon access enabled');
|
||||||
|
|
||||||
test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function (assert) {
|
test('visiting / when not authenticated and with { allowAnonymousAccess: true } takes user to folder view', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: true });
|
server.create('meta', { allowAnonymousAccess: true });
|
||||||
server.createList('folder', 2);
|
|
||||||
visit('/');
|
visit('/');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
|
@ -28,7 +27,6 @@ test('visiting / when not authenticated and with { allowAnonymousAccess: true }
|
||||||
|
|
||||||
test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) {
|
test('visiting / when authenticated and with { allowAnonymousAccess: true } takes user to dashboard', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: true });
|
server.create('meta', { allowAnonymousAccess: true });
|
||||||
server.createList('folder', 2);
|
|
||||||
visit('/');
|
visit('/');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
|
@ -42,4 +40,4 @@ test('visiting / when authenticated and with { allowAnonymousAccess: true } take
|
||||||
assert.equal(find('.login').length, 0, 'Login button is not displayed');
|
assert.equal(find('.login').length, 0, 'Login button is not displayed');
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in');
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Dashboard is displayed after user is signed in');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Authentication');
|
||||||
|
|
||||||
test('visiting /auth/login and logging in', function (assert) {
|
test('visiting /auth/login and logging in', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
visit('/auth/login');
|
visit('/auth/login');
|
||||||
|
|
||||||
fillIn('#authEmail', 'brizdigital@gmail.com');
|
fillIn('#authEmail', 'brizdigital@gmail.com');
|
||||||
|
@ -30,10 +29,8 @@ test('visiting /auth/login and logging in', function (assert) {
|
||||||
|
|
||||||
test('logging out a user', function (assert) {
|
test('logging out a user', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
userLogin();
|
userLogin();
|
||||||
|
click('.dropdown-menu a:contains(Logout)');
|
||||||
visit('/auth/logout');
|
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
assert.equal(currentURL(), '/auth/login', 'Logging out successful');
|
assert.equal(currentURL(), '/auth/login', 'Logging out successful');
|
||||||
|
@ -42,7 +39,6 @@ test('logging out a user', function (assert) {
|
||||||
|
|
||||||
test('successful sso login authenticates redirects to dashboard', function (assert) {
|
test('successful sso login authenticates redirects to dashboard', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
|
|
||||||
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
|
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
|
||||||
|
|
||||||
|
@ -53,11 +49,10 @@ test('successful sso login authenticates redirects to dashboard', function (asse
|
||||||
|
|
||||||
test('sso login with bad token should redirect to login', function (assert) {
|
test('sso login with bad token should redirect to login', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
|
|
||||||
visit('/auth/sso/randomToken1234567890');
|
visit('/auth/sso/randomToken1234567890');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
|
assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,47 +1,46 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
import { test, skip } from 'qunit';
|
import { test } from 'qunit';
|
||||||
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
|
|
||||||
moduleForAcceptance('Acceptance | Documents space');
|
moduleForAcceptance('Acceptance | Documents space');
|
||||||
|
|
||||||
skip('Adding a new folder space', function (assert) {
|
test('Adding a new folder space', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
let personalSpaces = find('.section div:contains(PERSONAL)').length;
|
let personalSpaces = find('.folders-list div:contains(PERSONAL) .list a').length;
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
assert.equal(personalSpaces, 1, '1 personal space is listed');
|
assert.equal(personalSpaces, 1, '1 personal space is listed');
|
||||||
});
|
});
|
||||||
|
|
||||||
click('#add-folder-button');
|
click('#add-folder-button');
|
||||||
|
|
||||||
fillIn('#new-folder-name', 'body', 'Test Folder');
|
fillIn('#new-folder-name', 'Test Folder');
|
||||||
|
|
||||||
click('.actions div:contains(Add)', 'body');
|
click('.actions div:contains(Add)');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
|
let folderCount = find('.folders-list div:contains(PERSONAL) .list a').length;
|
||||||
|
assert.equal(folderCount, 2, 'New folder has been added');
|
||||||
assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder');
|
assert.equal(currentURL(), '/s/V0Vy5Uw_3QeDAMW9/test-folder');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
skip('Adding a document to a space', function (assert) {
|
test('Adding a document to a space', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -52,20 +51,22 @@ skip('Adding a document to a space', function (assert) {
|
||||||
assert.equal(numberOfDocuments, 2, '2 documents listed');
|
assert.equal(numberOfDocuments, 2, '2 documents listed');
|
||||||
});
|
});
|
||||||
|
|
||||||
click('#start-document-button');
|
click('.actions div:contains(Start) .flat-green');
|
||||||
click('.actions div:contains(Add)', 'body');
|
|
||||||
|
andThen(function () {
|
||||||
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project/d/V4y7jkw_3QvCDSeS/new-document', 'New document displayed');
|
||||||
|
});
|
||||||
|
|
||||||
|
click('a div:contains(My Project) .space-name');
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
let numberOfDocuments = find('.documents-list li').length;
|
let numberOfDocuments = find('.documents-list li').length;
|
||||||
assert.equal(numberOfDocuments, 3, '3 documents listed');
|
assert.equal(numberOfDocuments, 3, '3 documents listed');
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('visiting space settings page', function (assert) {
|
test('visiting space settings page', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -80,8 +81,6 @@ test('visiting space settings page', function (assert) {
|
||||||
|
|
||||||
test('changing space name', function (assert) {
|
test('changing space name', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -100,8 +99,6 @@ test('changing space name', function (assert) {
|
||||||
|
|
||||||
test('sharing a space', function (assert) {
|
test('sharing a space', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -117,11 +114,8 @@ test('sharing a space', function (assert) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test will pass after moving to factories
|
|
||||||
test('changing space permissions', function (assert) {
|
test('changing space permissions', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
|
|
||||||
visit('/s/VzMygEw_3WrtFzto/test');
|
visit('/s/VzMygEw_3WrtFzto/test');
|
||||||
|
@ -150,8 +144,6 @@ test('changing space permissions', function (assert) {
|
||||||
|
|
||||||
test('deleting a space', function (assert) {
|
test('deleting a space', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -165,10 +157,8 @@ test('deleting a space', function (assert) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
skip('deleting a document', function (assert) {
|
test('deleting a document', function (assert) {
|
||||||
server.create('meta', { allowAnonymousAccess: false });
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
server.createList('folder', 2);
|
|
||||||
server.createList('permission', 4);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
visit('/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
|
|
||||||
|
@ -186,10 +176,7 @@ skip('deleting a document', function (assert) {
|
||||||
assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document');
|
assert.equal(deleteButton.length, 1, 'Delete button displayed after selecting document');
|
||||||
});
|
});
|
||||||
|
|
||||||
click('#delete-documents-button');
|
click('.actions div:contains(Delete) .flat-red');
|
||||||
|
|
||||||
waitToAppear('.drop-content');
|
|
||||||
click('.actions div:contains(Delete)', 'body');
|
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
let numberOfDocuments = find('.documents-list li');
|
let numberOfDocuments = find('.documents-list li');
|
||||||
|
@ -197,10 +184,32 @@ skip('deleting a document', function (assert) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('clicking a document title displays the document', function (assert) {
|
||||||
|
server.create('meta', { allowAnonymousAccess: false });
|
||||||
|
authenticateUser();
|
||||||
|
visit('/s/VzMygEw_3WrtFzto/test');
|
||||||
|
|
||||||
|
click('a .title:contains(README)');
|
||||||
|
|
||||||
|
andThen(function () {
|
||||||
|
findWithAssert('#add-section-button');
|
||||||
|
findWithAssert('#delete-document-button');
|
||||||
|
findWithAssert('#print-document-button');
|
||||||
|
findWithAssert('#save-template-button');
|
||||||
|
findWithAssert('#attachment-button');
|
||||||
|
findWithAssert('#set-meta-button');
|
||||||
|
findWithAssert('.name.space-name');
|
||||||
|
findWithAssert('.document-sidebar');
|
||||||
|
let title = find('.zone-header .title').text().trim();
|
||||||
|
assert.equal(title, 'README', 'document displayed correctly');
|
||||||
|
assert.equal(currentURL(), '/s/VzMygEw_3WrtFzto/test/d/VzMvJEw_3WqiafcI/readme');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function checkForCommonAsserts() {
|
function checkForCommonAsserts() {
|
||||||
findWithAssert('.sidebar-menu');
|
findWithAssert('.sidebar-menu');
|
||||||
findWithAssert('.options li:contains(General)');
|
findWithAssert('.options li:contains(General)');
|
||||||
findWithAssert('.options li:contains(Share)');
|
findWithAssert('.options li:contains(Share)');
|
||||||
findWithAssert('.options li:contains(Permissions)');
|
findWithAssert('.options li:contains(Permissions)');
|
||||||
findWithAssert('.options li:contains(Delete)');
|
findWithAssert('.options li:contains(Delete)');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
|
||||||
moduleForAcceptance('Acceptance | user profile');
|
moduleForAcceptance('Acceptance | user profile');
|
||||||
|
|
||||||
test('visiting /profile', function (assert) {
|
test('visiting /profile', function (assert) {
|
||||||
server.createList('folder', 2);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/profile');
|
visit('/profile');
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ test('visiting /profile', function (assert) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('changing user details and email ', function (assert) {
|
test('changing user details and email ', function (assert) {
|
||||||
server.createList('folder', 2);
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
visit('/profile');
|
visit('/profile');
|
||||||
|
|
||||||
|
@ -49,4 +47,4 @@ test('changing user details and email ', function (assert) {
|
||||||
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
|
||||||
assert.equal(find('.content .name').text().trim(), 'Test User', 'Profile name displayed');
|
assert.equal(find('.content .name').text().trim(), 'Test User', 'Profile name displayed');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -91,9 +91,6 @@ test('add a new user', function (assert) {
|
||||||
fillIn('#newUserEmail', 'test.user@domain.com');
|
fillIn('#newUserEmail', 'test.user@domain.com');
|
||||||
click('.button-blue');
|
click('.button-blue');
|
||||||
|
|
||||||
// waitToAppear('.user-notification:contains(Added)');
|
|
||||||
// waitToDisappear('.user-notification:contains(Added)');
|
|
||||||
|
|
||||||
andThen(function () {
|
andThen(function () {
|
||||||
let numberOfUsers = find('.user-list tr').length;
|
let numberOfUsers = find('.user-list tr').length;
|
||||||
assert.equal(numberOfUsers, 4, '3 Users listed');
|
assert.equal(numberOfUsers, 4, '3 Users listed');
|
||||||
|
@ -107,4 +104,4 @@ function checkForCommonAsserts() {
|
||||||
findWithAssert('#user-button');
|
findWithAssert('#user-button');
|
||||||
findWithAssert('#accounts-button');
|
findWithAssert('#accounts-button');
|
||||||
findWithAssert('.info .title');
|
findWithAssert('.info .title');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,31 +2,38 @@ import { module } from 'qunit';
|
||||||
import startApp from '../helpers/start-app';
|
import startApp from '../helpers/start-app';
|
||||||
import destroyApp from '../helpers/destroy-app';
|
import destroyApp from '../helpers/destroy-app';
|
||||||
|
|
||||||
export default function(name, options = {}) {
|
export default function (name, options = {}) {
|
||||||
module(name, {
|
module(name, {
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.application = startApp();
|
this.application = startApp();
|
||||||
stubAudit(this);
|
localStorage.setItem('folder', 'VzMuyEw_3WqiafcG');
|
||||||
stubUserNotification(this);
|
stubAudit(this);
|
||||||
|
stubUserNotification(this);
|
||||||
|
server.createList('folder', 2);
|
||||||
|
server.createList('user', 2);
|
||||||
|
server.createList('document', 2);
|
||||||
|
server.createList('permission', 4);
|
||||||
|
server.createList('folder-permission', 2);
|
||||||
|
server.createList('organization', 1);
|
||||||
|
|
||||||
if (options.beforeEach) {
|
if (options.beforeEach) {
|
||||||
options.beforeEach.apply(this, arguments);
|
options.beforeEach.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.register = (fullName, Factory) => {
|
this.register = (fullName, Factory) => {
|
||||||
let instance = this.application.__deprecatedInstance__;
|
let instance = this.application.__deprecatedInstance__;
|
||||||
let registry = instance.register ? instance : instance.registry;
|
let registry = instance.register ? instance : instance.registry;
|
||||||
|
|
||||||
return registry.register(fullName, Factory);
|
return registry.register(fullName, Factory);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
afterEach() {
|
afterEach() {
|
||||||
destroyApp(this.application);
|
destroyApp(this.application);
|
||||||
|
|
||||||
if (options.afterEach) {
|
if (options.afterEach) {
|
||||||
options.afterEach.apply(this, arguments);
|
options.afterEach.apply(this, arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,16 @@ import './stub-user-notification';
|
||||||
import './authenticate-user';
|
import './authenticate-user';
|
||||||
|
|
||||||
export default function startApp(attrs) {
|
export default function startApp(attrs) {
|
||||||
let application;
|
let application;
|
||||||
|
|
||||||
let attributes = Ember.merge({}, config.APP);
|
let attributes = Ember.merge({}, config.APP);
|
||||||
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
|
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
|
||||||
|
|
||||||
Ember.run(() => {
|
Ember.run(() => {
|
||||||
application = Application.create(attributes);
|
application = Application.create(attributes);
|
||||||
application.setupForTesting();
|
application.setupForTesting();
|
||||||
application.injectTestHelpers();
|
application.injectTestHelpers();
|
||||||
});
|
});
|
||||||
|
|
||||||
return application;
|
return application;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,16 @@
|
||||||
<meta property="dbname" content="{{.DBname}}" />
|
<meta property="dbname" content="{{.DBname}}" />
|
||||||
<meta property="dbhash" content="{{.DBhash}}" />
|
<meta property="dbhash" content="{{.DBhash}}" />
|
||||||
<meta name="author" content="Documize" />
|
<meta name="author" content="Documize" />
|
||||||
|
<style>
|
||||||
<style>
|
#ember-testing {
|
||||||
#ember-testing-container, #ember-testing-container * {
|
zoom: 100% !important;
|
||||||
/* Set position static to short-circuit Hubspot Tether's positioning */
|
}
|
||||||
/* https://github.com/HubSpot/tether/pull/98/ */
|
#ember-testing-container {
|
||||||
position: static !important;
|
/* Set position static to short-circuit Hubspot Tether's positioning */
|
||||||
}
|
/* https://github.com/HubSpot/tether/pull/98/ */
|
||||||
.tether-container * {
|
position: static !important;
|
||||||
z-index: 9999;
|
}
|
||||||
}
|
</style>
|
||||||
</style>
|
|
||||||
|
|
||||||
{{content-for "head"}}
|
{{content-for "head"}}
|
||||||
{{content-for "test-head"}}
|
{{content-for "test-head"}}
|
||||||
|
|
52
build-community.sh
Executable file
52
build-community.sh
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
NOW=$(date)
|
||||||
|
echo "Build process started $NOW"
|
||||||
|
|
||||||
|
# First parameter to this script is the Intercom.io key for audit logging.
|
||||||
|
# This is optional and we use Intercom to record user activity and provider in-app support via messaging.
|
||||||
|
intercomKey="$1"
|
||||||
|
|
||||||
|
echo "Building Ember assets..."
|
||||||
|
cd app
|
||||||
|
ember b -o dist-prod/ --environment=production intercom=$intercomKey
|
||||||
|
|
||||||
|
echo "Copying Ember assets..."
|
||||||
|
cd ..
|
||||||
|
rm -rf embed/bindata/public
|
||||||
|
mkdir -p embed/bindata/public
|
||||||
|
cp -r app/dist-prod/assets embed/bindata/public
|
||||||
|
cp -r app/dist-prod/codemirror embed/bindata/public/codemirror
|
||||||
|
cp -r app/dist-prod/tinymce embed/bindata/public/tinymce
|
||||||
|
cp -r app/dist-prod/sections embed/bindata/public/sections
|
||||||
|
cp app/dist-prod/*.* embed/bindata
|
||||||
|
cp app/dist-prod/favicon.ico embed/bindata/public
|
||||||
|
rm -rf embed/bindata/mail
|
||||||
|
mkdir -p embed/bindata/mail
|
||||||
|
cp core/api/mail/*.html embed/bindata/mail
|
||||||
|
cp core/database/templates/*.html embed/bindata
|
||||||
|
rm -rf embed/bindata/scripts
|
||||||
|
mkdir -p embed/bindata/scripts
|
||||||
|
cp -r core/database/scripts/autobuild/*.sql embed/bindata/scripts
|
||||||
|
|
||||||
|
echo "Generating in-memory static assets..."
|
||||||
|
go get -u github.com/jteeuwen/go-bindata/...
|
||||||
|
go get -u github.com/elazarl/go-bindata-assetfs/...
|
||||||
|
cd embed
|
||||||
|
go generate
|
||||||
|
|
||||||
|
echo "Compiling app..."
|
||||||
|
cd ..
|
||||||
|
for arch in amd64 ; do
|
||||||
|
for os in darwin linux windows ; do
|
||||||
|
if [ "$os" == "windows" ] ; then
|
||||||
|
echo "Compiling documize-community-$os-$arch.exe"
|
||||||
|
env GOOS=$os GOARCH=$arch go build -o bin/documize-community-$os-$arch.exe ./cmd/documize-community
|
||||||
|
else
|
||||||
|
echo "Compiling documize-community-$os-$arch"
|
||||||
|
env GOOS=$os GOARCH=$arch go build -o bin/documize-community-$os-$arch ./cmd/documize-community
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Finished."
|
52
build.sh
52
build.sh
|
@ -1,52 +0,0 @@
|
||||||
#! /bin/bash
|
|
||||||
|
|
||||||
NOW=$(date)
|
|
||||||
echo "Build process started $NOW"
|
|
||||||
|
|
||||||
# First parameter to this script is the Intercom.io key for audit logging.
|
|
||||||
# This is optional and we use Intercom to record user activity and provider in-app support via messaging.
|
|
||||||
intercomKey="$1"
|
|
||||||
|
|
||||||
echo "Building Ember assets..."
|
|
||||||
cd app
|
|
||||||
ember b -o dist-prod/ --environment=production intercom=$intercomKey
|
|
||||||
|
|
||||||
echo "Copying Ember assets..."
|
|
||||||
cd ..
|
|
||||||
rm -rf documize/web/bindata/public
|
|
||||||
mkdir -p documize/web/bindata/public
|
|
||||||
cp -r app/dist-prod/assets documize/web/bindata/public
|
|
||||||
cp -r app/dist-prod/codemirror documize/web/bindata/public/codemirror
|
|
||||||
cp -r app/dist-prod/tinymce documize/web/bindata/public/tinymce
|
|
||||||
cp -r app/dist-prod/sections documize/web/bindata/public/sections
|
|
||||||
cp app/dist-prod/*.* documize/web/bindata
|
|
||||||
cp app/dist-prod/favicon.ico documize/web/bindata/public
|
|
||||||
rm -rf documize/web/bindata/mail
|
|
||||||
mkdir -p documize/web/bindata/mail
|
|
||||||
cp documize/api/mail/*.html documize/web/bindata/mail
|
|
||||||
cp documize/database/templates/*.html documize/web/bindata
|
|
||||||
rm -rf documize/web/bindata/scripts
|
|
||||||
mkdir -p documize/web/bindata/scripts
|
|
||||||
cp -r documize/database/scripts/autobuild/*.sql documize/web/bindata/scripts
|
|
||||||
|
|
||||||
echo "Generating in-memory static assets..."
|
|
||||||
go get github.com/jteeuwen/go-bindata/...
|
|
||||||
go get github.com/elazarl/go-bindata-assetfs/...
|
|
||||||
cd documize/web
|
|
||||||
go generate
|
|
||||||
|
|
||||||
echo "Compiling app..."
|
|
||||||
cd ../..
|
|
||||||
for arch in amd64 ; do
|
|
||||||
for os in darwin linux windows ; do
|
|
||||||
if [ "$os" == "windows" ] ; then
|
|
||||||
echo "Compiling documize-$os-$arch.exe"
|
|
||||||
env GOOS=$os GOARCH=$arch go build -o bin/documize-$os-$arch.exe ./documize
|
|
||||||
else
|
|
||||||
echo "Compiling documize-$os-$arch"
|
|
||||||
env GOOS=$os GOARCH=$arch go build -o bin/documize-$os-$arch ./documize
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Finished."
|
|
|
@ -13,9 +13,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/documize/api/endpoint"
|
"github.com/documize/community/core/api/endpoint"
|
||||||
"github.com/documize/community/documize/section"
|
"github.com/documize/community/core/environment"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/section"
|
||||||
|
|
||||||
|
_ "github.com/documize/community/embed" // the compressed front-end code and static data
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql" // the mysql driver is required behind the scenes
|
_ "github.com/go-sql-driver/mysql" // the mysql driver is required behind the scenes
|
||||||
)
|
)
|
|
@ -16,7 +16,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
)
|
)
|
||||||
|
|
||||||
func endPoint() string {
|
func endPoint() string {
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
|
@ -14,11 +14,11 @@ package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/documize/community/documize/api/convert/excerpt"
|
"github.com/documize/community/core/api/convert/excerpt"
|
||||||
"github.com/documize/community/documize/api/convert/html"
|
"github.com/documize/community/core/api/convert/html"
|
||||||
"github.com/documize/community/documize/api/plugins"
|
"github.com/documize/community/core/api/plugins"
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
|
@ -1,24 +1,25 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
package convert_test
|
package convert_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/documize/api/convert"
|
|
||||||
"github.com/documize/community/documize/api/plugins"
|
|
||||||
"github.com/documize/community/wordsmith/api"
|
|
||||||
"github.com/documize/community/wordsmith/log"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/documize/community/core/api/convert"
|
||||||
|
"github.com/documize/community/core/api/plugins"
|
||||||
|
api "github.com/documize/community/core/convapi"
|
||||||
|
"github.com/documize/community/core/log"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,7 @@ package documizeapi
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
|
@ -18,7 +18,7 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
words "github.com/documize/community/wordsmith/wordlists/en-2012"
|
words "github.com/documize/community/core/wordlists/en-2012"
|
||||||
|
|
||||||
"github.com/rookii/paicehusk"
|
"github.com/rookii/paicehusk"
|
||||||
)
|
)
|
|
@ -1,18 +1,18 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
package excerpt_test
|
package excerpt_test
|
||||||
|
|
||||||
import "testing"
|
import "testing"
|
||||||
import "github.com/documize/community/documize/api/convert/excerpt"
|
import "github.com/documize/community/core/api/convert/excerpt"
|
||||||
import "strings"
|
import "strings"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"golang.org/x/net/html"
|
"golang.org/x/net/html"
|
||||||
"golang.org/x/net/html/atom"
|
"golang.org/x/net/html/atom"
|
|
@ -15,8 +15,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
import "github.com/documize/community/wordsmith/api"
|
import api "github.com/documize/community/core/convapi"
|
||||||
import "github.com/documize/community/documize/api/convert/html"
|
import "github.com/documize/community/core/api/convert/html"
|
||||||
|
|
||||||
const b string = `
|
const b string = `
|
||||||
<h1>Markdown: Basics</h1>
|
<h1>Markdown: Basics</h1>
|
|
@ -12,7 +12,7 @@
|
||||||
package md
|
package md
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
|
|
||||||
"github.com/documize/blackfriday"
|
"github.com/documize/blackfriday"
|
||||||
|
|
|
@ -20,10 +20,10 @@ import (
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
|
|
||||||
uuid "github.com/nu7hatch/gouuid"
|
uuid "github.com/nu7hatch/gouuid"
|
||||||
|
|
|
@ -23,15 +23,15 @@ import (
|
||||||
|
|
||||||
jwt "github.com/dgrijalva/jwt-go"
|
jwt "github.com/dgrijalva/jwt-go"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/endpoint/models"
|
"github.com/documize/community/core/api/endpoint/models"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/documize/section/provider"
|
"github.com/documize/community/core/section/provider"
|
||||||
"github.com/documize/community/documize/web"
|
"github.com/documize/community/core/web"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Authenticate user based up HTTP Authorization header.
|
// Authenticate user based up HTTP Authorization header.
|
|
@ -20,13 +20,13 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/endpoint/models"
|
"github.com/documize/community/core/api/endpoint/models"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/store"
|
"github.com/documize/community/core/api/store"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
|
|
||||||
uuid "github.com/nu7hatch/gouuid"
|
uuid "github.com/nu7hatch/gouuid"
|
||||||
|
|
|
@ -19,12 +19,12 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/plugins"
|
"github.com/documize/community/core/api/plugins"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/store"
|
"github.com/documize/community/core/api/store"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
|
@ -36,8 +36,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/plugins"
|
"github.com/documize/community/documize/api/plugins"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
|
|
||||||
"github.com/documize/community/sdk/exttest"
|
"github.com/documize/community/sdk/exttest"
|
||||||
)
|
)
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -15,9 +15,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/store"
|
||||||
"github.com/documize/community/documize/api/store"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var storageProvider store.StorageProvider
|
var storageProvider store.StorageProvider
|
||||||
|
@ -26,18 +25,6 @@ func init() {
|
||||||
storageProvider = new(store.LocalStorageProvider)
|
storageProvider = new(store.LocalStorageProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
//getAppURL returns full HTTP url for the app
|
|
||||||
func getAppURL(c request.Context, endpoint string) string {
|
|
||||||
|
|
||||||
scheme := "http://"
|
|
||||||
|
|
||||||
if c.SSL {
|
|
||||||
scheme = "https://"
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%s%s/%s", scheme, c.AppURL, endpoint)
|
|
||||||
}
|
|
||||||
|
|
||||||
func writePayloadError(w http.ResponseWriter, method string, err error) {
|
func writePayloadError(w http.ResponseWriter, method string, err error) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
|
@ -21,13 +21,13 @@ import (
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/endpoint/models"
|
"github.com/documize/community/core/api/endpoint/models"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/mail"
|
"github.com/documize/community/core/api/mail"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddFolder creates a new folder.
|
// AddFolder creates a new folder.
|
||||||
|
@ -407,7 +407,7 @@ func SetFolderPermissions(w http.ResponseWriter, r *http.Request) {
|
||||||
hasEveryoneRole := false
|
hasEveryoneRole := false
|
||||||
roleCount := 0
|
roleCount := 0
|
||||||
|
|
||||||
url := getAppURL(p.Context, fmt.Sprintf("s/%s/%s", label.RefID, utility.MakeSlug(label.Name)))
|
url := p.Context.GetAppURL(fmt.Sprintf("s/%s/%s", label.RefID, utility.MakeSlug(label.Name)))
|
||||||
|
|
||||||
for _, role := range model.Roles {
|
for _, role := range model.Roles {
|
||||||
role.OrgID = p.Context.OrgID
|
role.OrgID = p.Context.OrgID
|
||||||
|
@ -742,13 +742,13 @@ func InviteToFolder(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
url := getAppURL(p.Context, fmt.Sprintf("s/%s/%s", label.RefID, utility.MakeSlug(label.Name)))
|
url := p.Context.GetAppURL(fmt.Sprintf("s/%s/%s", label.RefID, utility.MakeSlug(label.Name)))
|
||||||
go mail.ShareFolderExistingUser(email, inviter.Fullname(), url, label.Name, model.Message)
|
go mail.ShareFolderExistingUser(email, inviter.Fullname(), url, label.Name, model.Message)
|
||||||
log.Info(fmt.Sprintf("%s is sharing space %s with existing user %s", inviter.Email, label.Name, email))
|
log.Info(fmt.Sprintf("%s is sharing space %s with existing user %s", inviter.Email, label.Name, email))
|
||||||
} else {
|
} else {
|
||||||
// On-board new user
|
// On-board new user
|
||||||
if strings.Contains(email, "@") {
|
if strings.Contains(email, "@") {
|
||||||
url := getAppURL(p.Context, fmt.Sprintf("auth/share/%s/%s", label.RefID, utility.MakeSlug(label.Name)))
|
url := p.Context.GetAppURL(fmt.Sprintf("auth/share/%s/%s", label.RefID, utility.MakeSlug(label.Name)))
|
||||||
err = inviteNewUserToSharedFolder(p, email, inviter, url, label, model.Message)
|
err = inviteNewUserToSharedFolder(p, email, inviter, url, label, model.Message)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -18,10 +18,11 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/log"
|
||||||
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetMeta provides org meta data based upon request domain (e.g. acme.documize.com).
|
// GetMeta provides org meta data based upon request domain (e.g. acme.documize.com).
|
||||||
|
@ -40,11 +41,13 @@ func GetMeta(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
product := core.Product()
|
||||||
|
|
||||||
data.OrgID = org.RefID
|
data.OrgID = org.RefID
|
||||||
data.Title = org.Title
|
data.Title = org.Title
|
||||||
data.Message = org.Message
|
data.Message = org.Message
|
||||||
data.AllowAnonymousAccess = org.AllowAnonymousAccess
|
data.AllowAnonymousAccess = org.AllowAnonymousAccess
|
||||||
data.Version = AppVersion
|
data.Version = product.Version
|
||||||
|
|
||||||
json, err := json.Marshal(data)
|
json, err := json.Marshal(data)
|
||||||
|
|
||||||
|
@ -77,7 +80,7 @@ Disallow: /
|
||||||
|
|
||||||
// Anonymous access would mean we allow bots to crawl.
|
// Anonymous access would mean we allow bots to crawl.
|
||||||
if org.AllowAnonymousAccess {
|
if org.AllowAnonymousAccess {
|
||||||
sitemap := getAppURL(p.Context, "sitemap.xml")
|
sitemap := p.Context.GetAppURL("sitemap.xml")
|
||||||
robots = fmt.Sprintf(
|
robots = fmt.Sprintf(
|
||||||
`User-agent: *
|
`User-agent: *
|
||||||
Disallow: /settings/
|
Disallow: /settings/
|
||||||
|
@ -135,7 +138,7 @@ func GetSitemap(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
for _, folder := range folders {
|
for _, folder := range folders {
|
||||||
var item sitemapItem
|
var item sitemapItem
|
||||||
item.URL = getAppURL(p.Context, fmt.Sprintf("s/%s/%s", folder.RefID, utility.MakeSlug(folder.Name)))
|
item.URL = p.Context.GetAppURL(fmt.Sprintf("s/%s/%s", folder.RefID, utility.MakeSlug(folder.Name)))
|
||||||
item.Date = folder.Revised.Format("2006-01-02T15:04:05.999999-07:00")
|
item.Date = folder.Revised.Format("2006-01-02T15:04:05.999999-07:00")
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,7 @@ func GetSitemap(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
for _, document := range documents {
|
for _, document := range documents {
|
||||||
var item sitemapItem
|
var item sitemapItem
|
||||||
item.URL = getAppURL(p.Context, fmt.Sprintf("s/%s/%s/d/%s/%s",
|
item.URL = p.Context.GetAppURL(fmt.Sprintf("s/%s/%s/d/%s/%s",
|
||||||
document.FolderID, utility.MakeSlug(document.Folder), document.DocumentID, utility.MakeSlug(document.Document)))
|
document.FolderID, utility.MakeSlug(document.Folder), document.DocumentID, utility.MakeSlug(document.Document)))
|
||||||
item.Date = document.Revised.Format("2006-01-02T15:04:05.999999-07:00")
|
item.Date = document.Revised.Format("2006-01-02T15:04:05.999999-07:00")
|
||||||
items = append(items, item)
|
items = append(items, item)
|
|
@ -15,7 +15,7 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PageSequenceRequestModel details a page ID and its sequence within the document.
|
// PageSequenceRequestModel details a page ID and its sequence within the document.
|
|
@ -18,10 +18,10 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
|
@ -19,13 +19,13 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/endpoint/models"
|
"github.com/documize/community/core/api/endpoint/models"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/documize/section/provider"
|
"github.com/documize/community/core/section/provider"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
220
core/api/endpoint/router.go
Normal file
220
core/api/endpoint/router.go
Normal file
|
@ -0,0 +1,220 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
package endpoint
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/documize/community/core/log"
|
||||||
|
"github.com/documize/community/core/web"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RoutePrefixPublic used for the unsecured api
|
||||||
|
RoutePrefixPublic = "/api/public/"
|
||||||
|
// RoutePrefixPrivate used for secured api (requiring api)
|
||||||
|
RoutePrefixPrivate = "/api/"
|
||||||
|
// RoutePrefixRoot used for unsecured endpoints at root (e.g. robots.txt)
|
||||||
|
RoutePrefixRoot = "/"
|
||||||
|
)
|
||||||
|
|
||||||
|
type routeDef struct {
|
||||||
|
Prefix string
|
||||||
|
Path string
|
||||||
|
Methods []string
|
||||||
|
Queries []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// RouteFunc describes end-point functions
|
||||||
|
type RouteFunc func(http.ResponseWriter, *http.Request)
|
||||||
|
|
||||||
|
type routeMap map[string]RouteFunc
|
||||||
|
|
||||||
|
var routes = make(routeMap)
|
||||||
|
|
||||||
|
func routesKey(prefix, path string, methods, queries []string) (string, error) {
|
||||||
|
rd := routeDef{
|
||||||
|
Prefix: prefix,
|
||||||
|
Path: path,
|
||||||
|
Methods: methods,
|
||||||
|
Queries: queries,
|
||||||
|
}
|
||||||
|
b, e := json.Marshal(rd)
|
||||||
|
return string(b), e
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add an endpoint to those that will be processed when Serve() is called.
|
||||||
|
func Add(prefix, path string, methods, queries []string, endPtFn RouteFunc) error {
|
||||||
|
k, e := routesKey(prefix, path, methods, queries)
|
||||||
|
if e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
routes[k] = endPtFn
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove an endpoint.
|
||||||
|
func Remove(prefix, path string, methods, queries []string) error {
|
||||||
|
k, e := routesKey(prefix, path, methods, queries)
|
||||||
|
if e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
delete(routes, k)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type routeSortItem struct {
|
||||||
|
def routeDef
|
||||||
|
fun RouteFunc
|
||||||
|
ord int
|
||||||
|
}
|
||||||
|
|
||||||
|
type routeSorter []routeSortItem
|
||||||
|
|
||||||
|
func (s routeSorter) Len() int { return len(s) }
|
||||||
|
func (s routeSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s routeSorter) Less(i, j int) bool {
|
||||||
|
if s[i].def.Prefix == s[j].def.Prefix && s[i].def.Path == s[j].def.Path {
|
||||||
|
return len(s[i].def.Queries) > len(s[j].def.Queries)
|
||||||
|
}
|
||||||
|
return s[i].ord < s[j].ord
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildRoutes(prefix string) *mux.Router {
|
||||||
|
var rs routeSorter
|
||||||
|
for k, v := range routes {
|
||||||
|
var rd routeDef
|
||||||
|
if err := json.Unmarshal([]byte(k), &rd); err != nil {
|
||||||
|
log.Error("buildRoutes json.Unmarshal", err)
|
||||||
|
} else {
|
||||||
|
if rd.Prefix == prefix {
|
||||||
|
order := strings.Index(rd.Path, "{")
|
||||||
|
if order == -1 {
|
||||||
|
order = len(rd.Path)
|
||||||
|
}
|
||||||
|
order = -order
|
||||||
|
rs = append(rs, routeSortItem{def: rd, fun: v, ord: order})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort.Sort(rs)
|
||||||
|
router := mux.NewRouter()
|
||||||
|
for _, it := range rs {
|
||||||
|
//fmt.Printf("DEBUG buildRoutes: %d %#v\n", it.ord, it.def)
|
||||||
|
|
||||||
|
x := router.HandleFunc(it.def.Prefix+it.def.Path, it.fun)
|
||||||
|
if len(it.def.Methods) > 0 {
|
||||||
|
y := x.Methods(it.def.Methods...)
|
||||||
|
if len(it.def.Queries) > 0 {
|
||||||
|
y.Queries(it.def.Queries...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
// **** add Unsecure Routes
|
||||||
|
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "meta", []string{"GET", "OPTIONS"}, nil, GetMeta))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "authenticate", []string{"POST", "OPTIONS"}, nil, Authenticate))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "validate", []string{"GET", "OPTIONS"}, nil, ValidateAuthToken))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "forgot", []string{"POST", "OPTIONS"}, nil, ForgotUserPassword))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "reset/{token}", []string{"POST", "OPTIONS"}, nil, ResetUserPassword))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "share/{folderID}", []string{"POST", "OPTIONS"}, nil, AcceptSharedFolder))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "attachments/{orgID}/{job}/{fileID}", []string{"GET", "OPTIONS"}, nil, AttachmentDownload))
|
||||||
|
log.IfErr(Add(RoutePrefixPublic, "version", []string{"GET", "OPTIONS"}, nil, version))
|
||||||
|
|
||||||
|
// **** add secure routes
|
||||||
|
|
||||||
|
// Import & Convert Document
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "import/folder/{folderID}", []string{"POST", "OPTIONS"}, nil, UploadConvertDocument))
|
||||||
|
|
||||||
|
// Document
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/export", []string{"GET", "OPTIONS"}, nil, GetDocumentAsDocx))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents", []string{"GET", "OPTIONS"}, []string{"filter", "tag"}, GetDocumentsByTag))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents", []string{"GET", "OPTIONS"}, nil, GetDocumentsByFolder))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}", []string{"GET", "OPTIONS"}, nil, GetDocument))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}", []string{"PUT", "OPTIONS"}, nil, UpdateDocument))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}", []string{"DELETE", "OPTIONS"}, nil, DeleteDocument))
|
||||||
|
|
||||||
|
// Document Meta
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/meta", []string{"GET", "OPTIONS"}, nil, GetDocumentMeta))
|
||||||
|
|
||||||
|
// Document Page
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/level", []string{"POST", "OPTIONS"}, nil, ChangeDocumentPageLevel))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/sequence", []string{"POST", "OPTIONS"}, nil, ChangeDocumentPageSequence))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/batch", []string{"POST", "OPTIONS"}, nil, GetDocumentPagesBatch))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"GET", "OPTIONS"}, nil, GetDocumentPages))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"PUT", "OPTIONS"}, nil, UpdateDocumentPage))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"DELETE", "OPTIONS"}, nil, DeleteDocumentPage))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"POST", "OPTIONS"}, nil, DeleteDocumentPages))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}", []string{"GET", "OPTIONS"}, nil, GetDocumentPage))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages", []string{"POST", "OPTIONS"}, nil, AddDocumentPage))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/attachments", []string{"GET", "OPTIONS"}, nil, GetAttachments))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/attachments/{attachmentID}", []string{"DELETE", "OPTIONS"}, nil, DeleteAttachment))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/attachments", []string{"POST", "OPTIONS"}, nil, AddAttachments))
|
||||||
|
|
||||||
|
// Document Page Meta
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}/meta", []string{"GET", "OPTIONS"}, nil, GetDocumentPageMeta))
|
||||||
|
|
||||||
|
// Organization
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "organizations/{orgID}", []string{"GET", "OPTIONS"}, nil, GetOrganization))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "organizations/{orgID}", []string{"PUT", "OPTIONS"}, nil, UpdateOrganization))
|
||||||
|
|
||||||
|
// Folder
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders/{folderID}/move/{moveToId}", []string{"DELETE", "OPTIONS"}, nil, RemoveFolder))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders/{folderID}/permissions", []string{"PUT", "OPTIONS"}, nil, SetFolderPermissions))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders/{folderID}/permissions", []string{"GET", "OPTIONS"}, nil, GetFolderPermissions))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders/{folderID}/invitation", []string{"POST", "OPTIONS"}, nil, InviteToFolder))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders", []string{"GET", "OPTIONS"}, []string{"filter", "viewers"}, GetFolderVisibility))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders", []string{"POST", "OPTIONS"}, nil, AddFolder))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders", []string{"GET", "OPTIONS"}, nil, GetFolders))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders/{folderID}", []string{"GET", "OPTIONS"}, nil, GetFolder))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "folders/{folderID}", []string{"PUT", "OPTIONS"}, nil, UpdateFolder))
|
||||||
|
|
||||||
|
// Users
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users/{userID}/password", []string{"POST", "OPTIONS"}, nil, ChangeUserPassword))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users/{userID}/permissions", []string{"GET", "OPTIONS"}, nil, GetUserFolderPermissions))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users", []string{"POST", "OPTIONS"}, nil, AddUser))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users/folder/{folderID}", []string{"GET", "OPTIONS"}, nil, GetFolderUsers))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users", []string{"GET", "OPTIONS"}, nil, GetOrganizationUsers))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users/{userID}", []string{"GET", "OPTIONS"}, nil, GetUser))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users/{userID}", []string{"PUT", "OPTIONS"}, nil, UpdateUser))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "users/{userID}", []string{"DELETE", "OPTIONS"}, nil, DeleteUser))
|
||||||
|
|
||||||
|
// Search
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "search", []string{"GET", "OPTIONS"}, nil, SearchDocuments))
|
||||||
|
|
||||||
|
// Templates
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "templates", []string{"POST", "OPTIONS"}, nil, SaveAsTemplate))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "templates", []string{"GET", "OPTIONS"}, nil, GetSavedTemplates))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "templates/stock", []string{"GET", "OPTIONS"}, nil, GetStockTemplates))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "templates/{templateID}/folder/{folderID}", []string{"POST", "OPTIONS"}, []string{"type", "stock"}, StartDocumentFromStockTemplate))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "templates/{templateID}/folder/{folderID}", []string{"POST", "OPTIONS"}, []string{"type", "saved"}, StartDocumentFromSavedTemplate))
|
||||||
|
|
||||||
|
// Sections
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "sections", []string{"GET", "OPTIONS"}, nil, GetSections))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "sections", []string{"POST", "OPTIONS"}, nil, RunSectionCommand))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "sections/refresh", []string{"GET", "OPTIONS"}, nil, RefreshSections))
|
||||||
|
|
||||||
|
// **** configure single page app handler.
|
||||||
|
|
||||||
|
log.IfErr(Add(RoutePrefixRoot, "robots.txt", []string{"GET", "OPTIONS"}, nil, GetRobots))
|
||||||
|
log.IfErr(Add(RoutePrefixRoot, "sitemap.xml", []string{"GET", "OPTIONS"}, nil, GetSitemap))
|
||||||
|
log.IfErr(Add(RoutePrefixRoot, "{rest:.*}", nil, nil, web.EmberHandler))
|
||||||
|
}
|
|
@ -15,11 +15,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/documize/section/provider"
|
"github.com/documize/community/core/section/provider"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSections returns available smart sections.
|
// GetSections returns available smart sections.
|
167
core/api/endpoint/server.go
Normal file
167
core/api/endpoint/server.go
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
package endpoint
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/codegangsta/negroni"
|
||||||
|
"github.com/documize/community/core"
|
||||||
|
"github.com/documize/community/core/api/plugins"
|
||||||
|
"github.com/documize/community/core/database"
|
||||||
|
"github.com/documize/community/core/environment"
|
||||||
|
"github.com/documize/community/core/log"
|
||||||
|
"github.com/documize/community/core/web"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
)
|
||||||
|
|
||||||
|
var port, certFile, keyFile, forcePort2SSL string
|
||||||
|
var product core.ProdInfo
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
product = core.Product()
|
||||||
|
environment.GetString(&certFile, "cert", false, "the cert.pem file used for https", nil)
|
||||||
|
environment.GetString(&keyFile, "key", false, "the key.pem file used for https", nil)
|
||||||
|
environment.GetString(&port, "port", false, "http/https port number", nil)
|
||||||
|
environment.GetString(&forcePort2SSL, "forcesslport", false, "redirect given http port number to TLS", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
var testHost string // used during automated testing
|
||||||
|
|
||||||
|
// Serve the Documize endpoint.
|
||||||
|
func Serve(ready chan struct{}) {
|
||||||
|
err := plugins.LibSetup()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Terminating before running - invalid plugin.json", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info(fmt.Sprintf("Starting %s version %s", product.Title, product.Version))
|
||||||
|
|
||||||
|
switch web.SiteMode {
|
||||||
|
case web.SiteModeOffline:
|
||||||
|
log.Info("Serving OFFLINE web app")
|
||||||
|
case web.SiteModeSetup:
|
||||||
|
Add(RoutePrefixPrivate, "setup", []string{"POST", "OPTIONS"}, nil, database.Create)
|
||||||
|
log.Info("Serving SETUP web app")
|
||||||
|
case web.SiteModeBadDB:
|
||||||
|
log.Info("Serving BAD DATABASE web app")
|
||||||
|
default:
|
||||||
|
log.Info("Starting web app")
|
||||||
|
}
|
||||||
|
|
||||||
|
router := mux.NewRouter()
|
||||||
|
|
||||||
|
// "/api/public/..."
|
||||||
|
router.PathPrefix(RoutePrefixPublic).Handler(negroni.New(
|
||||||
|
negroni.HandlerFunc(cors),
|
||||||
|
negroni.Wrap(buildRoutes(RoutePrefixPublic)),
|
||||||
|
))
|
||||||
|
|
||||||
|
// "/api/..."
|
||||||
|
router.PathPrefix(RoutePrefixPrivate).Handler(negroni.New(
|
||||||
|
negroni.HandlerFunc(Authorize),
|
||||||
|
negroni.Wrap(buildRoutes(RoutePrefixPrivate)),
|
||||||
|
))
|
||||||
|
|
||||||
|
// "/..."
|
||||||
|
router.PathPrefix(RoutePrefixRoot).Handler(negroni.New(
|
||||||
|
negroni.HandlerFunc(cors),
|
||||||
|
negroni.Wrap(buildRoutes(RoutePrefixRoot)),
|
||||||
|
))
|
||||||
|
|
||||||
|
n := negroni.New()
|
||||||
|
n.Use(negroni.NewStatic(web.StaticAssetsFileSystem()))
|
||||||
|
n.Use(negroni.HandlerFunc(cors))
|
||||||
|
n.Use(negroni.HandlerFunc(metrics))
|
||||||
|
n.UseHandler(router)
|
||||||
|
ready <- struct{}{}
|
||||||
|
|
||||||
|
if certFile == "" && keyFile == "" {
|
||||||
|
if port == "" {
|
||||||
|
port = "80"
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("Starting non-SSL server on " + port)
|
||||||
|
|
||||||
|
n.Run(testHost + ":" + port)
|
||||||
|
} else {
|
||||||
|
if port == "" {
|
||||||
|
port = "443"
|
||||||
|
}
|
||||||
|
|
||||||
|
if forcePort2SSL != "" {
|
||||||
|
log.Info("Starting non-SSL server on " + forcePort2SSL + " and redirecting to SSL server on " + port)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err := http.ListenAndServe(":"+forcePort2SSL, http.HandlerFunc(
|
||||||
|
func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
var host = strings.Replace(req.Host, forcePort2SSL, port, 1) + req.RequestURI
|
||||||
|
http.Redirect(w, req, "https://"+host, http.StatusMovedPermanently)
|
||||||
|
}))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("ListenAndServe on "+forcePort2SSL, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info("Starting SSL server on " + port + " with " + certFile + " " + keyFile)
|
||||||
|
|
||||||
|
server := &http.Server{Addr: ":" + port, Handler: n}
|
||||||
|
server.SetKeepAlivesEnabled(true)
|
||||||
|
if err := server.ListenAndServeTLS(certFile, keyFile); err != nil {
|
||||||
|
log.Error("ListenAndServeTLS on "+port, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func cors(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
w.Header().Set("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS, PATCH")
|
||||||
|
w.Header().Set("Access-Control-Allow-Headers", "host, content-type, accept, authorization, origin, referer, user-agent, cache-control, x-requested-with")
|
||||||
|
w.Header().Set("Access-Control-Expose-Headers", "x-documize-version")
|
||||||
|
|
||||||
|
if r.Method == "OPTIONS" {
|
||||||
|
if _, err := w.Write([]byte("")); err != nil {
|
||||||
|
log.Error("cors", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
next(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
func metrics(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
|
|
||||||
|
w.Header().Add("X-Documize-Version", product.Version)
|
||||||
|
w.Header().Add("Cache-Control", "no-cache")
|
||||||
|
|
||||||
|
// Prevent page from being displayed in an iframe
|
||||||
|
w.Header().Add("X-Frame-Options", "DENY")
|
||||||
|
|
||||||
|
// Force SSL delivery
|
||||||
|
// if certFile != "" && keyFile != "" {
|
||||||
|
// w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
|
||||||
|
// }
|
||||||
|
|
||||||
|
next(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
func version(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if _, err := w.Write([]byte(product.Version)); err != nil {
|
||||||
|
log.Error("versionHandler", err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,14 +22,14 @@ import (
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/convert"
|
"github.com/documize/community/core/api/convert"
|
||||||
"github.com/documize/community/documize/api/endpoint/models"
|
"github.com/documize/community/core/api/endpoint/models"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
uuid "github.com/nu7hatch/gouuid"
|
uuid "github.com/nu7hatch/gouuid"
|
||||||
)
|
)
|
|
@ -20,13 +20,13 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/mail"
|
"github.com/documize/community/core/api/mail"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
@ -174,13 +174,13 @@ func AddUser(w http.ResponseWriter, r *http.Request) {
|
||||||
auth := fmt.Sprintf("%s:%s:%s", p.Context.AppURL, userModel.Email, requestedPassword[:size])
|
auth := fmt.Sprintf("%s:%s:%s", p.Context.AppURL, userModel.Email, requestedPassword[:size])
|
||||||
encrypted := utility.EncodeBase64([]byte(auth))
|
encrypted := utility.EncodeBase64([]byte(auth))
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/%s", getAppURL(p.Context, "auth/sso"), url.QueryEscape(string(encrypted)))
|
url := fmt.Sprintf("%s/%s", p.Context.GetAppURL("auth/sso"), url.QueryEscape(string(encrypted)))
|
||||||
go mail.InviteNewUser(userModel.Email, inviter.Fullname(), url, userModel.Email, requestedPassword)
|
go mail.InviteNewUser(userModel.Email, inviter.Fullname(), url, userModel.Email, requestedPassword)
|
||||||
|
|
||||||
log.Info(fmt.Sprintf("%s invited by %s on %s", userModel.Email, inviter.Email, p.Context.AppURL))
|
log.Info(fmt.Sprintf("%s invited by %s on %s", userModel.Email, inviter.Email, p.Context.AppURL))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
go mail.InviteExistingUser(userModel.Email, inviter.Fullname(), getAppURL(p.Context, ""))
|
go mail.InviteExistingUser(userModel.Email, inviter.Fullname(), p.Context.GetAppURL(""))
|
||||||
|
|
||||||
log.Info(fmt.Sprintf("%s is giving access to an existing user %s", inviter.Email, userModel.Email))
|
log.Info(fmt.Sprintf("%s is giving access to an existing user %s", inviter.Email, userModel.Email))
|
||||||
}
|
}
|
||||||
|
@ -605,9 +605,7 @@ func ForgotUserPassword(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
log.IfErr(tx.Commit())
|
log.IfErr(tx.Commit())
|
||||||
|
|
||||||
appURL := getAppURL(p.Context, fmt.Sprintf("auth/reset/%s", token))
|
appURL := p.Context.GetAppURL(fmt.Sprintf("auth/reset/%s", token))
|
||||||
|
|
||||||
fmt.Println(appURL)
|
|
||||||
|
|
||||||
go mail.PasswordReset(user.Email, appURL)
|
go mail.PasswordReset(user.Email, appURL)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/documize/web"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InviteNewUser invites someone new providing credentials, explaining the product and stating who is inviting them.
|
// InviteNewUser invites someone new providing credentials, explaining the product and stating who is inviting them.
|
||||||
|
@ -44,8 +44,8 @@ func InviteNewUser(recipient, inviter, url, username, password string) {
|
||||||
|
|
||||||
subject := fmt.Sprintf("%s has invited you to Documize", inviter)
|
subject := fmt.Sprintf("%s has invited you to Documize", inviter)
|
||||||
|
|
||||||
e := newEmail()
|
e := NewEmail()
|
||||||
e.From = creds.SMTPsender()
|
e.From = SMTPCreds.SMTPsender()
|
||||||
e.To = []string{recipient}
|
e.To = []string{recipient}
|
||||||
e.Subject = subject
|
e.Subject = subject
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func InviteNewUser(recipient, inviter, url, username, password string) {
|
||||||
log.IfErr(t.Execute(buffer, ¶meters))
|
log.IfErr(t.Execute(buffer, ¶meters))
|
||||||
e.HTML = buffer.Bytes()
|
e.HTML = buffer.Bytes()
|
||||||
|
|
||||||
err = e.Send(getHost(), getAuth())
|
err = e.Send(GetHost(), GetAuth())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
||||||
|
@ -95,8 +95,8 @@ func InviteExistingUser(recipient, inviter, url string) {
|
||||||
|
|
||||||
subject := fmt.Sprintf("%s has invited you to their Documize account", inviter)
|
subject := fmt.Sprintf("%s has invited you to their Documize account", inviter)
|
||||||
|
|
||||||
e := newEmail()
|
e := NewEmail()
|
||||||
e.From = creds.SMTPsender()
|
e.From = SMTPCreds.SMTPsender()
|
||||||
e.To = []string{recipient}
|
e.To = []string{recipient}
|
||||||
e.Subject = subject
|
e.Subject = subject
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ func InviteExistingUser(recipient, inviter, url string) {
|
||||||
log.IfErr(t.Execute(buffer, ¶meters))
|
log.IfErr(t.Execute(buffer, ¶meters))
|
||||||
e.HTML = buffer.Bytes()
|
e.HTML = buffer.Bytes()
|
||||||
|
|
||||||
err = e.Send(getHost(), getAuth())
|
err = e.Send(GetHost(), GetAuth())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
||||||
|
@ -137,8 +137,8 @@ func PasswordReset(recipient, url string) {
|
||||||
|
|
||||||
subject := "Documize password reset request"
|
subject := "Documize password reset request"
|
||||||
|
|
||||||
e := newEmail()
|
e := NewEmail()
|
||||||
e.From = creds.SMTPsender() //e.g. "Documize <hello@documize.com>"
|
e.From = SMTPCreds.SMTPsender() //e.g. "Documize <hello@documize.com>"
|
||||||
e.To = []string{recipient}
|
e.To = []string{recipient}
|
||||||
e.Subject = subject
|
e.Subject = subject
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ func PasswordReset(recipient, url string) {
|
||||||
log.IfErr(t.Execute(buffer, ¶meters))
|
log.IfErr(t.Execute(buffer, ¶meters))
|
||||||
e.HTML = buffer.Bytes()
|
e.HTML = buffer.Bytes()
|
||||||
|
|
||||||
err = e.Send(getHost(), getAuth())
|
err = e.Send(GetHost(), GetAuth())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
||||||
|
@ -182,8 +182,8 @@ func ShareFolderExistingUser(recipient, inviter, url, folder, intro string) {
|
||||||
|
|
||||||
subject := fmt.Sprintf("%s has shared %s with you", inviter, folder)
|
subject := fmt.Sprintf("%s has shared %s with you", inviter, folder)
|
||||||
|
|
||||||
e := newEmail()
|
e := NewEmail()
|
||||||
e.From = creds.SMTPsender()
|
e.From = SMTPCreds.SMTPsender()
|
||||||
e.To = []string{recipient}
|
e.To = []string{recipient}
|
||||||
e.Subject = subject
|
e.Subject = subject
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ func ShareFolderExistingUser(recipient, inviter, url, folder, intro string) {
|
||||||
log.IfErr(t.Execute(buffer, ¶meters))
|
log.IfErr(t.Execute(buffer, ¶meters))
|
||||||
e.HTML = buffer.Bytes()
|
e.HTML = buffer.Bytes()
|
||||||
|
|
||||||
err = e.Send(getHost(), getAuth())
|
err = e.Send(GetHost(), GetAuth())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
||||||
|
@ -233,8 +233,8 @@ func ShareFolderNewUser(recipient, inviter, url, folder, invitationMessage strin
|
||||||
|
|
||||||
subject := fmt.Sprintf("%s has shared %s with you on Documize", inviter, folder)
|
subject := fmt.Sprintf("%s has shared %s with you on Documize", inviter, folder)
|
||||||
|
|
||||||
e := newEmail()
|
e := NewEmail()
|
||||||
e.From = creds.SMTPsender()
|
e.From = SMTPCreds.SMTPsender()
|
||||||
e.To = []string{recipient}
|
e.To = []string{recipient}
|
||||||
e.Subject = subject
|
e.Subject = subject
|
||||||
|
|
||||||
|
@ -257,14 +257,15 @@ func ShareFolderNewUser(recipient, inviter, url, folder, invitationMessage strin
|
||||||
log.IfErr(t.Execute(buffer, ¶meters))
|
log.IfErr(t.Execute(buffer, ¶meters))
|
||||||
e.HTML = buffer.Bytes()
|
e.HTML = buffer.Bytes()
|
||||||
|
|
||||||
err = e.Send(getHost(), getAuth())
|
err = e.Send(GetHost(), GetAuth())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
log.Error(fmt.Sprintf("%s - unable to send email", method), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var creds = struct{ SMTPuserid, SMTPpassword, SMTPhost, SMTPport, SMTPsender func() string }{
|
// SMTPCreds return SMTP configuration.
|
||||||
|
var SMTPCreds = struct{ SMTPuserid, SMTPpassword, SMTPhost, SMTPport, SMTPsender func() string }{
|
||||||
func() string { return request.ConfigString("SMTP", "userid") },
|
func() string { return request.ConfigString("SMTP", "userid") },
|
||||||
func() string { return request.ConfigString("SMTP", "password") },
|
func() string { return request.ConfigString("SMTP", "password") },
|
||||||
func() string { return request.ConfigString("SMTP", "host") },
|
func() string { return request.ConfigString("SMTP", "host") },
|
||||||
|
@ -278,16 +279,16 @@ var creds = struct{ SMTPuserid, SMTPpassword, SMTPhost, SMTPport, SMTPsender fun
|
||||||
func() string { return request.ConfigString("SMTP", "sender") },
|
func() string { return request.ConfigString("SMTP", "sender") },
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to return SMTP credentials
|
// GetAuth to return SMTP credentials
|
||||||
func getAuth() smtp.Auth {
|
func GetAuth() smtp.Auth {
|
||||||
a := smtp.PlainAuth("", creds.SMTPuserid(), creds.SMTPpassword(), creds.SMTPhost())
|
a := smtp.PlainAuth("", SMTPCreds.SMTPuserid(), SMTPCreds.SMTPpassword(), SMTPCreds.SMTPhost())
|
||||||
//fmt.Printf("DEBUG getAuth() = %#v\n", a)
|
//fmt.Printf("DEBUG GetAuth() = %#v\n", a)
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to return SMTP host details
|
// GetHost to return SMTP host details
|
||||||
func getHost() string {
|
func GetHost() string {
|
||||||
h := creds.SMTPhost() + ":" + creds.SMTPport()
|
h := SMTPCreds.SMTPhost() + ":" + SMTPCreds.SMTPport()
|
||||||
//fmt.Printf("DEBUG getHost() = %#v\n", h)
|
//fmt.Printf("DEBUG GetHost() = %#v\n", h)
|
||||||
return h
|
return h
|
||||||
}
|
}
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMail(t *testing.T) {
|
func TestMail(t *testing.T) {
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/documize/community/wordsmith/log"
|
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
"mime"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
|
@ -56,6 +55,8 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/documize/community/core/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -77,8 +78,8 @@ type Email struct {
|
||||||
ReadReceipt []string
|
ReadReceipt []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// newEmail creates an Email, and returns the pointer to it.
|
// NewEmail creates an Email, and returns the pointer to it.
|
||||||
func newEmail() *Email {
|
func NewEmail() *Email {
|
||||||
return &Email{Headers: textproto.MIMEHeader{}}
|
return &Email{Headers: textproto.MIMEHeader{}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/convert/apidocumizecom"
|
"github.com/documize/community/core/api/convert/apidocumizecom"
|
||||||
"github.com/documize/community/documize/api/convert/documizeapi"
|
"github.com/documize/community/core/api/convert/documizeapi"
|
||||||
"github.com/documize/community/documize/api/convert/html"
|
"github.com/documize/community/core/api/convert/html"
|
||||||
"github.com/documize/community/documize/api/convert/md"
|
"github.com/documize/community/core/api/convert/md"
|
||||||
"github.com/documize/community/documize/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/wordsmith/api"
|
api "github.com/documize/community/core/convapi"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/glick"
|
"github.com/documize/glick"
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,9 +14,9 @@ package request
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,7 @@ package request
|
||||||
/* TODO(Elliott)
|
/* TODO(Elliott)
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/documize/api/entity"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -16,9 +16,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddAttachment inserts the given record into the database attachement table.
|
// AddAttachment inserts the given record into the database attachement table.
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/documize/api/entity"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testAtt = "TestAttachment"
|
const testAtt = "TestAttachment"
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* NOT CURRENTLY USED
|
/* NOT CURRENTLY USED
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/gorilla/context"
|
"github.com/gorilla/context"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rc = Context{}
|
var rc = Context{}
|
||||||
|
@ -42,6 +42,17 @@ type Context struct {
|
||||||
Transaction *sqlx.Tx
|
Transaction *sqlx.Tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GetAppURL returns full HTTP url for the app
|
||||||
|
func (c *Context) GetAppURL(endpoint string) string {
|
||||||
|
scheme := "http://"
|
||||||
|
|
||||||
|
if c.SSL {
|
||||||
|
scheme = "https://"
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s%s/%s", scheme, c.AppURL, endpoint)
|
||||||
|
}
|
||||||
|
|
||||||
// NewContext simply returns a blank Context type.
|
// NewContext simply returns a blank Context type.
|
||||||
func NewContext() Context {
|
func NewContext() Context {
|
||||||
return Context{}
|
return Context{}
|
|
@ -13,7 +13,7 @@ package request
|
||||||
|
|
||||||
/* TODO(Elliott)
|
/* TODO(Elliott)
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
|
@ -18,9 +18,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddDocument inserts the given document record into the document table and audits that it has been done.
|
// AddDocument inserts the given document record into the document table and audits that it has been done.
|
||||||
|
@ -77,9 +77,12 @@ func (p *Persister) GetDocument(id string) (document entity.Document, err error)
|
||||||
func (p *Persister) GetDocumentMeta(id string) (meta entity.DocumentMeta, err error) {
|
func (p *Persister) GetDocumentMeta(id string) (meta entity.DocumentMeta, err error) {
|
||||||
err = nil
|
err = nil
|
||||||
|
|
||||||
sqlViewers := `SELECT CONVERT_TZ(MAX(a.created), @@session.time_zone, '+00:00') as created, a.userid, u.firstname, u.lastname
|
sqlViewers := `SELECT CONVERT_TZ(MAX(a.created), @@session.time_zone, '+00:00') as created,
|
||||||
|
IFNULL(a.userid, '') AS userid, IFNULL(u.firstname, '') AS firstname, IFNULL(u.lastname, '') AS lastname
|
||||||
FROM audit a LEFT JOIN user u ON a.userid=u.refid
|
FROM audit a LEFT JOIN user u ON a.userid=u.refid
|
||||||
WHERE a.orgid=? AND a.documentid=? AND a.userid != '0' AND action='get-document'
|
WHERE a.orgid=? AND a.documentid=?
|
||||||
|
AND a.userid != '0' AND a.userid != ''
|
||||||
|
AND action='get-document'
|
||||||
GROUP BY a.userid ORDER BY MAX(a.created) DESC`
|
GROUP BY a.userid ORDER BY MAX(a.created) DESC`
|
||||||
|
|
||||||
err = Db.Select(&meta.Viewers, sqlViewers, p.Context.OrgID, id)
|
err = Db.Select(&meta.Viewers, sqlViewers, p.Context.OrgID, id)
|
||||||
|
@ -88,11 +91,12 @@ func (p *Persister) GetDocumentMeta(id string) (meta entity.DocumentMeta, err er
|
||||||
log.Error(fmt.Sprintf("Unable to execute select GetDocumentMeta.viewers %s", id), err)
|
log.Error(fmt.Sprintf("Unable to execute select GetDocumentMeta.viewers %s", id), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//SELECT CONVERT_TZ(a.created, @@session.time_zone, '+00:00') as
|
//SELECT CONVERT_TZ(a.created, @@session.time_zone, '+00:00') as
|
||||||
sqlEdits := `SELECT CONVERT_TZ(a.created, @@session.time_zone, '+00:00') as created,
|
sqlEdits := `SELECT CONVERT_TZ(a.created, @@session.time_zone, '+00:00') as created,
|
||||||
a.action, a.userid, u.firstname, u.lastname, a.pageid
|
IFNULL(a.action, '') AS action, IFNULL(a.userid, '') AS userid, IFNULL(u.firstname, '') AS firstname, IFNULL(u.lastname, '') AS lastname, IFNULL(a.pageid, '') AS pageid
|
||||||
FROM audit a LEFT JOIN user u ON a.userid=u.refid
|
FROM audit a LEFT JOIN user u ON a.userid=u.refid
|
||||||
WHERE a.orgid=? AND a.documentid=? AND a.userid != '0'
|
WHERE a.orgid=? AND a.documentid=? AND a.userid != '0' AND a.userid != ''
|
||||||
AND (a.action='update-page' OR a.action='add-page' OR a.action='remove-page')
|
AND (a.action='update-page' OR a.action='add-page' OR a.action='remove-page')
|
||||||
ORDER BY a.created DESC;`
|
ORDER BY a.created DESC;`
|
||||||
|
|
|
@ -14,7 +14,7 @@ package request
|
||||||
/* TODO(Elliott)
|
/* TODO(Elliott)
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/documize/api/entity"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
|
@ -15,13 +15,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
"github.com/documize/community/documize/database"
|
"github.com/documize/community/core/database"
|
||||||
"github.com/documize/community/wordsmith/environment"
|
"github.com/documize/community/core/environment"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
|
"github.com/documize/community/core/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
var connectionString string
|
var connectionString string
|
||||||
|
@ -58,6 +60,7 @@ func init() {
|
||||||
|
|
||||||
Db.SetMaxIdleConns(30)
|
Db.SetMaxIdleConns(30)
|
||||||
Db.SetMaxOpenConns(100)
|
Db.SetMaxOpenConns(100)
|
||||||
|
Db.SetConnMaxLifetime(time.Second * 14400)
|
||||||
|
|
||||||
err = Db.Ping()
|
err = Db.Ping()
|
||||||
|
|
||||||
|
@ -68,13 +71,15 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// go into setup mode if required
|
// go into setup mode if required
|
||||||
if database.Check(Db, connectionString) {
|
if web.SiteMode != web.SiteModeOffline {
|
||||||
if err := database.Migrate(true /* the config table exists */); err != nil {
|
if database.Check(Db, connectionString) {
|
||||||
log.Error("Unable to run database migration: ", err)
|
if err := database.Migrate(true /* the config table exists */); err != nil {
|
||||||
os.Exit(2)
|
log.Error("Unable to run database migration: ", err)
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Info("database.Check(Db) !OK, going into setup mode")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.Info("database.Check(Db) !OK, going into setup mode")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false // value not changed
|
return false // value not changed
|
|
@ -15,9 +15,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddLabel adds new folder into the store.
|
// AddLabel adds new folder into the store.
|
|
@ -16,9 +16,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddLabelRole inserts the given record into the labelrole database table.
|
// AddLabelRole inserts the given record into the labelrole database table.
|
|
@ -17,10 +17,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/web"
|
"github.com/documize/community/core/web"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,10 +18,10 @@ import (
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/endpoint/models"
|
"github.com/documize/community/core/api/endpoint/models"
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddPage inserts the given page into the page table, adds that page to the queue of pages to index and audits that the page has been added.
|
// AddPage inserts the given page into the page table, adds that page to the queue of pages to index and audits that the page has been added.
|
|
@ -21,9 +21,9 @@ import (
|
||||||
_ "github.com/go-sql-driver/mysql" // required for sqlx but not directly called
|
_ "github.com/go-sql-driver/mysql" // required for sqlx but not directly called
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
|
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/core/log"
|
||||||
"github.com/documize/community/wordsmith/utility"
|
"github.com/documize/community/core/utility"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SearchManager type provides the datastructure for the queues of activity to be serialized through a single background goroutine.
|
// SearchManager type provides the datastructure for the queues of activity to be serialized through a single background goroutine.
|
|
@ -14,8 +14,8 @@ package request
|
||||||
// This file contains the code for initial set-up of a database
|
// This file contains the code for initial set-up of a database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/documize/community/documize/api/entity"
|
"github.com/documize/community/core/api/entity"
|
||||||
"github.com/documize/community/documize/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupPersister() (*Persister, error) {
|
func SetupPersister() (*Persister, error) {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue