Skip to content

Commit

Permalink
bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
HarveyKandola committed Aug 22, 2017
1 parent 07c8238 commit c235fb5
Show file tree
Hide file tree
Showing 9 changed files with 819 additions and 664 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li

## Latest version

v1.52.2
v1.53.0

## OS Support

Expand Down
3 changes: 0 additions & 3 deletions core/database/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ type migrationsT []string

// migrations returns a list of the migrations to update the database as required for this version of the code.
func migrations(lastMigration string) (migrationsT, error) {

lastMigration = strings.TrimPrefix(strings.TrimSuffix(lastMigration, `"`), `"`)

//fmt.Println(`DEBUG Migrations("`+lastMigration+`")`)

files, err := web.AssetDir(migrationsDir)
if err != nil {
return nil, err
Expand Down
50 changes: 27 additions & 23 deletions domain/meta/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (h *Handler) RobotsTxt(w http.ResponseWriter, r *http.Request) {
ctx := domain.GetRequestContext(r)

dom := organization.GetSubdomainFromHost(r)
org, err := h.Store.Organization.GetOrganizationByDomain(dom)
o, err := h.Store.Organization.GetOrganizationByDomain(dom)

// default is to deny
robots :=
Expand All @@ -78,29 +78,31 @@ func (h *Handler) RobotsTxt(w http.ResponseWriter, r *http.Request) {
`

if err != nil {
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom), err)
h.Runtime.Log.Info(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom))
o = org.Organization{}
o.AllowAnonymousAccess = false
}

// Anonymous access would mean we allow bots to crawl.
if org.AllowAnonymousAccess {
if o.AllowAnonymousAccess {
sitemap := ctx.GetAppURL("sitemap.xml")
robots = fmt.Sprintf(
`User-agent: *
Disallow: /settings/
Disallow: /settings/*
Disallow: /profile/
Disallow: /profile/*
Disallow: /auth/login/
Disallow: /auth/login/
Disallow: /auth/logout/
Disallow: /auth/logout/*
Disallow: /auth/reset/*
Disallow: /auth/reset/*
Disallow: /auth/sso/
Disallow: /auth/sso/*
Disallow: /share
Disallow: /share/*
Sitemap: %s`, sitemap)
Disallow: /settings/
Disallow: /settings/*
Disallow: /profile/
Disallow: /profile/*
Disallow: /auth/login/
Disallow: /auth/login/
Disallow: /auth/logout/
Disallow: /auth/logout/*
Disallow: /auth/reset/*
Disallow: /auth/reset/*
Disallow: /auth/sso/
Disallow: /auth/sso/*
Disallow: /share
Disallow: /share/*
Sitemap: %s`, sitemap)
}

response.WriteBytes(w, []byte(robots))
Expand All @@ -113,10 +115,12 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
ctx := domain.GetRequestContext(r)

dom := organization.GetSubdomainFromHost(r)
org, err := h.Store.Organization.GetOrganizationByDomain(dom)
o, err := h.Store.Organization.GetOrganizationByDomain(dom)

if err != nil {
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom), err)
h.Runtime.Log.Info(fmt.Sprintf("%s failed to get Organization for domain %s", method, dom))
o = org.Organization{}
o.AllowAnonymousAccess = false
}

sitemap :=
Expand All @@ -131,9 +135,9 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
var items []sitemapItem

// Anonymous access means we announce folders/documents shared with 'Everyone'.
if org.AllowAnonymousAccess {
if o.AllowAnonymousAccess {
// Grab shared folders
folders, err := h.Store.Space.PublicSpaces(ctx, org.RefID)
folders, err := h.Store.Space.PublicSpaces(ctx, o.RefID)
if err != nil {
folders = []space.Space{}
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get folders for domain %s", method, dom), err)
Expand All @@ -148,7 +152,7 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {

// Grab documents from shared folders
var documents []doc.SitemapDocument
documents, err = h.Store.Document.PublicDocuments(ctx, org.RefID)
documents, err = h.Store.Document.PublicDocuments(ctx, o.RefID)
if err != nil {
documents = []doc.SitemapDocument{}
h.Runtime.Log.Error(fmt.Sprintf("%s failed to get documents for domain %s", method, dom), err)
Expand Down
95 changes: 95 additions & 0 deletions domain/space/space_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package space

import (
"testing"

"github.com/documize/community/core/uniqueid"
"github.com/documize/community/domain/test"
"github.com/documize/community/model/space"
)

//add a new space and get it. if the get returns the same space as the one just added it passes the test
func TestAddSpace(t *testing.T) {
//Setup - get the necessary info to add a space, generate a test space
rt, s, ctx := test.SetupTest()
var err error

//Run test - Add a space to the DB, read it to make sure it was added correctly
ctx.Transaction, err = rt.Db.Beginx()
if err != nil {
return
}
sp := space.Space{}
sp.RefID = uniqueid.Generate()
sp.OrgID = ctx.OrgID
sp.Type = space.ScopePrivate
sp.UserID = ctx.UserID
sp.Name = "test"

err = s.Space.Add(ctx, sp)
if err != nil {
ctx.Transaction.Rollback()
return
}
ctx.Transaction.Commit()

sp2, err := s.Space.Get(ctx, sp.RefID)
if err != nil {
return
}

if sp != sp2 {
t.Errorf("Test Failed, space one (%v) does not match space 2(%v)", sp, sp2)
}
}

// Function to create a space with an identifier, remove it and then try get it using that Identifier, if it doesnt get it, it is removed
// func TestRemoveSpace(t *testing.T) {
// //Setup - get the necessary info to add a space, generate a test space
// rt, s, ctx := test.SetupTest()
// var err error
// println("marker 1")

// //Run test - Add a space
// ctx.Transaction, err = rt.Db.Beginx()
// if err != nil {
// return
// }

// println("marker 2")

// sp := space.Space{}
// sp.RefID = uniqueid.Generate()
// sp.OrgID = ctx.OrgID
// sp.Type = space.ScopePrivate
// sp.UserID = ctx.UserID
// sp.Name = "test-toBeDeleted"

// println("marker 3")

// err = s.Space.Add(ctx, sp)
// if err != nil {
// ctx.Transaction.Rollback()
// return
// }
// ctx.Transaction.Commit()

// //Remove the space
// ctx.Transaction, err = rt.Db.Beginx()

// _, err = s.Space.Delete(ctx, sp.RefID)

// move := "moveToId"

// err = s.Document.MoveDocumentSpace(ctx, sp.RefID, move)

// err = s.Space.MoveSpaceRoles(ctx, sp.RefID, move)

// _, err = s.Pin.DeletePinnedSpace(ctx, sp.RefID)

// s.Audit.Record(ctx, audit.EventTypeSpaceDelete)

// ctx.Transaction.Commit()

// _, err = s.Space.Get(ctx, sp.RefID)
// }
59 changes: 59 additions & 0 deletions domain/test/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package test

import (
"fmt"

"github.com/documize/community/core/env"
"github.com/documize/community/domain"
"github.com/documize/community/edition/boot"
"github.com/documize/community/edition/logging"
_ "github.com/go-sql-driver/mysql" // testing
)

// SetupTest prepares test environment
func SetupTest() (rt *env.Runtime, s *domain.Store, ctx domain.RequestContext) {
rt, s = startRuntime()
ctx = setupContext()
return rt, s, ctx
}

func startRuntime() (rt *env.Runtime, s *domain.Store) {
rt = new(env.Runtime)
s = new(domain.Store)
rt.Log = logging.NewLogger()

rt.Product = env.ProdInfo{}
rt.Product.Major = "0"
rt.Product.Minor = "0"
rt.Product.Patch = "0"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = "Test"
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
rt.Product.License = env.License{}
rt.Product.License.Seats = 1
rt.Product.License.Valid = true
rt.Product.License.Trial = false
rt.Product.License.Edition = "Community"

// parse settings from command line and environment
rt.Flags = env.ParseFlags()
boot.InitRuntime(rt, s)

// section.Register(rt, s)

return rt, s
}

// setup testing context
func setupContext() domain.RequestContext {
ctx := domain.RequestContext{}
ctx.AllowAnonymousAccess = true
ctx.Authenticated = true
ctx.Administrator = true
ctx.Guest = false
ctx.Editor = true
ctx.Global = true
ctx.UserID = "1"
ctx.OrgID = "1"
return ctx
}
4 changes: 2 additions & 2 deletions edition/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func main() {
// product details
rt.Product = env.ProdInfo{}
rt.Product.Major = "1"
rt.Product.Minor = "52"
rt.Product.Patch = "2"
rt.Product.Minor = "53"
rt.Product.Patch = "0"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = "Community"
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
Expand Down
1,256 changes: 628 additions & 628 deletions embed/bindata_assetfs.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "documize",
"version": "1.52.2",
"version": "1.53.0",
"description": "The Document IDE",
"private": true,
"repository": "",
Expand Down
12 changes: 6 additions & 6 deletions meta.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"community":
{
"version": "1.52.2",
"version": "1.53.0",
"major": 1,
"minor": 52,
"patch": 2
"minor": 53,
"patch": 0
},
"enterprise":
{
"version": "1.54.2",
"version": "1.55.0",
"major": 1,
"minor": 54,
"patch": 2
"minor": 55,
"patch": 0
}
}

0 comments on commit c235fb5

Please sign in to comment.