Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
a748b3a4
Commit
a748b3a4
authored
Apr 30, 2017
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: History page - List previous commits
parent
a7c4f42e
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
132 additions
and
6 deletions
+132
-6
.deployexclude
.build/.deployexclude
+1
-2
app.js
client/js/app.js
+2
-1
history.js
client/js/pages/history.js
+11
-0
sidebar.scss
client/scss/components/sidebar.scss
+22
-0
pages.js
server/controllers/pages.js
+21
-0
entries.js
server/libs/entries.js
+12
-0
git.js
server/libs/git.js
+24
-0
settings.pug
server/views/pages/admin/settings.pug
+1
-0
history.pug
server/views/pages/history.pug
+35
-0
view.pug
server/views/pages/view.pug
+3
-3
No files found.
.build/.deployexclude
View file @
a748b3a4
client/js
client
client/scss
coverage
coverage
data
data
logs
logs
...
...
client/js/app.js
View file @
a748b3a4
...
@@ -19,7 +19,7 @@ $(() => {
...
@@ -19,7 +19,7 @@ $(() => {
offset
:
-
50
offset
:
-
50
})
})
$
(
'.stickyscroll'
).
sticky
({
topSpacing
:
15
})
$
(
'.stickyscroll'
).
sticky
({
topSpacing
:
15
,
bottomSpacing
:
75
})
// ====================================
// ====================================
// Notifications
// Notifications
...
@@ -58,5 +58,6 @@ $(() => {
...
@@ -58,5 +58,6 @@ $(() => {
require
(
'./pages/create.js'
)(
alerts
,
socket
)
require
(
'./pages/create.js'
)(
alerts
,
socket
)
require
(
'./pages/edit.js'
)(
alerts
,
socket
)
require
(
'./pages/edit.js'
)(
alerts
,
socket
)
require
(
'./pages/source.js'
)(
alerts
)
require
(
'./pages/source.js'
)(
alerts
)
require
(
'./pages/history.js'
)(
alerts
)
require
(
'./pages/admin.js'
)(
alerts
)
require
(
'./pages/admin.js'
)(
alerts
)
})
})
client/js/pages/history.js
0 → 100644
View file @
a748b3a4
'use strict'
import
$
from
'jquery'
module
.
exports
=
(
alerts
)
=>
{
if
(
$
(
'#page-type-history'
).
length
)
{
let
currentBasePath
=
(
$
(
'#page-type-history'
).
data
(
'entrypath'
)
!==
'home'
)
?
$
(
'#page-type-history'
).
data
(
'entrypath'
)
:
''
}
}
client/scss/components/sidebar.scss
View file @
a748b3a4
...
@@ -45,6 +45,21 @@
...
@@ -45,6 +45,21 @@
transition
:
all
.4s
ease
;
transition
:
all
.4s
ease
;
line-height
:
14px
;
line-height
:
14px
;
&
.is-multiline
{
flex-wrap
:
wrap
;
}
&
.is-active
{
border-left
:
5px
solid
mc
(
'blue'
,
'500'
);
color
:
mc
(
'blue'
,
'300'
);
padding-left
:
15px
;
.is-small
{
color
:
mc
(
'blue'
,
'500'
);
}
}
i
{
i
{
margin-right
:
7px
;
margin-right
:
7px
;
color
:
mc
(
'blue-grey'
,
'300'
);
color
:
mc
(
'blue-grey'
,
'300'
);
...
@@ -55,6 +70,13 @@
...
@@ -55,6 +70,13 @@
text-decoration
:
none
;
text-decoration
:
none
;
}
}
.is-small
{
flex
:
1
0
100%
;
display
:
block
;
font-size
:
11px
;
color
:
rgba
(
255
,
255
,
255
,.
5
)
}
}
}
>
ul
{
>
ul
{
...
...
server/controllers/pages.js
View file @
a748b3a4
...
@@ -180,6 +180,27 @@ router.get('/source/*', (req, res, next) => {
...
@@ -180,6 +180,27 @@ router.get('/source/*', (req, res, next) => {
})
})
/**
/**
* View history of a document
*/
router
.
get
(
'/hist/*'
,
(
req
,
res
,
next
)
=>
{
let
safePath
=
entryHelper
.
parsePath
(
_
.
replace
(
req
.
path
,
'/hist'
,
''
))
entries
.
getHistory
(
safePath
).
then
((
pageData
)
=>
{
if
(
pageData
)
{
res
.
render
(
'pages/history'
,
{
pageData
})
}
else
{
throw
new
Error
(
'Invalid page path.'
)
}
return
true
}).
catch
((
err
)
=>
{
res
.
render
(
'error'
,
{
message
:
err
.
message
,
error
:
{}
})
})
})
/**
* View document
* View document
*/
*/
router
.
get
(
'/*'
,
(
req
,
res
,
next
)
=>
{
router
.
get
(
'/*'
,
(
req
,
res
,
next
)
=>
{
...
...
server/libs/entries.js
View file @
a748b3a4
...
@@ -402,5 +402,17 @@ module.exports = {
...
@@ -402,5 +402,17 @@ module.exports = {
return
rights
.
checkRole
(
'/'
+
r
.
_id
,
usr
.
rights
,
'read'
)
return
rights
.
checkRole
(
'/'
+
r
.
_id
,
usr
.
rights
,
'read'
)
})
})
})
})
},
getHistory
(
entryPath
)
{
return
db
.
Entry
.
findOne
({
_id
:
entryPath
,
isEntry
:
true
}).
then
(
entry
=>
{
if
(
!
entry
)
{
return
false
}
return
git
.
getHistory
(
entryPath
).
then
(
history
=>
{
return
{
meta
:
entry
,
history
}
})
})
}
}
}
}
server/libs/git.js
View file @
a748b3a4
...
@@ -253,6 +253,30 @@ module.exports = {
...
@@ -253,6 +253,30 @@ module.exports = {
if
(
_
.
includes
(
err
.
stdout
,
'nothing to commit'
))
{
return
true
}
if
(
_
.
includes
(
err
.
stdout
,
'nothing to commit'
))
{
return
true
}
})
})
})
})
},
getHistory
(
entryPath
)
{
let
self
=
this
let
gitFilePath
=
entryPath
+
'.md'
return
self
.
_git
.
exec
(
'log'
,
[
'-n'
,
'25'
,
'--format=format:%H %h %cI %cE %cN'
,
'--'
,
gitFilePath
]).
then
((
cProc
)
=>
{
let
out
=
cProc
.
stdout
.
toString
()
if
(
_
.
includes
(
out
,
'fatal'
))
{
let
errorMsg
=
_
.
capitalize
(
_
.
head
(
_
.
split
(
_
.
replace
(
out
,
'fatal: '
,
''
),
','
)))
throw
new
Error
(
errorMsg
)
}
let
hist
=
_
.
chain
(
out
).
split
(
'
\
n'
).
map
(
h
=>
{
let
hParts
=
h
.
split
(
' '
,
4
)
return
{
commit
:
hParts
[
0
],
commitAbbr
:
hParts
[
1
],
date
:
hParts
[
2
],
email
:
hParts
[
3
],
name
:
hParts
[
4
]
}
}).
value
()
return
hist
})
}
}
}
}
server/views/pages/admin/settings.pug
View file @
a748b3a4
...
@@ -7,6 +7,7 @@ block adminContent
...
@@ -7,6 +7,7 @@ block adminContent
h2.subtitle Manage site configuration
h2.subtitle Manage site configuration
.form-sections
.form-sections
section
section
img(src='/images/logo.png', style={width:'200px', float:'right'})
label.label System Version
label.label System Version
.section-block
.section-block
p Current Version: #[strong= sysversion.current]
p Current Version: #[strong= sysversion.current]
...
...
server/views/pages/history.pug
0 → 100644
View file @
a748b3a4
extends ../layout.pug
block rootNavRight
i.nav-item#notifload
.nav-item
a.button(href='/' + pageData.meta._id)
i.icon-circle-check
span View Latest
block content
#page-type-history.page-type-container(data-entrypath=pageData.meta._id)
.container.is-fluid.has-mkcontent
.columns.is-gapless
.column.is-narrow.is-hidden-touch.sidebar
aside.stickyscroll
.sidebar-label
span Past versions
ul.sidebar-menu
each item, index in pageData.history
- var itemDate = moment(item.date)
li: a.is-multiline(class={ 'is-active': index < 1 }, href='', title=itemDate.format('LLLL'))
span= itemDate.calendar(null, { sameElse: 'llll'})
span.is-small= item.commitAbbr
.column
.hero
h1.title#title= pageData.meta.title
if pageData.meta.subtitle
h2.subtitle= pageData.meta.subtitle
.content.mkcontent
!= pageData.html
server/views/pages/view.pug
View file @
a748b3a4
...
@@ -18,9 +18,9 @@ block rootNavRight
...
@@ -18,9 +18,9 @@ block rootNavRight
a.button.is-outlined(href='/source/' + pageData.meta.path)
a.button.is-outlined(href='/source/' + pageData.meta.path)
i.icon-loader
i.icon-loader
span Source
span Source
a.button.is-outlined(href='/
diff
/' + pageData.meta.path)
a.button.is-outlined(href='/
hist
/' + pageData.meta.path)
i.icon-
flow-merge
i.icon-
clock
span
Diff
span
History
if rights.write
if rights.write
a.button(href='/edit/' + pageData.meta.path)
a.button(href='/edit/' + pageData.meta.path)
i.icon-document-text
i.icon-document-text
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment