mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +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
|
||||
|
||||
v1.47.1
|
||||
v1.47.2
|
||||
|
||||
## OS Support
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
}
|
||||
|
||||
.section-github-render {
|
||||
font-size: 0.9rem;
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
@ -77,8 +79,8 @@
|
|||
}
|
||||
|
||||
.github-table tbody tr td {
|
||||
border: none!important;
|
||||
padding: 5px 20px !important;
|
||||
border: none !important;
|
||||
padding: 5px 0 !important;
|
||||
}
|
||||
|
||||
.github-table .right-column {
|
||||
|
@ -114,6 +116,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
.contributor-meta {
|
||||
white-space: nowrap;
|
||||
width: 1%;
|
||||
}
|
||||
|
||||
span.issue-state {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
|
@ -123,6 +130,6 @@
|
|||
img.github-avatar {
|
||||
width: 24px;
|
||||
border-radius: 4px;
|
||||
margin-right: 10px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "documize",
|
||||
"version": "1.47.1",
|
||||
"version": "1.47.2",
|
||||
"description": "The Document IDE",
|
||||
"private": true,
|
||||
"repository": "",
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
// Msword type provides a peg to hang the Convert method on.
|
||||
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 {
|
||||
byts, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"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/section/provider"
|
||||
"github.com/documize/community/core/utility"
|
||||
"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.
|
||||
func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
||||
valid = false
|
||||
// ValidateAuthToken finds and validates authentication token.
|
||||
func ValidateAuthToken(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
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)
|
||||
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.
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -274,6 +286,7 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
|||
domain := request.GetSubdomainFromHost(r)
|
||||
domain2 := request.GetRequestSubdomain(r)
|
||||
if org.Domain != domain && org.Domain != domain2 {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -283,6 +296,7 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
|||
// So you have a bad token
|
||||
if hasToken {
|
||||
if tokenErr != nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -305,23 +319,23 @@ func ValidToken(r *http.Request) (context request.Context, valid bool) {
|
|||
context.Global = false
|
||||
|
||||
// Fetch user permissions for this org
|
||||
if context.Authenticated {
|
||||
user, err := getSecuredUser(p, org.RefID, context.UserID)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
context.Administrator = user.Admin
|
||||
context.Editor = user.Editor
|
||||
context.Global = user.Global
|
||||
if !context.Authenticated {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
request.SetContext(r, context)
|
||||
p = request.GetPersister(r)
|
||||
user, err := getSecuredUser(p, org.RefID, context.UserID)
|
||||
|
||||
valid = context.Authenticated || org.AllowAnonymousAccess
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
context.Administrator = user.Admin
|
||||
context.Editor = user.Editor
|
||||
context.Global = user.Global
|
||||
|
||||
util.WriteJSON(w, user)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,23 @@ import (
|
|||
"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) {
|
||||
method := "uploadDocument"
|
||||
p := request.GetPersister(r)
|
||||
|
||||
params := mux.Vars(r)
|
||||
folderID := params["folderID"]
|
||||
|
||||
|
@ -47,7 +60,6 @@ func uploadDocument(w http.ResponseWriter, r *http.Request) (string, string, str
|
|||
|
||||
// grab file
|
||||
filedata, filename, err := r.FormFile("attachment")
|
||||
|
||||
if err != nil {
|
||||
writeMissingDataError(w, method, "attachment")
|
||||
return "", "", ""
|
||||
|
@ -55,7 +67,6 @@ func uploadDocument(w http.ResponseWriter, r *http.Request) (string, string, str
|
|||
|
||||
b := new(bytes.Buffer)
|
||||
_, err = io.Copy(b, filedata)
|
||||
|
||||
if err != nil {
|
||||
writeServerError(w, method, err)
|
||||
return "", "", ""
|
||||
|
@ -90,7 +101,6 @@ func convertDocument(w http.ResponseWriter, r *http.Request, job, folderID strin
|
|||
var err error
|
||||
|
||||
filename, fileResult, err = storageProvider.Convert(conversion)
|
||||
|
||||
if err != nil {
|
||||
writePayloadError(w, method, err)
|
||||
return
|
||||
|
@ -124,19 +134,6 @@ func convertDocument(w http.ResponseWriter, r *http.Request, job, folderID strin
|
|||
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) {
|
||||
// Convert into database objects
|
||||
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, "authenticate/keycloak", []string{"POST", "OPTIONS"}, nil, AuthenticateKeycloak))
|
||||
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, "reset/{token}", []string{"POST", "OPTIONS"}, nil, ResetUserPassword))
|
||||
log.IfErr(Add(RoutePrefixPublic, "share/{folderID}", []string{"POST", "OPTIONS"}, nil, AcceptSharedFolder))
|
||||
|
|
|
@ -35,7 +35,7 @@ var Product core.ProdInfo
|
|||
func init() {
|
||||
Product.Major = "1"
|
||||
Product.Minor = "47"
|
||||
Product.Patch = "1"
|
||||
Product.Patch = "2"
|
||||
Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
|
||||
Product.Edition = "Community"
|
||||
Product.Title = fmt.Sprintf("%s Edition", Product.Edition)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// 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
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
|
@ -22,7 +22,7 @@ import (
|
|||
gogithub "github.com/google/go-github/github"
|
||||
)
|
||||
|
||||
const commitTimeFormat = "January 2 2006, 15:04"
|
||||
const commitTimeFormat = "2006-01-02, 15:04"
|
||||
|
||||
type githubCommit struct {
|
||||
Owner string `json:"owner"`
|
||||
|
|
|
@ -71,7 +71,7 @@ const commitsTemplate = `
|
|||
<table class="github-table" style="width: 100%;">
|
||||
<thead>
|
||||
<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>
|
||||
</tr>
|
||||
|
@ -85,8 +85,8 @@ const commitsTemplate = `
|
|||
</td>
|
||||
<td class="right-column">
|
||||
<div class="contributor-meta">
|
||||
<img class="github-avatar" title="@{{$commit.Name}}" alt="@{{$commit.Name}}" src="{{$commit.Avatar}}" />
|
||||
{{$commit.Date}}
|
||||
<img class="github-avatar" title="@{{$commit.Name}}" alt="@{{$commit.Name}}" src="{{$commit.Avatar}}" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue