mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
GitHub section improvements
This commit is contained in:
parent
60131df628
commit
65666c5a89
11 changed files with 686 additions and 668 deletions
|
@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
|
||||||
|
|
||||||
## Latest version
|
## Latest version
|
||||||
|
|
||||||
v1.47.1
|
v1.47.2
|
||||||
|
|
||||||
## OS Support
|
## OS Support
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-github-render {
|
.section-github-render {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,7 @@
|
||||||
|
|
||||||
.github-table tbody tr td {
|
.github-table tbody tr td {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
padding: 5px 20px !important;
|
padding: 5px 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.github-table .right-column {
|
.github-table .right-column {
|
||||||
|
@ -114,6 +116,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.contributor-meta {
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 1%;
|
||||||
|
}
|
||||||
|
|
||||||
span.issue-state {
|
span.issue-state {
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
@ -123,6 +130,6 @@
|
||||||
img.github-avatar {
|
img.github-avatar {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
margin-right: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "documize",
|
"name": "documize",
|
||||||
"version": "1.47.1",
|
"version": "1.47.2",
|
||||||
"description": "The Document IDE",
|
"description": "The Document IDE",
|
||||||
"private": true,
|
"private": true,
|
||||||
"repository": "",
|
"repository": "",
|
||||||
|
|
|
@ -26,7 +26,7 @@ import (
|
||||||
// Msword type provides a peg to hang the Convert method on.
|
// Msword type provides a peg to hang the Convert method on.
|
||||||
type Msword struct{}
|
type Msword struct{}
|
||||||
|
|
||||||
// Convert converts a file into the Countersoft Documize format.
|
// Convert converts a file into the Documize format.
|
||||||
func (file *Msword) Convert(r api.DocumentConversionRequest, reply *api.DocumentConversionResponse) error {
|
func (file *Msword) Convert(r api.DocumentConversionRequest, reply *api.DocumentConversionResponse) error {
|
||||||
byts, err := json.Marshal(r)
|
byts, err := json.Marshal(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/documize/community/core/api/request"
|
"github.com/documize/community/core/api/request"
|
||||||
"github.com/documize/community/core/api/util"
|
"github.com/documize/community/core/api/util"
|
||||||
"github.com/documize/community/core/log"
|
"github.com/documize/community/core/log"
|
||||||
|
"github.com/documize/community/core/section/provider"
|
||||||
"github.com/documize/community/core/utility"
|
"github.com/documize/community/core/utility"
|
||||||
"github.com/documize/community/core/web"
|
"github.com/documize/community/core/web"
|
||||||
)
|
)
|
||||||
|
@ -238,9 +239,19 @@ func Authorize(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidToken finds and validates authentication token.
|
// ValidateAuthToken finds and validates authentication token.
|
||||||
func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
func ValidateAuthToken(w http.ResponseWriter, r *http.Request) {
|
||||||
valid = false
|
|
||||||
|
log.Info("cb gh")
|
||||||
|
// TODO should this go after token validation?
|
||||||
|
if s := r.URL.Query().Get("section"); s != "" {
|
||||||
|
if err := provider.Callback(s, w, r); err != nil {
|
||||||
|
log.Error("section validation failure", err)
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
token := findJWT(r)
|
token := findJWT(r)
|
||||||
hasToken := len(token) > 1
|
hasToken := len(token) > 1
|
||||||
|
@ -263,6 +274,7 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
||||||
|
|
||||||
// Inability to find org record spells the end of this request.
|
// Inability to find org record spells the end of this request.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +286,7 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
||||||
domain := request.GetSubdomainFromHost(r)
|
domain := request.GetSubdomainFromHost(r)
|
||||||
domain2 := request.GetRequestSubdomain(r)
|
domain2 := request.GetRequestSubdomain(r)
|
||||||
if org.Domain != domain && org.Domain != domain2 {
|
if org.Domain != domain && org.Domain != domain2 {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +296,7 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
||||||
// So you have a bad token
|
// So you have a bad token
|
||||||
if hasToken {
|
if hasToken {
|
||||||
if tokenErr != nil {
|
if tokenErr != nil {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -305,23 +319,23 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
||||||
context.Global = false
|
context.Global = false
|
||||||
|
|
||||||
// Fetch user permissions for this org
|
// Fetch user permissions for this org
|
||||||
if context.Authenticated {
|
if !context.Authenticated {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
user, err := getSecuredUser(p, org.RefID, context.UserID)
|
user, err := getSecuredUser(p, org.RefID, context.UserID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Administrator = user.Admin
|
context.Administrator = user.Admin
|
||||||
context.Editor = user.Editor
|
context.Editor = user.Editor
|
||||||
context.Global = user.Global
|
context.Global = user.Global
|
||||||
}
|
|
||||||
|
|
||||||
request.SetContext(r, context)
|
|
||||||
p = request.GetPersister(r)
|
|
||||||
|
|
||||||
valid = context.Authenticated || org.AllowAnonymousAccess
|
|
||||||
|
|
||||||
|
util.WriteJSON(w, user)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,23 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// UploadConvertDocument is an endpoint to both upload and convert a document
|
||||||
|
func UploadConvertDocument(w http.ResponseWriter, r *http.Request) {
|
||||||
|
job, folderID, orgID := uploadDocument(w, r)
|
||||||
|
if job == "" {
|
||||||
|
return // error already handled
|
||||||
|
}
|
||||||
|
|
||||||
|
convertDocument(w, r, job, folderID, api.ConversionJobRequest{
|
||||||
|
Job: job,
|
||||||
|
IndexDepth: 4,
|
||||||
|
OrgID: orgID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func uploadDocument(w http.ResponseWriter, r *http.Request) (string, string, string) {
|
func uploadDocument(w http.ResponseWriter, r *http.Request) (string, string, string) {
|
||||||
method := "uploadDocument"
|
method := "uploadDocument"
|
||||||
p := request.GetPersister(r)
|
p := request.GetPersister(r)
|
||||||
|
|
||||||
params := mux.Vars(r)
|
params := mux.Vars(r)
|
||||||
folderID := params["folderID"]
|
folderID := params["folderID"]
|
||||||
|
|
||||||
|
@ -47,7 +60,6 @@ func uploadDocument(w http.ResponseWriter, r *http.Request) (string, string, str
|
||||||
|
|
||||||
// grab file
|
// grab file
|
||||||
filedata, filename, err := r.FormFile("attachment")
|
filedata, filename, err := r.FormFile("attachment")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeMissingDataError(w, method, "attachment")
|
writeMissingDataError(w, method, "attachment")
|
||||||
return "", "", ""
|
return "", "", ""
|
||||||
|
@ -55,7 +67,6 @@ func uploadDocument(w http.ResponseWriter, r *http.Request) (string, string, str
|
||||||
|
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
_, err = io.Copy(b, filedata)
|
_, err = io.Copy(b, filedata)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeServerError(w, method, err)
|
writeServerError(w, method, err)
|
||||||
return "", "", ""
|
return "", "", ""
|
||||||
|
@ -90,7 +101,6 @@ func convertDocument(w http.ResponseWriter, r *http.Request, job, folderID strin
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
filename, fileResult, err = storageProvider.Convert(conversion)
|
filename, fileResult, err = storageProvider.Convert(conversion)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writePayloadError(w, method, err)
|
writePayloadError(w, method, err)
|
||||||
return
|
return
|
||||||
|
@ -124,19 +134,6 @@ func convertDocument(w http.ResponseWriter, r *http.Request, job, folderID strin
|
||||||
writeSuccessBytes(w, json)
|
writeSuccessBytes(w, json)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UploadConvertDocument is an endpoint to both upload and convert a document
|
|
||||||
func UploadConvertDocument(w http.ResponseWriter, r *http.Request) {
|
|
||||||
job, folderID, orgID := uploadDocument(w, r)
|
|
||||||
if job == "" {
|
|
||||||
return // error already handled
|
|
||||||
}
|
|
||||||
convertDocument(w, r, job, folderID, api.ConversionJobRequest{
|
|
||||||
Job: job,
|
|
||||||
IndexDepth: 4,
|
|
||||||
OrgID: orgID,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func processDocument(p request.Persister, filename, job, folderID string, fileResult *api.DocumentConversionResponse) (newDocument entity.Document, err error) {
|
func processDocument(p request.Persister, filename, job, folderID string, fileResult *api.DocumentConversionResponse) (newDocument entity.Document, err error) {
|
||||||
// Convert into database objects
|
// Convert into database objects
|
||||||
document := store.ConvertFileResult(filename, fileResult)
|
document := store.ConvertFileResult(filename, fileResult)
|
||||||
|
|
|
@ -134,7 +134,7 @@ func init() {
|
||||||
log.IfErr(Add(RoutePrefixPublic, "meta", []string{"GET", "OPTIONS"}, nil, GetMeta))
|
log.IfErr(Add(RoutePrefixPublic, "meta", []string{"GET", "OPTIONS"}, nil, GetMeta))
|
||||||
log.IfErr(Add(RoutePrefixPublic, "authenticate/keycloak", []string{"POST", "OPTIONS"}, nil, AuthenticateKeycloak))
|
log.IfErr(Add(RoutePrefixPublic, "authenticate/keycloak", []string{"POST", "OPTIONS"}, nil, AuthenticateKeycloak))
|
||||||
log.IfErr(Add(RoutePrefixPublic, "authenticate", []string{"POST", "OPTIONS"}, nil, Authenticate))
|
log.IfErr(Add(RoutePrefixPublic, "authenticate", []string{"POST", "OPTIONS"}, nil, Authenticate))
|
||||||
// log.IfErr(Add(RoutePrefixPublic, "validate", []string{"GET", "OPTIONS"}, nil, ValidateAuthToken))
|
log.IfErr(Add(RoutePrefixPublic, "validate", []string{"GET", "OPTIONS"}, nil, ValidateAuthToken))
|
||||||
log.IfErr(Add(RoutePrefixPublic, "forgot", []string{"POST", "OPTIONS"}, nil, ForgotUserPassword))
|
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, "reset/{token}", []string{"POST", "OPTIONS"}, nil, ResetUserPassword))
|
||||||
log.IfErr(Add(RoutePrefixPublic, "share/{folderID}", []string{"POST", "OPTIONS"}, nil, AcceptSharedFolder))
|
log.IfErr(Add(RoutePrefixPublic, "share/{folderID}", []string{"POST", "OPTIONS"}, nil, AcceptSharedFolder))
|
||||||
|
|
|
@ -35,7 +35,7 @@ var Product core.ProdInfo
|
||||||
func init() {
|
func init() {
|
||||||
Product.Major = "1"
|
Product.Major = "1"
|
||||||
Product.Minor = "47"
|
Product.Minor = "47"
|
||||||
Product.Patch = "1"
|
Product.Patch = "2"
|
||||||
Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
|
Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
|
||||||
Product.Edition = "Community"
|
Product.Edition = "Community"
|
||||||
Product.Title = fmt.Sprintf("%s Edition", Product.Edition)
|
Product.Title = fmt.Sprintf("%s Edition", Product.Edition)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize unity Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
@ -22,7 +22,7 @@ import (
|
||||||
gogithub "github.com/google/go-github/github"
|
gogithub "github.com/google/go-github/github"
|
||||||
)
|
)
|
||||||
|
|
||||||
const commitTimeFormat = "January 2 2006, 15:04"
|
const commitTimeFormat = "2006-01-02, 15:04"
|
||||||
|
|
||||||
type githubCommit struct {
|
type githubCommit struct {
|
||||||
Owner string `json:"owner"`
|
Owner string `json:"owner"`
|
||||||
|
|
|
@ -71,7 +71,7 @@ const commitsTemplate = `
|
||||||
<table class="github-table" style="width: 100%;">
|
<table class="github-table" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="title">Commits <span>· {{len .BranchCommits}} commits by {{.NumContributors}} contributors</span>
|
<th class="title">Commits <span>· {{len .BranchCommits}} commits</span>
|
||||||
</th>
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -85,8 +85,8 @@ const commitsTemplate = `
|
||||||
</td>
|
</td>
|
||||||
<td class="right-column">
|
<td class="right-column">
|
||||||
<div class="contributor-meta">
|
<div class="contributor-meta">
|
||||||
<img class="github-avatar" title="@{{$commit.Name}}" alt="@{{$commit.Name}}" src="{{$commit.Avatar}}" />
|
|
||||||
{{$commit.Date}}
|
{{$commit.Date}}
|
||||||
|
<img class="github-avatar" title="@{{$commit.Name}}" alt="@{{$commit.Name}}" src="{{$commit.Avatar}}" />
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue