1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Merge pull request #61 from documize/doc-wiki-layout

switch between docs and wiki layout
This commit is contained in:
Harvey Kandola 2016-11-20 19:56:31 -08:00 committed by GitHub
commit e0d2dd47df
18 changed files with 704 additions and 620 deletions

View file

@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
## Latest version
v0.32.0
v0.33.0
## OS Support

View file

@ -28,6 +28,10 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
didReceiveAttrs() {
this.set('saveTemplate.name', this.get('document.name'));
this.set('saveTemplate.description', this.get('document.excerpt'));
let doc = this.get('document');
this.set('layoutLabel', doc.get('layout') === 'doc' ? 'Wiki style' : 'Document style');
},
didRender() {
@ -53,6 +57,17 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
window.print();
},
changeLayout() {
let doc = this.get('document');
let layout = doc.get('layout') === 'doc' ? 'wiki' : 'doc';
doc.set('layout', layout);
this.attrs.onSaveMeta(doc);
this.set('layoutLabel', doc.get('layout') === 'doc' ? 'Wiki style' : 'Document style');
},
saveTemplate() {
var name = this.get('saveTemplate.name');
var excerpt = this.get('saveTemplate.description');

View file

@ -48,6 +48,7 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
title: "Empty",
description: "An empty canvas for your words",
img: "template-blank",
layout: "doc",
locked: true
};

View file

@ -25,6 +25,7 @@ export default Model.extend({
userId: attr('string'),
tags: attr('string'),
template: attr('boolean'),
layout: attr('string'),
// client-side property
selected: attr('boolean', { defaultValue: false }),

View file

@ -15,6 +15,10 @@
display: none !important;
}
.zone-content {
padding: 0 !important;
}
.document-view {
.attachment-zone,
.document-summary,
@ -28,4 +32,10 @@
display: block !important;
}
}
.doc-layout {
padding: 0 !important;
box-shadow: none !important;
margin: 0 !important;
}
}

View file

