1
0
Fork 0
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:
Elliott Stoneham 2016-07-27 06:52:50 +01:00
commit a6873f807c
205 changed files with 15328 additions and 1771 deletions

3
.gitignore vendored
View file

@ -17,7 +17,7 @@ _convert
# Documize build artifacts
bin/*
dist/*
/documize/web/bindata/*
embed/bindata/*
app/dist/*
app/dist-prod/*
@ -51,7 +51,6 @@ _testmain.go
/app/testem.log
# Misc.
documize/web/bindata_assetfs.go
build
plugin-msword/plugin-msword
plugin-msword/plugin-msword-osx

View file

@ -2,25 +2,17 @@
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 couldnt 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 toolmore SaaS tools, more data silos, more screenshots and even more app links to send round.
So we set about building Documizeit 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.
**Dont write documents. Compose them.**
@HarveyKandola, Founder, Documize Inc.
## Latest version
v0.15.0
## OS Support
* Windows
* Linux
* OSX
## Tech stack

View file

@ -13,7 +13,6 @@ import Ember from 'ember';
import TooltipMixin from '../../mixins/tooltip';
const {
computed: { oneWay, or, notEmpty },
computed
} = Ember;

View file

@ -32,6 +32,7 @@ export default Ember.Component.extend({
targetOffset: "10px 0",
constrainToWindow: true,
constrainToScrollParent: true,
tether: Ember.inject.service(),
hasSecondButton: Ember.computed('button2', 'color2', function () {
return is.not.empty(this.get('button2')) && is.not.empty(this.get('color2'));
@ -43,9 +44,10 @@ export default Ember.Component.extend({
didInsertElement() {
this._super(...arguments);
// TODO: refactor to eliminate self
let self = this;
let drop = new Drop({
let drop = this.get('tether').createDrop({
target: document.getElementById(self.get('target')),
content: self.$(".dropdown-dialog")[0],
classes: 'drop-theme-basic',
@ -65,30 +67,38 @@ export default Ember.Component.extend({
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("focusOn"))) {
document.getElementById(self.get("focusOn")).focus();
}
if (is.not.null(self.get("selectOn"))) {
document.getElementById(self.get("selectOn")).select();
}
if (is.not.null(self.get("selectOn"))) {
document.getElementById(self.get("selectOn")).select();
}
if (is.not.null(self.get("onOpenCallback"))) {
self.attrs.onOpenCallback(drop);
}
});
self.set('drop', drop);
}
if (is.not.null(self.get("onOpenCallback"))) {
self.attrs.onOpenCallback(drop);
}
});
},
willDestroyElement() {
this.get('drop').destroy();
let drop = this.get('drop');
if (drop) {
drop.destroy();
}
},
actions: {
onCancel() {
this.get('drop').close();
let drop = this.get('drop');
if (drop) {
drop.close();
}
},
onAction() {
@ -98,8 +108,9 @@ export default Ember.Component.extend({
let close = this.attrs.onAction();
if (close) {
this.get('drop').close();
let drop = this.get('drop');
if (close && drop) {
drop.close();
}
},
@ -110,8 +121,9 @@ export default Ember.Component.extend({
let close = this.attrs.onAction2();
if (close) {
this.get('drop').close();
let drop = this.get('drop');
if (close && drop) {
drop.close();
}
}
}

View file

@ -13,40 +13,44 @@ import Ember from 'ember';
import stringUtil from '../utils/string';
export default Ember.Component.extend({
target: null,
open: "click",
position: 'bottom right',
contentId: "",
drop: null,
target: null,
open: "click",
position: 'bottom right',
contentId: "",
drop: null,
tether: Ember.inject.service(),
didReceiveAttrs() {
this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10));
didReceiveAttrs() {
this.set("contentId", 'dropdown-menu-' + stringUtil.makeId(10));
// if (this.session.get('isMobile')) {
// this.set('open', "click");
// }
},
// if (this.session.get('isMobile')) {
// this.set('open', "click");
// }
},
didInsertElement() {
this._super(...arguments);
let self = this;
didInsertElement() {
this._super(...arguments);
let self = this;
let drop = new Drop({
target: document.getElementById(self.get('target')),
content: self.$(".dropdown-menu")[0],
classes: 'drop-theme-menu',
position: self.get('position'),
openOn: self.get('open'),
tetherOptions: {
offset: "5px 0",
targetOffset: "10px 0"
}
});
let drop = this.get('tether').createDrop({
target: document.getElementById(self.get('target')),
content: self.$(".dropdown-menu")[0],
classes: 'drop-theme-menu',
position: self.get('position'),
openOn: self.get('open'),
tetherOptions: {
offset: "5px 0",
targetOffset: "10px 0"
}
});
self.set('drop', drop);
},
self.set('drop', drop);
},
willDestroyElement() {
this.get('drop').destroy();
}
willDestroyElement() {
let drop = this.get('drop');
if (drop) {
drop.destroy();
}
}
});

View file

@ -21,8 +21,8 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
appMeta: service(),
session: service(),
beforeModel() {
return this.get('appMeta').boot().then(data => {
beforeModel(transition) {
return this.get('appMeta').boot(transition.targetName).then(data => {
if (this.get('session.session.authenticator') !== "authenticator:documize" && data.allowAnonymousAccess) {
return this.get('session').authenticate('authenticator:anonymous', data);
}

View file

@ -31,10 +31,10 @@ export default Ember.Service.extend({
setupMode: false,
getBaseUrl(endpoint) {
return [this.get('host'), endpoint].join('/');
return [this.get('endpoint'), endpoint].join('/');
},
boot() {
boot(/*requestedUrl*/) {
let dbhash;
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
dbhash = document.head.querySelector("[property=dbhash]").content;

View file

@ -14,7 +14,8 @@ import netUtil from '../utils/net';
import config from '../config/environment';
export default Ember.Service.extend({
sessionService: Ember.inject.service('session'),
session: Ember.inject.service('session'),
appMeta: Ember.inject.service(),
ready: false,
enabled: config.APP.auditEnabled,
appId: config.APP.intercomKey,
@ -45,9 +46,10 @@ export default Ember.Service.extend({
},
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;
}
@ -55,19 +57,19 @@ export default Ember.Service.extend({
window.intercomSettings = {
app_id: this.get('appId'),
name: session.user.firstname + " " + session.user.lastname,
email: session.user.email,
user_id: session.user.id,
"administrator": session.user.admin,
name: user.fullname,
email: user.email,
user_id: user.id,
"administrator": user.admin,
company: {
id: session.get('appMeta.orgId'),
name: session.get('appMeta.title').string,
id: self.get('appMeta.orgId'),
name: self.get('appMeta.title'),
"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 = {
activator: "#IntercomDefaultWidget"
};

View 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);
}
});

View file

@ -13,117 +13,117 @@ import Ember from 'ember';
import models from '../utils/model';
export default Ember.Service.extend({
sessionService: Ember.inject.service('session'),
ajax: Ember.inject.service(),
sessionService: Ember.inject.service('session'),
ajax: Ember.inject.service(),
// Adds a new user.
add(user) {
// Adds a new user.
add(user) {
return this.get('ajax').request(`users`, {
type: 'POST',
data: JSON.stringify(user),
contentType: 'json'
}).then(function(response){
return models.UserModel.create(response);
});
},
return this.get('ajax').request(`users`, {
type: 'POST',
data: JSON.stringify(user),
contentType: 'json'
}).then(function (response) {
return models.UserModel.create(response);
});
},
// Returns user model for specified user id.
getUser(userId) {
let url = `users/${userId}`;
// Returns user model for specified user id.
getUser(userId) {
let url = `users/${userId}`;
return this.get('ajax').request(url, {
type: 'GET'
}).then((response) => {
return models.UserModel.create(response);
});
},
return this.get('ajax').request(url, {
type: 'GET'
}).then((response) => {
return models.UserModel.create(response);
});
},
// Returns all users for organization.
getAll() {
return this.get('ajax').request(`users`).then((response) => {
return response.map(function(obj){
return models.UserModel.create(obj);
});
});
},
// Returns all users for organization.
getAll() {
return this.get('ajax').request(`users`).then((response) => {
return response.map(function (obj) {
return models.UserModel.create(obj);
});
});
},
// Returns all users that can see folder.
getFolderUsers(folderId) {
let url = `users/folder/${folderId}`;
// Returns all users that can see folder.
getFolderUsers(folderId) {
let url = `users/folder/${folderId}`;
return this.get('ajax').request(url, {
method: "GET"
}).then((response)=>{
let data = [];
_.each(response, function(obj) {
data.pushObject(models.UserModel.create(obj));
});
return this.get('ajax').request(url, {
method: "GET"
}).then((response) => {
let data = [];
_.each(response, function (obj) {
data.pushObject(models.UserModel.create(obj));
});
return data;
});
},
return data;
});
},
// Updates an existing user record.
save(user) {
let userId = user.get('id');
let url = `users/${userId}`;
// Updates an existing user record.
save(user) {
let userId = user.get('id');
let url = `users/${userId}`;
return this.get('ajax').request(url, {
type: 'PUT',
data: JSON.stringify(user),
contentType: 'json'
});
},
return this.get('ajax').request(url, {
type: 'PUT',
data: JSON.stringify(user),
contentType: 'json'
});
},
// updatePassword changes the password for the specified user.
updatePassword(userId, password) {
let url = `users/${userId}/password`;
// updatePassword changes the password for the specified user.
updatePassword(userId, password) {
let url = `users/${userId}/password`;
return this.get('ajax').post(url, {
data: password
});
},
return this.get('ajax').post(url, {
data: password
});
},
// Removes the specified user.
remove(userId) {
let url = `users/${userId}`;
// Removes the specified user.
remove(userId) {
let url = `users/${userId}`;
return this.get('ajax').request(url, {
method: 'DELETE'
});
},
return this.get('ajax').request(url, {
method: 'DELETE'
});
},
// Request password reset.
forgotPassword(email) {
let url = `public/forgot`;
// Request password reset.
forgotPassword(email) {
let url = `public/forgot`;
if (is.empty(email)) {
return Ember.RSVP.reject("invalid");
}
if (is.empty(email)) {
return Ember.RSVP.reject("invalid");
}
let data = JSON.stringify({
Email: email
});
let data = JSON.stringify({
email: email
});
return this.get('ajax').request(url, {
method: 'POST',
dataType: 'json',
data: data
});
},
return this.get('ajax').request(url, {
method: 'POST',
dataType: 'json',
data: data
});
},
// Set new password.
resetPassword(token, password) {
var url = `public/reset/${token}`;
// Set new password.
resetPassword(token, password) {
var url = `public/reset/${token}`;
if (is.empty(token) || is.empty(password)) {
return Ember.RSVP.reject("invalid");
}
if (is.empty(token) || is.empty(password)) {
return Ember.RSVP.reject("invalid");
}
return this.get('ajax').request(url, {
method: "POST",
data: password
});
}
return this.get('ajax').request(url, {
method: "POST",
data: password
});
}
});

View file

@ -26,7 +26,7 @@
vertical-align: middle;
}
> .login {
padding: 15px 0 0 0;
padding: 0;
font-size: 1rem;
display: inline-block;
> a {

View file

@ -1,6 +1,6 @@
<div class="document-structure">
{{#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'}}>
<i class="material-icons">arrow_upward</i>
</div>

View file

@ -1,6 +1,6 @@
<div class="document-sidebar">
{{#if session.authenticated}}
<div class="summary-line">
<div class="summary-line hidden-xs hidden-sm">
<ul class="items">
<li class="item">
<div id="owner-avatar" class="avatar" data-tooltip="{{owner.fullname}}" data-tooltip-position="right middle">{{owner.initials}}</div>

View file

@ -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';
export default function () {
@ -13,48 +24,6 @@ export default function () {
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 () {
return [];
});
@ -63,55 +32,231 @@ export default function () {
let folder_id = request.queryParams.folder;
if (folder_id = "VzMuyEw_3WqiafcG") {
return [{
"id": "VzMwX0w_3WrtFztd",
"created": "2016-05-11T13:15:11Z",
"revised": "2016-05-11T13:22:16Z",
return schema.db.documents.where({ folderId: folder_id });
}
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",
"folderId": "VzMuyEw_3WqiafcG",
"userId": "VzMuyEw_3WqiafcE",
"job": "",
"location": "template-0",
"name": "Empty Document",
"excerpt": "My test document",
"name": "New Document",
"excerpt": "A new document",
"tags": "",
"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) {
return schema.db.folders;
});
this.post('/folders', function (schema, request) {
var name = JSON.parse(request.requestBody).name;
let newFolder = {
let folder = {
"id": "V0Vy5Uw_3QeDAMW9",
"created": "2016-05-25T09:39:49Z",
"revised": "2016-05-25T09:39:49Z",
@ -121,43 +266,19 @@ export default function () {
"folderType": 2
};
let folder = schema.db.folders.insert(newFolder);
return folder;
return schema.db.folders.insert(folder);
});
this.post('/public/authenticate', (schema, request) => {
let authorization = request.requestHeaders.Authorization;
let expectedAuthorization = "Basic OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==";
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0";
let user = schema.db.users.where({ id: "VzMuyEw_3WqiafcE" });
if (expectedAuthorization === authorization) {
console.log("SSO login success");
return {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
"user": {
"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": ""
}]
}
"token": `${token}`,
"user": user[0]
};
}
@ -166,78 +287,49 @@ export default function () {
}
return {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb21haW4iOiIiLCJleHAiOjE0NjQwMjM2NjcsImlzcyI6IkRvY3VtaXplIiwib3JnIjoiVnpNdXlFd18zV3FpYWZjRCIsInN1YiI6IndlYmFwcCIsInVzZXIiOiJWek11eUV3XzNXcWlhZmNFIn0.NXZ6bo8mtvdZF_b9HavbidVUJqhmBA1zr0fSAPvbah0",
"user": {
"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": ""
}]
}
"token": `${token}`,
"user": user[0]
};
});
this.get('/users/VzMuyEw_3WqiafcE/permissions', (schema) => {
return schema.db.permissions;
this.get('/users/:id/permissions', (schema, request) => {
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 [{
"folderId": "VzMuyEw_3WqiafcG",
"userId": "VzMuyEw_3WqiafcE",
"canView": true,
"canEdit": true
"id": "VzMuyEw_3WqiafcE",
"created": "2016-05-11T15:08:24Z",
"revised": "2016-07-04T10:24:41Z",
"firstname": "Lennex",
"lastname": "Zinyando",
"email": "brizdigital@gmail.com",
"initials": "LZ",
"active": true,
"editor": false,
"admin": false,
"accounts": null
}];
});
this.put('/folders/VzMygEw_3WrtFzto/permissions', () => {
return [{
"orgId": "VzMuyEw_3WqiafcD",
"folderId": "VzMygEw_3WrtFzto",
"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.get('/sections/refresh', (schema, request) => {
let documentID = request.queryParams.documentID;
if (documentID) {
return {};
}
});
this.put('/folders/:id', (schema, request) => {
@ -264,18 +356,8 @@ export default function () {
return schema.db.folders.find(id);
});
this.get('/organizations/VzMuyEw_3WqiafcD', () => {
return {
"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.get('/organizations/VzMuyEw_3WqiafcD', (schema) => {
return schema.db.organizations[0];
});
this.put('/organizations/VzMuyEw_3WqiafcD', (schema, request) => {
@ -283,69 +365,15 @@ export default function () {
let message = JSON.parse(request.requestBody).title;
let allowAnonymousAccess = JSON.parse(request.requestBody).allowAnonymousAccess;
return {
"id": "VzMuyEw_3WqiafcD",
"created": "2016-05-11T15:08:24Z",
"revised": "2016-05-23T11:23:20Z",
"title": `${title}`,
"message": `${message}`,
"url": "",
"domain": "",
"email": "brizdigital@gmail.com",
"allowAnonymousAccess": `${allowAnonymousAccess}`
};
return schema.db.organizations.update('VzMuyEw_3WqiafcD', {
title: `${title}`,
message: `${message}`,
allowAnonymousAccess: `${allowAnonymousAccess}`
});
});
this.get('/users', () => {
return [{
"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.get('/users', (schema) => {
return schema.db.users;
});
this.post('/users', (schema, request) => {
@ -353,7 +381,7 @@ export default function () {
let lastname = JSON.parse(request.requestBody).lastname;
let email = JSON.parse(request.requestBody).email;
return {
let user = {
"id": "V0RmtUw_3QeDAMW7",
"created": "2016-05-24T14:35:33Z",
"revised": "2016-05-24T14:35:33Z",
@ -378,35 +406,14 @@ export default function () {
"domain": ""
}]
};
return schema.db.users.insert(user);
});
this.get('/users/VzMuyEw_3WqiafcE', () => {
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/:id', (schema, request) => {
let id = request.params.id;
let user = schema.db.users.where({ id: `${id}` });
return user[0];
});
this.put('/users/VzMuyEw_3WqiafcE', (schema, request) => {
@ -414,31 +421,11 @@ export default function () {
let lastname = JSON.parse(request.requestBody).lastname;
let email = JSON.parse(request.requestBody).email;
return {
"id": "VzMuyEw_3WqiafcE",
"created": "2016-05-11T15:08:24Z",
"revised": "2016-05-11T15:08:24Z",
"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": ""
}]
};
return schema.db.users.update('VzMuyEw_3WqiafcE', {
firstname: `${firstname}`,
lastname: `${lastname}`,
email: `${email}`
});
});
this.post('/folders/VzMuyEw_3WqiafcG/invitation', () => {

View file

@ -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.
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({
// name: 'Pete', // strings
// age: 20, // numbers
// tall: true, // booleans
// name: 'Pete', // strings
// age: 20, // numbers
// tall: true, // booleans
// email: function(i) { // and functions
// return 'person' + i + '@test.com';
// },
// email: function(i) { // and functions
// return 'person' + i + '@test.com';
// },
// firstName: faker.name.firstName, // using faker
// lastName: faker.name.firstName,
// zipCode: faker.address.zipCode
// firstName: faker.name.firstName, // using faker
// lastName: faker.name.firstName,
// zipCode: faker.address.zipCode
});

View 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
});

View 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
});

View 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
});

View file

@ -12,8 +12,8 @@
import Mirage, { faker } from 'ember-cli-mirage';
export default Mirage.Factory.extend({
"folderId": faker.list.cycle('V0Vy5Uw_3QeDAMW9', 'VzMuyEw_3WqiafcG', 'VzMygEw_3WrtFzto', 'VzMygEw_3WrtFzto'),
"userId": faker.list.cycle('VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', ''),
"folderId": faker.list.cycle('V0Vy5Uw_3QeDAMW9', 'VzMuyEw_3WqiafcG', 'VzMygEw_3WrtFzto', 'VzMygEw_3WrtFzto', "VzMygEw_3WrtFzto"),
"userId": faker.list.cycle('VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', 'VzMuyEw_3WqiafcE', '', 0),
"canView": true,
"canEdit": faker.list.cycle(true, true, true, false)
"canEdit": faker.list.cycle(true, true, true, false, false)
});

View 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": ""
}]
});

View file

@ -32,7 +32,8 @@
"waitToAppear",
"stubUserNotification",
"is",
"authenticateUser"
"authenticateUser",
"localStorage"
],
"node": false,
"browser": false,

View file

@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Anon access disabled');
test('visiting / when not authenticated and with { allowAnonymousAccess: false } takes user to login', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
visit('/');
andThen(function () {

View file

@ -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) {
server.create('meta', { allowAnonymousAccess: true });
server.createList('folder', 2);
visit('/');
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) {
server.create('meta', { allowAnonymousAccess: true });
server.createList('folder', 2);
visit('/');
andThen(function () {

View file

@ -16,7 +16,6 @@ moduleForAcceptance('Acceptance | Authentication');
test('visiting /auth/login and logging in', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
visit('/auth/login');
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) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
userLogin();
visit('/auth/logout');
click('.dropdown-menu a:contains(Logout)');
andThen(function () {
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) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
@ -53,7 +49,6 @@ test('successful sso login authenticates redirects to dashboard', function (asse
test('sso login with bad token should redirect to login', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
visit('/auth/sso/randomToken1234567890');

View file

@ -9,39 +9,38 @@
//
// https://documize.com
import { test, skip } from 'qunit';
import { test } from 'qunit';
import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
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.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project');
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(personalSpaces, 1, '1 personal space is listed');
});
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 () {
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');
});
});
skip('Adding a document to a space', function (assert) {
test('Adding a document to a space', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
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');
});
click('#start-document-button');
click('.actions div:contains(Add)', 'body');
click('.actions div:contains(Start) .flat-green');
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 () {
let numberOfDocuments = find('.documents-list li').length;
assert.equal(numberOfDocuments, 3, '3 documents listed');
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project');
});
});
test('visiting space settings page', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project');
@ -80,8 +81,6 @@ test('visiting space settings page', function (assert) {
test('changing space name', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
visit('/s/VzMuyEw_3WqiafcG/my-project');
@ -100,8 +99,6 @@ test('changing space name', function (assert) {
test('sharing a space', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
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) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
visit('/s/VzMygEw_3WrtFzto/test');
@ -150,8 +144,6 @@ test('changing space permissions', function (assert) {
test('deleting a space', function (assert) {
server.create('meta', { allowAnonymousAccess: false });
server.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
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.createList('folder', 2);
server.createList('permission', 4);
authenticateUser();
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');
});
click('#delete-documents-button');
waitToAppear('.drop-content');
click('.actions div:contains(Delete)', 'body');
click('.actions div:contains(Delete) .flat-red');
andThen(function () {
let numberOfDocuments = find('.documents-list li');
@ -197,6 +184,28 @@ 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() {
findWithAssert('.sidebar-menu');
findWithAssert('.options li:contains(General)');

View file

@ -15,7 +15,6 @@ import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
moduleForAcceptance('Acceptance | user profile');
test('visiting /profile', function (assert) {
server.createList('folder', 2);
authenticateUser();
visit('/profile');
@ -28,7 +27,6 @@ test('visiting /profile', function (assert) {
});
test('changing user details and email ', function (assert) {
server.createList('folder', 2);
authenticateUser();
visit('/profile');

View file

@ -91,9 +91,6 @@ test('add a new user', function (assert) {
fillIn('#newUserEmail', 'test.user@domain.com');
click('.button-blue');
// waitToAppear('.user-notification:contains(Added)');
// waitToDisappear('.user-notification:contains(Added)');
andThen(function () {
let numberOfUsers = find('.user-list tr').length;
assert.equal(numberOfUsers, 4, '3 Users listed');

View file

@ -2,31 +2,38 @@ import { module } from 'qunit';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
export default function(name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
stubAudit(this);
stubUserNotification(this);
export default function (name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
localStorage.setItem('folder', 'VzMuyEw_3WqiafcG');
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) {
options.beforeEach.apply(this, arguments);
}
if (options.beforeEach) {
options.beforeEach.apply(this, arguments);
}
this.register = (fullName, Factory) => {
let instance = this.application.__deprecatedInstance__;
let registry = instance.register ? instance : instance.registry;
this.register = (fullName, Factory) => {
let instance = this.application.__deprecatedInstance__;
let registry = instance.register ? instance : instance.registry;
return registry.register(fullName, Factory);
};
},
return registry.register(fullName, Factory);
};
},
afterEach() {
destroyApp(this.application);
afterEach() {
destroyApp(this.application);
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
}
});
if (options.afterEach) {
options.afterEach.apply(this, arguments);
}
}
});
}

View file

@ -9,16 +9,16 @@ import './stub-user-notification';
import './authenticate-user';
export default function startApp(attrs) {
let application;
let application;
let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
Ember.run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
Ember.run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
return application;
}

View file

@ -10,17 +10,16 @@
<meta property="dbname" content="{{.DBname}}" />
<meta property="dbhash" content="{{.DBhash}}" />
<meta name="author" content="Documize" />
<style>
#ember-testing-container, #ember-testing-container * {
/* Set position static to short-circuit Hubspot Tether's positioning */
/* https://github.com/HubSpot/tether/pull/98/ */
position: static !important;
}
.tether-container * {
z-index: 9999;
}
</style>
<style>
#ember-testing {
zoom: 100% !important;
}
#ember-testing-container {
/* Set position static to short-circuit Hubspot Tether's positioning */
/* https://github.com/HubSpot/tether/pull/98/ */
position: static !important;
}
</style>
{{content-for "head"}}
{{content-for "test-head"}}

52
build-community.sh Executable file
View 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."

View file

@ -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."

View file

@ -13,9 +13,11 @@
package main
import (
"github.com/documize/community/documize/api/endpoint"
"github.com/documize/community/documize/section"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/core/api/endpoint"
"github.com/documize/community/core/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
)

View file

@ -16,7 +16,7 @@ import (
"errors"
"net/http"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/core/api/request"
)
func endPoint() string {

View file

@ -18,7 +18,7 @@ import (
"net/http"
"path/filepath"
"github.com/documize/community/wordsmith/api"
api "github.com/documize/community/core/convapi"
"golang.org/x/net/context"
)

View file

@ -14,11 +14,11 @@ package convert
import (
"errors"
"github.com/documize/community/documize/api/convert/excerpt"
"github.com/documize/community/documize/api/convert/html"
"github.com/documize/community/documize/api/plugins"
"github.com/documize/community/wordsmith/api"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/convert/excerpt"
"github.com/documize/community/core/api/convert/html"
"github.com/documize/community/core/api/plugins"
api "github.com/documize/community/core/convapi"
"github.com/documize/community/core/utility"
"golang.org/x/net/context"
)

View file

@ -12,13 +12,14 @@
package convert_test
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"
"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"
)

View file

@ -14,7 +14,7 @@ package documizeapi
import (
"encoding/json"
"github.com/documize/community/wordsmith/api"
api "github.com/documize/community/core/convapi"
"golang.org/x/net/context"
)

View file

@ -18,7 +18,7 @@ import (
"unicode"
"unicode/utf8"
words "github.com/documize/community/wordsmith/wordlists/en-2012"
words "github.com/documize/community/core/wordlists/en-2012"
"github.com/rookii/paicehusk"
)

View file

@ -12,7 +12,7 @@
package excerpt_test
import "testing"
import "github.com/documize/community/documize/api/convert/excerpt"
import "github.com/documize/community/core/api/convert/excerpt"
import "strings"
import "fmt"

View file

@ -16,9 +16,9 @@ import (
"fmt"
"strings"
"github.com/documize/community/wordsmith/api"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
api "github.com/documize/community/core/convapi"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"

View file

@ -15,8 +15,8 @@ import (
"strings"
"testing"
)
import "github.com/documize/community/wordsmith/api"
import "github.com/documize/community/documize/api/convert/html"
import api "github.com/documize/community/core/convapi"
import "github.com/documize/community/core/api/convert/html"
const b string = `
<h1>Markdown: Basics</h1>

View file

@ -12,7 +12,7 @@
package md
import (
"github.com/documize/community/wordsmith/api"
api "github.com/documize/community/core/convapi"
"github.com/documize/blackfriday"

View file

@ -20,10 +20,10 @@ import (
"mime"
"net/http"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
"github.com/documize/community/core/log"
uuid "github.com/nu7hatch/gouuid"

View file

@ -23,15 +23,15 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/documize/community/documize/api/endpoint/models"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/documize/section/provider"
"github.com/documize/community/documize/web"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/endpoint/models"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
"github.com/documize/community/core/section/provider"
"github.com/documize/community/core/web"
"github.com/documize/community/core/environment"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// Authenticate user based up HTTP Authorization header.

View file

@ -20,13 +20,13 @@ import (
"net/http"
"strings"
"github.com/documize/community/documize/api/endpoint/models"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/store"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/wordsmith/api"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/api/endpoint/models"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/store"
"github.com/documize/community/core/api/util"
api "github.com/documize/community/core/convapi"
"github.com/documize/community/core/log"
uuid "github.com/nu7hatch/gouuid"

View file

@ -19,12 +19,12 @@ import (
"net/http"
"net/url"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/plugins"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/store"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/plugins"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/store"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"github.com/gorilla/mux"
)

View file

@ -36,8 +36,8 @@ import (
"time"
"github.com/documize/community/documize/api/plugins"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/environment"
"github.com/documize/community/core/log"
"github.com/documize/community/sdk/exttest"
)

View file

@ -15,9 +15,8 @@ import (
"fmt"
"net/http"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/store"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/api/store"
"github.com/documize/community/core/log"
)
var storageProvider store.StorageProvider
@ -26,18 +25,6 @@ func init() {
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) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest)

View file

@ -21,13 +21,13 @@ import (
"github.com/gorilla/mux"
"github.com/documize/community/documize/api/endpoint/models"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/mail"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/endpoint/models"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/mail"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// AddFolder creates a new folder.
@ -407,7 +407,7 @@ func SetFolderPermissions(w http.ResponseWriter, r *http.Request) {
hasEveryoneRole := false
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 {
role.OrgID = p.Context.OrgID
@ -742,13 +742,13 @@ func InviteToFolder(w http.ResponseWriter, r *http.Request) {
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)
log.Info(fmt.Sprintf("%s is sharing space %s with existing user %s", inviter.Email, label.Name, email))
} else {
// On-board new user
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)
if err != nil {

View file

@ -18,10 +18,11 @@ import (
"net/http"
"text/template"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"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).
@ -40,11 +41,13 @@ func GetMeta(w http.ResponseWriter, r *http.Request) {
return
}
product := core.Product()
data.OrgID = org.RefID
data.Title = org.Title
data.Message = org.Message
data.AllowAnonymousAccess = org.AllowAnonymousAccess
data.Version = AppVersion
data.Version = product.Version
json, err := json.Marshal(data)
@ -77,7 +80,7 @@ Disallow: /
// Anonymous access would mean we allow bots to crawl.
if org.AllowAnonymousAccess {
sitemap := getAppURL(p.Context, "sitemap.xml")
sitemap := p.Context.GetAppURL("sitemap.xml")
robots = fmt.Sprintf(
`User-agent: *
Disallow: /settings/
@ -135,7 +138,7 @@ func GetSitemap(w http.ResponseWriter, r *http.Request) {
for _, folder := range folders {
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")
items = append(items, item)
}
@ -149,7 +152,7 @@ func GetSitemap(w http.ResponseWriter, r *http.Request) {
for _, document := range documents {
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)))
item.Date = document.Revised.Format("2006-01-02T15:04:05.999999-07:00")
items = append(items, item)

View file

@ -15,7 +15,7 @@
package models
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.

View file

@ -18,10 +18,10 @@ import (
"io/ioutil"
"net/http"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"github.com/gorilla/mux"
)

View file

@ -19,13 +19,13 @@ import (
"net/http"
"strconv"
"github.com/documize/community/documize/api/endpoint/models"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/documize/section/provider"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/endpoint/models"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
"github.com/documize/community/core/section/provider"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"github.com/gorilla/mux"
)

220
core/api/endpoint/router.go Normal file
View 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))
}

View file

@ -15,11 +15,11 @@ import (
"encoding/json"
"net/http"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/documize/section/provider"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
"github.com/documize/community/core/section/provider"
"github.com/documize/community/core/log"
)
// GetSections returns available smart sections.

167
core/api/endpoint/server.go Normal file
View 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)
}
}

View file

@ -22,14 +22,14 @@ import (
"github.com/gorilla/mux"
"github.com/documize/community/documize/api/convert"
"github.com/documize/community/documize/api/endpoint/models"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/wordsmith/api"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/convert"
"github.com/documize/community/core/api/endpoint/models"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
api "github.com/documize/community/core/convapi"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
uuid "github.com/nu7hatch/gouuid"
)

View file

@ -20,13 +20,13 @@ import (
"net/url"
"strings"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/mail"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/wordsmith/api"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/mail"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/api/util"
api "github.com/documize/community/core/convapi"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"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])
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)
log.Info(fmt.Sprintf("%s invited by %s on %s", userModel.Email, inviter.Email, p.Context.AppURL))
} 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))
}
@ -605,9 +605,7 @@ func ForgotUserPassword(w http.ResponseWriter, r *http.Request) {
log.IfErr(tx.Commit())
appURL := getAppURL(p.Context, fmt.Sprintf("auth/reset/%s", token))
fmt.Println(appURL)
appURL := p.Context.GetAppURL(fmt.Sprintf("auth/reset/%s", token))
go mail.PasswordReset(user.Email, appURL)

View file

@ -19,9 +19,9 @@ import (
"html/template"
"net/smtp"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/documize/web"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/api/request"
"github.com/documize/community/core/log"
"github.com/documize/community/core/web"
)
// 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)
e := newEmail()
e.From = creds.SMTPsender()
e := NewEmail()
e.From = SMTPCreds.SMTPsender()
e.To = []string{recipient}
e.Subject = subject
@ -68,7 +68,7 @@ func InviteNewUser(recipient, inviter, url, username, password string) {
log.IfErr(t.Execute(buffer, &parameters))
e.HTML = buffer.Bytes()
err = e.Send(getHost(), getAuth())
err = e.Send(GetHost(), GetAuth())
if err != nil {
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)
e := newEmail()
e.From = creds.SMTPsender()
e := NewEmail()
e.From = SMTPCreds.SMTPsender()
e.To = []string{recipient}
e.Subject = subject
@ -115,7 +115,7 @@ func InviteExistingUser(recipient, inviter, url string) {
log.IfErr(t.Execute(buffer, &parameters))
e.HTML = buffer.Bytes()
err = e.Send(getHost(), getAuth())
err = e.Send(GetHost(), GetAuth())
if err != nil {
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"
e := newEmail()
e.From = creds.SMTPsender() //e.g. "Documize <hello@documize.com>"
e := NewEmail()
e.From = SMTPCreds.SMTPsender() //e.g. "Documize <hello@documize.com>"
e.To = []string{recipient}
e.Subject = subject
@ -155,7 +155,7 @@ func PasswordReset(recipient, url string) {
log.IfErr(t.Execute(buffer, &parameters))
e.HTML = buffer.Bytes()
err = e.Send(getHost(), getAuth())
err = e.Send(GetHost(), GetAuth())
if err != nil {
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)
e := newEmail()
e.From = creds.SMTPsender()
e := NewEmail()
e.From = SMTPCreds.SMTPsender()
e.To = []string{recipient}
e.Subject = subject
@ -206,7 +206,7 @@ func ShareFolderExistingUser(recipient, inviter, url, folder, intro string) {
log.IfErr(t.Execute(buffer, &parameters))
e.HTML = buffer.Bytes()
err = e.Send(getHost(), getAuth())
err = e.Send(GetHost(), GetAuth())
if err != nil {
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)
e := newEmail()
e.From = creds.SMTPsender()
e := NewEmail()
e.From = SMTPCreds.SMTPsender()
e.To = []string{recipient}
e.Subject = subject
@ -257,14 +257,15 @@ func ShareFolderNewUser(recipient, inviter, url, folder, invitationMessage strin
log.IfErr(t.Execute(buffer, &parameters))
e.HTML = buffer.Bytes()
err = e.Send(getHost(), getAuth())
err = e.Send(GetHost(), GetAuth())
if err != nil {
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", "password") },
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") },
}
// Helper to return SMTP credentials
func getAuth() smtp.Auth {
a := smtp.PlainAuth("", creds.SMTPuserid(), creds.SMTPpassword(), creds.SMTPhost())
//fmt.Printf("DEBUG getAuth() = %#v\n", a)
// GetAuth to return SMTP credentials
func GetAuth() smtp.Auth {
a := smtp.PlainAuth("", SMTPCreds.SMTPuserid(), SMTPCreds.SMTPpassword(), SMTPCreds.SMTPhost())
//fmt.Printf("DEBUG GetAuth() = %#v\n", a)
return a
}
// Helper to return SMTP host details
func getHost() string {
h := creds.SMTPhost() + ":" + creds.SMTPport()
//fmt.Printf("DEBUG getHost() = %#v\n", h)
// GetHost to return SMTP host details
func GetHost() string {
h := SMTPCreds.SMTPhost() + ":" + SMTPCreds.SMTPport()
//fmt.Printf("DEBUG GetHost() = %#v\n", h)
return h
}

View file

@ -19,7 +19,7 @@ import (
"strings"
"testing"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/log"
)
func TestMail(t *testing.T) {

View file

@ -45,7 +45,6 @@ import (
"encoding/base64"
"errors"
"fmt"
"github.com/documize/community/wordsmith/log"
"io"
"mime"
"mime/multipart"
@ -56,6 +55,8 @@ import (
"path/filepath"
"strings"
"time"
"github.com/documize/community/core/log"
)
const (
@ -77,8 +78,8 @@ type Email struct {
ReadReceipt []string
}
// newEmail creates an Email, and returns the pointer to it.
func newEmail() *Email {
// NewEmail creates an Email, and returns the pointer to it.
func NewEmail() *Email {
return &Email{Headers: textproto.MIMEHeader{}}
}

View file

@ -18,14 +18,14 @@ import (
"io/ioutil"
"time"
"github.com/documize/community/documize/api/convert/apidocumizecom"
"github.com/documize/community/documize/api/convert/documizeapi"
"github.com/documize/community/documize/api/convert/html"
"github.com/documize/community/documize/api/convert/md"
"github.com/documize/community/documize/api/request"
"github.com/documize/community/wordsmith/api"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/api/convert/apidocumizecom"
"github.com/documize/community/core/api/convert/documizeapi"
"github.com/documize/community/core/api/convert/html"
"github.com/documize/community/core/api/convert/md"
"github.com/documize/community/core/api/request"
api "github.com/documize/community/core/convapi"
"github.com/documize/community/core/environment"
"github.com/documize/community/core/log"
"github.com/documize/glick"
)

View file

@ -14,9 +14,9 @@ package request
import (
"database/sql"
"fmt"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"time"
)

View file

@ -14,7 +14,7 @@ package request
/* TODO(Elliott)
import (
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/core/environment"
"testing"
)

View file

@ -16,9 +16,9 @@ import (
"strings"
"time"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// AddAttachment inserts the given record into the database attachement table.

View file

@ -17,7 +17,7 @@ import (
"testing"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/core/environment"
)
const testAtt = "TestAttachment"

View file

@ -15,7 +15,7 @@ import (
"bytes"
"errors"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/utility"
)
/* NOT CURRENTLY USED

View file

@ -20,7 +20,7 @@ import (
"github.com/gorilla/context"
"github.com/jmoiron/sqlx"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/core/log"
)
var rc = Context{}
@ -42,6 +42,17 @@ type Context struct {
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.
func NewContext() Context {
return Context{}

View file

@ -13,7 +13,7 @@ package request
/* TODO(Elliott)
import (
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/core/environment"
"net/http"
"testing"
)

View file

@ -18,9 +18,9 @@ import (
"strings"
"time"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// 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) {
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
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`
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)
return
}
//SELECT CONVERT_TZ(a.created, @@session.time_zone, '+00:00') as
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
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')
ORDER BY a.created DESC;`

View file

@ -14,7 +14,7 @@ package request
/* TODO(Elliott)
import (
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/core/environment"
"testing"
"time"
)

View file

@ -15,13 +15,15 @@ import (
"fmt"
"os"
"strings"
"time"
"github.com/jmoiron/sqlx"
"github.com/documize/community/documize/database"
"github.com/documize/community/wordsmith/environment"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/database"
"github.com/documize/community/core/environment"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"github.com/documize/community/core/web"
)
var connectionString string
@ -58,6 +60,7 @@ func init() {
Db.SetMaxIdleConns(30)
Db.SetMaxOpenConns(100)
Db.SetConnMaxLifetime(time.Second * 14400)
err = Db.Ping()
@ -68,13 +71,15 @@ func init() {
}
// go into setup mode if required
if database.Check(Db, connectionString) {
if err := database.Migrate(true /* the config table exists */); err != nil {
log.Error("Unable to run database migration: ", err)
os.Exit(2)
if web.SiteMode != web.SiteModeOffline {
if database.Check(Db, connectionString) {
if err := database.Migrate(true /* the config table exists */); err != nil {
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

View file

@ -15,9 +15,9 @@ import (
"fmt"
"time"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// AddLabel adds new folder into the store.

View file

@ -16,9 +16,9 @@ import (
"fmt"
"time"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// AddLabelRole inserts the given record into the labelrole database table.

View file

@ -17,10 +17,10 @@ import (
"strings"
"time"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/web"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/web"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
"github.com/jmoiron/sqlx"
)

View file

@ -18,10 +18,10 @@ import (
"github.com/jmoiron/sqlx"
"github.com/documize/community/documize/api/endpoint/models"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/endpoint/models"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"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.

View file

@ -21,9 +21,9 @@ import (
_ "github.com/go-sql-driver/mysql" // required for sqlx but not directly called
"github.com/jmoiron/sqlx"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// SearchManager type provides the datastructure for the queues of activity to be serialized through a single background goroutine.

View file

@ -14,8 +14,8 @@ package request
// This file contains the code for initial set-up of a database
import (
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/documize/api/util"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/api/util"
)
func SetupPersister() (*Persister, error) {

View file

@ -18,9 +18,9 @@ import (
"database/sql"
"github.com/documize/community/documize/api/entity"
"github.com/documize/community/wordsmith/log"
"github.com/documize/community/wordsmith/utility"
"github.com/documize/community/core/api/entity"
"github.com/documize/community/core/log"
"github.com/documize/community/core/utility"
)
// AddUser adds the given user record to the user table.

Some files were not shown because too many files have changed in this diff Show more