@ -1,3 +1,13 @@
.wiki-layout {
}
.doc-layout {
padding: 60px 50px;
box-shadow: 0 0 0 0.75pt $color-stroke,0 0 3pt 0.75pt $color-stroke;
margin: 30px 40px 50px 40px;
}
.document-view {
.print-title {
display: none;

View file

@ -38,7 +38,13 @@
{{#dropdown-menu target="document-toolbar-menu" position="bottom right" open="click" onOpenCallback=(action 'onMenuOpen') onCloseCallback=(action 'onMenuOpen')}}
<ul class="menu">
{{#if isEditor}}
<li class="item" {{action 'changeLayout'}} >{{layoutLabel}}</li>
<li class="divider"></li>
{{/if}}
<li class="item" id="print-document-button" {{action 'printDocument'}}>Print</li>
{{#if isEditor}}
<li class="divider"></li>
<li class="item" id="delete-document-button">Delete</li>

View file

@ -1,4 +1,4 @@
<div class="document-view">
<div class="document-view {{document.layout}}-layout">
{{#if document.template}}
<div class="is-template">TEMPLATE</div>
{{/if}}

View file

@ -1,11 +1,11 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
// by contacting <sales@documize.com>.
//
// https://documize.com
@ -14,5 +14,10 @@ export default {
Public: 1,
Private: 2,
Protected: 3
}
};
},
DisplayLayout: {
DisplayLayoutDoc: "doc",
DisplayLayoutWiki: "wiki"
}
};

View file

@ -1,6 +1,6 @@
{
"name": "documize",
"version": "0.32.0",
"version": "0.33.0",
"description": "The Document IDE",
"private": true,
"directories": {

View file

@ -336,18 +336,12 @@ func StartDocumentFromSavedTemplate(w http.ResponseWriter, r *http.Request) {
d.Excerpt = "A new document"
d.Slug = utility.MakeSlug(d.Title)
d.Tags = ""
d.Layout = "doc"
d.LabelID = folderID
documentID := util.UniqueID()
d.RefID = documentID
var pages = []entity.Page{}
//var pages = make([]entity.Page, 1, 1)
//pages[0] = entity.Page{}
//pages[0].Title = "Heading"
//pages[0].Body = "<p>Some content here.</p>"
//pages[0].Level = 1
//pages[0].Sequence = 1
var attachments = []entity.Attachment{}
// Fetch document and associated pages, attachments if we have template ID
@ -394,13 +388,22 @@ func StartDocumentFromSavedTemplate(w http.ResponseWriter, r *http.Request) {
}
for _, page := range pages {
meta, err2 := p.GetPageMeta(page.RefID)
if err2 != nil {
log.IfErr(tx.Rollback())
writeGeneralSQLError(w, method, err)
return
}
page.DocumentID = documentID
pageID := util.UniqueID()
page.RefID = pageID
meta := entity.PageMeta{}
// meta := entity.PageMeta{}
meta.PageID = pageID
meta.RawBody = page.Body
meta.DocumentID = documentID
// meta.RawBody = page.Body
model := models.PageModel{}
model.Page = page

View file

@ -152,6 +152,7 @@ type Document struct {
Slug string `json:"-"`
Tags string `json:"tags"`
Template bool `json:"template"`
Layout string `json:"layout"`
}
// SetDefaults ensures on blanks and cleans.
@ -161,6 +162,8 @@ func (d *Document) SetDefaults() {
if len(d.Title) == 0 {
d.Title = "Document"
}
d.Layout = "doc"
}
// Attachment represents an attachment to a document.

View file

@ -28,8 +28,11 @@ func (p *Persister) AddDocument(document entity.Document) (err error) {
document.OrgID = p.Context.OrgID
document.Created = time.Now().UTC()
document.Revised = document.Created // put same time in both fields
if document.Layout == "" {
document.Layout = "doc"
}
stmt, err := p.Context.Transaction.Preparex("INSERT INTO document (refId, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
stmt, err := p.Context.Transaction.Preparex("INSERT INTO document (refId, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
defer utility.Close(stmt)
if err != nil {
@ -37,7 +40,7 @@ func (p *Persister) AddDocument(document entity.Document) (err error) {
return
}
_, err = stmt.Exec(document.RefID, document.OrgID, document.LabelID, document.UserID, document.Job, document.Location, document.Title, document.Excerpt, document.Slug, document.Tags, document.Template, document.Created, document.Revised)
_, err = stmt.Exec(document.RefID, document.OrgID, document.LabelID, document.UserID, document.Job, document.Location, document.Title, document.Excerpt, document.Slug, document.Tags, document.Template, document.Layout, document.Created, document.Revised)
if err != nil {
log.Error("Unable to execute insert for document", err)
@ -53,7 +56,7 @@ func (p *Persister) AddDocument(document entity.Document) (err error) {
func (p *Persister) GetDocument(id string) (document entity.Document, err error) {
err = nil
stmt, err := Db.Preparex("SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised FROM document WHERE orgid=? and refid=?")
stmt, err := Db.Preparex("SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? and refid=?")
defer utility.Close(stmt)
if err != nil {
@ -112,7 +115,7 @@ func (p *Persister) GetDocumentMeta(id string) (meta entity.DocumentMeta, err er
// GetDocuments returns a slice containg all of the the documents for the client's organisation, with the most recient first.
func (p *Persister) GetDocuments() (documents []entity.Document, err error) {
err = Db.Select(&documents, "SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised FROM document WHERE orgid=? AND template=0 ORDER BY revised DESC", p.Context.OrgID)
err = Db.Select(&documents, "SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? AND template=0 ORDER BY revised DESC", p.Context.OrgID)
if err != nil {
log.Error(fmt.Sprintf("Unable to execute select documents for org %s", p.Context.OrgID), err)
@ -125,7 +128,7 @@ func (p *Persister) GetDocuments() (documents []entity.Document, err error) {
// GetDocumentsByFolder returns a slice containing the documents for a given folder, most recient first.
func (p *Persister) GetDocumentsByFolder(folderID string) (documents []entity.Document, err error) {
err = nil
err = Db.Select(&documents, "SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised FROM document WHERE orgid=? AND template=0 AND labelid=? ORDER BY revised DESC", p.Context.OrgID, folderID)
err = Db.Select(&documents, "SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? AND template=0 AND labelid=? ORDER BY revised DESC", p.Context.OrgID, folderID)
if err != nil {
log.Error(fmt.Sprintf("Unable to execute select documents for org %s", p.Context.OrgID), err)
@ -141,7 +144,7 @@ func (p *Persister) GetDocumentsByTag(tag string) (documents []entity.Document,
tagQuery := "tags LIKE '%#" + tag + "#%'"
err = Db.Select(&documents,
`SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised FROM document WHERE orgid=? AND template=0 AND `+tagQuery+` AND labelid IN
`SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? AND template=0 AND `+tagQuery+` AND labelid IN
(SELECT refid from label WHERE orgid=? AND type=2 AND userid=?
UNION ALL SELECT refid FROM label a where orgid=? AND type=1 AND refid IN (SELECT labelid from labelrole WHERE orgid=? AND userid='' AND (canedit=1 OR canview=1))
UNION ALL SELECT refid FROM label a where orgid=? AND type=3 AND refid IN (SELECT labelid from labelrole WHERE orgid=? AND userid=? AND (canedit=1 OR canview=1)))
@ -166,7 +169,7 @@ func (p *Persister) GetDocumentsByTag(tag string) (documents []entity.Document,
// GetDocumentTemplates returns a slice containing the documents available as templates to the client's organisation, in title order.
func (p *Persister) GetDocumentTemplates() (documents []entity.Document, err error) {
err = Db.Select(&documents,
`SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised FROM document WHERE orgid=? AND template=1 AND labelid IN
`SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? AND template=1 AND labelid IN
(SELECT refid from label WHERE orgid=? AND type=2 AND userid=?
UNION ALL SELECT refid FROM label a where orgid=? AND type=1 AND refid IN (SELECT labelid from labelrole WHERE orgid=? AND userid='' AND (canedit=1 OR canview=1))
UNION ALL SELECT refid FROM label a where orgid=? AND type=3 AND refid IN (SELECT labelid from labelrole WHERE orgid=? AND userid=? AND (canedit=1 OR canview=1)))
@ -283,7 +286,7 @@ func (p *Persister) SearchDocument(keywords string) (results []entity.DocumentSe
func (p *Persister) UpdateDocument(document entity.Document) (err error) {
document.Revised = time.Now().UTC()
stmt, err := p.Context.Transaction.PrepareNamed("UPDATE document SET labelid=:labelid, userid=:userid, job=:job, location=:location, title=:title, excerpt=:excerpt, slug=:slug, tags=:tags, template=:template, revised=:revised WHERE orgid=:orgid AND refid=:refid")
stmt, err := p.Context.Transaction.PrepareNamed("UPDATE document SET labelid=:labelid, userid=:userid, job=:job, location=:location, title=:title, excerpt=:excerpt, slug=:slug, tags=:tags, template=:template, layout=:layout, revised=:revised WHERE orgid=:orgid AND refid=:refid")
defer utility.Close(stmt)
if err != nil {

View file

@ -38,6 +38,7 @@ func ConvertFileResult(filename string, fileResult *api.DocumentConversionRespon
document.LabelID = ""
document.Job = ""
document.Location = filename
if fileResult != nil {
if len(fileResult.Pages) > 0 {
document.Title = fileResult.Pages[0].Title

View file

@ -131,6 +131,7 @@ CREATE TABLE IF NOT EXISTS `document` (
`slug` NVARCHAR(2000) NOT NULL,
`tags` NVARCHAR(1000) NOT NULL DEFAULT '',
`template` BOOL NOT NULL DEFAULT 0,
`layout` CHAR(10) NOT NULL DEFAULT 'doc',
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),

View file

@ -0,0 +1,2 @@
/* community edition */
ALTER TABLE document ADD COLUMN `layout` CHAR(10) NOT NULL DEFAULT 'doc' AFTER `template`;

View file

@ -26,7 +26,7 @@ type ProdInfo struct {
// Product returns product edition details
func Product() (p ProdInfo) {
p.Major = "0"
p.Minor = "32"
p.Minor = "33"
p.Patch = "0"
p.Version = fmt.Sprintf("%s.%s.%s", p.Major, p.Minor, p.Patch)
p.Edition = "Community"

File diff suppressed because one or more lines are too long