implemented admin post filtering
This commit is contained in:
parent
57684e7a27
commit
c2290a2e26
8 changed files with 92 additions and 50 deletions
|
@ -12,7 +12,7 @@
|
|||
"no-class-assign": 2,
|
||||
"no-compare-neg-zero": 2,
|
||||
"no-cond-assign": 2,
|
||||
"no-console": 2,
|
||||
"no-console": 1,
|
||||
"no-const-assign": 2,
|
||||
"no-constant-condition": 2,
|
||||
"no-control-regex": 1,
|
||||
|
|
|
@ -11,9 +11,11 @@ const dateUtils = new DateUtils();
|
|||
//--------------------------
|
||||
// POSTS
|
||||
//--------------------------
|
||||
router.get('/:page?', function(req, res) {
|
||||
router.get('/:filter?/:page?', function(req, res) {
|
||||
var pageNum = req.params.page;
|
||||
var filter = req.params.filter;
|
||||
if (pageNum == '' || pageNum == null) pageNum = 1;
|
||||
if (filter == '' || filter == null) filter = 'all';
|
||||
if (req.session.user) {
|
||||
Models.FreshPost.findAll({
|
||||
order: [['id', 'DESC']]
|
||||
|
@ -35,14 +37,26 @@ router.get('/:page?', function(req, res) {
|
|||
deleted.push(posts[index]);
|
||||
}
|
||||
}
|
||||
var count = Math.round(all.length / 6);
|
||||
var filtered;
|
||||
switch (filter) {
|
||||
case 'published':
|
||||
filtered = published;
|
||||
break;
|
||||
case 'deleted':
|
||||
filtered = deleted;
|
||||
break;
|
||||
default:
|
||||
filtered = all;
|
||||
break;
|
||||
}
|
||||
var count = Math.round(filtered.length / 6);
|
||||
var pageItems = [];
|
||||
var itemLimit = 6;
|
||||
var rangeStart = pageNum * itemLimit - itemLimit;
|
||||
for (var i = 0; i < itemLimit; i++) {
|
||||
try {
|
||||
if (all[i + rangeStart].id != null) {
|
||||
pageItems.push(all[i + rangeStart]);
|
||||
if (filtered[i + rangeStart].id != null) {
|
||||
pageItems.push(filtered[i + rangeStart]);
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log("NO POST", e)
|
||||
|
@ -62,6 +76,7 @@ router.get('/:page?', function(req, res) {
|
|||
},
|
||||
page_index: pageNum,
|
||||
page_count: count,
|
||||
postFilter: filter,
|
||||
user_status: true
|
||||
});
|
||||
})
|
||||
|
|
|
@ -1614,6 +1614,10 @@ svg.icons {
|
|||
z-index: 10;
|
||||
position: relative;
|
||||
}
|
||||
.main-container section header #header-wrapper #header-one #the-logo,
|
||||
.main-container section header #header-wrapper #header-two #the-logo {
|
||||
width: 40px;
|
||||
}
|
||||
.main-container section header #header-wrapper #header-two {
|
||||
text-align: right;
|
||||
color: #f2f1ef;
|
||||
|
@ -1622,12 +1626,12 @@ svg.icons {
|
|||
text-decoration-color: #fc6399;
|
||||
}
|
||||
.main-container section header #header-wrapper #header-two label#the-title {
|
||||
font-family: 'Apercu-Mono';
|
||||
font-size: 1.2em;
|
||||
font-weight: 300;
|
||||
font-weight: 400;
|
||||
color: #f5ab35;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
line-height: 0.8;
|
||||
}
|
||||
.main-container section header #header-wrapper #header-two #dash-menu {
|
||||
text-align: right;
|
||||
|
@ -2165,6 +2169,10 @@ select {
|
|||
margin-bottom: 10px;
|
||||
float: right;
|
||||
}
|
||||
#post-index #post-index-wrapper #post-index-menu .current-filter {
|
||||
color: #fc6399;
|
||||
text-decoration-color: #b2cce5;
|
||||
}
|
||||
#post-index #post-index-wrapper #posts-list {
|
||||
margin: 20px 0 0 0;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,7 @@ html(xmlns='http://www.w3.org/1999/xhtml', lang='en', xml:lang="en")
|
|||
#header-wrapper.columns
|
||||
#header-one.column
|
||||
a(href="/@/dashboard")
|
||||
img(src="/dash/assets/images/the-logo.svg")
|
||||
img#the-logo(src="/dash/assets/images/the-logo.svg")
|
||||
#header-two.column
|
||||
label#the-title= welcome
|
||||
-if(user_status)
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
extends frame
|
||||
block main-content
|
||||
#post-index
|
||||
#post-index
|
||||
#post-index-wrapper
|
||||
#post-index-menu
|
||||
a(href="#")= "All Posts ("+page_info.all+")"
|
||||
- if(postFilter=='all')
|
||||
a.current-filter(href="/@/dashboard/posts/all")= "All Posts ("+page_info.all+")"
|
||||
- else
|
||||
a(href="/@/dashboard/posts/all")= "All Posts ("+page_info.all+")"
|
||||
| .
|
||||
a(href="#")= "Published ("+page_info.published+")"
|
||||
- if(postFilter=='published')
|
||||
a.current-filter(href="/@/dashboard/posts/published")= "Published ("+page_info.published+")"
|
||||
- else
|
||||
a(href="/@/dashboard/posts/published")= "Published ("+page_info.published+")"
|
||||
| .
|
||||
a(href="#")= "Pages ("+page_info.pages+")"
|
||||
| .
|
||||
a(href="#")= "Deleted ("+page_info.deleted+")"
|
||||
|
||||
- if(postFilter=='deleted')
|
||||
a.current-filter(href="/@/dashboard/posts/deleted")= "Deleted ("+page_info.deleted+")"
|
||||
- else
|
||||
a(href="/@/dashboard/posts/deleted")= "Deleted ("+page_info.deleted+")"
|
||||
|
||||
a.add-new-post(href="/@/dashboard/posts/add/new") + Create New Post
|
||||
#posts-list
|
||||
- var index = 0;
|
||||
|
@ -20,20 +27,20 @@ block main-content
|
|||
span= items[index].post.created
|
||||
div.post-bg(style="background: #fc6399 url("+items[index].post.feature.substr(8)+") no-repeat center center / cover")
|
||||
p= items[index].post.plaintext.substr(0, 200)+"..."
|
||||
|
||||
|
||||
- var next = parseInt(page_index, 10) + 1
|
||||
- var prev = parseInt(page_index, 10) - 1
|
||||
- if(next > page_count) next = 1
|
||||
- if(prev <= 0) prev = page_count
|
||||
|
||||
br
|
||||
a.page-btns(href="/@/dashboard/posts/"+prev)
|
||||
a.page-btns(href="/@/dashboard/posts/"+postFilter+"/"+prev)
|
||||
svg(viewBox="0 0 20 20" class="icons")
|
||||
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-left')
|
||||
|
||||
span.paginate= "PAGE "+page_index+" OF "+page_count
|
||||
|
||||
a.page-btns(href="/@/dashboard/posts/"+next)
|
||||
a.page-btns(href="/@/dashboard/posts/"+postFilter+"/"+next)
|
||||
svg(viewBox="0 0 20 20" class="icons")
|
||||
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-right')
|
||||
|
||||
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
#post-index-wrapper
|
||||
padding 0.75rem
|
||||
|
||||
#post-index-menu
|
||||
color $white
|
||||
|
||||
a
|
||||
text-decoration-color: $highlight
|
||||
text-decoration-color $highlight
|
||||
|
||||
a.add-new-post
|
||||
display inline-block
|
||||
background $highlight
|
||||
|
@ -19,41 +22,49 @@
|
|||
margin-bottom 10px
|
||||
float right
|
||||
|
||||
.current-filter
|
||||
color $highlight
|
||||
text-decoration-color $secondary
|
||||
|
||||
#posts-list
|
||||
margin 20px 0 0 0
|
||||
a.post-link
|
||||
background $white
|
||||
|
||||
a.post-link
|
||||
background $white
|
||||
display inline-block
|
||||
vertical-align top
|
||||
width 100%
|
||||
text-decoration none
|
||||
margin 0 0 20px 0
|
||||
border-radius: 3px
|
||||
border-radius 3px
|
||||
color $primary - 60%
|
||||
|
||||
label
|
||||
font-size 1.3em
|
||||
font-weight: 500
|
||||
font-weight 500
|
||||
padding 10px
|
||||
display inline-block
|
||||
vertical-align: top
|
||||
width: 45%
|
||||
vertical-align top
|
||||
width 45%
|
||||
|
||||
span
|
||||
display inline-block
|
||||
vertical-align: top
|
||||
vertical-align top
|
||||
font-size 0.8em
|
||||
font-family 'Apercu-Mono'
|
||||
width: 50%
|
||||
text-align: right
|
||||
width 50%
|
||||
text-align right
|
||||
padding 10px
|
||||
|
||||
div.post-bg
|
||||
width: 100%
|
||||
width 100%
|
||||
height 350px
|
||||
background-color: $highlight
|
||||
background-color $highlight
|
||||
|
||||
p
|
||||
padding 10px
|
||||
font-size 1.2em
|
||||
font-weight: 400
|
||||
font-weight 400
|
||||
|
||||
#post-edit-index
|
||||
width 100%
|
||||
|
@ -77,6 +88,7 @@
|
|||
color $white
|
||||
padding 5px
|
||||
margin 0 0 5px 0
|
||||
|
||||
#post-date
|
||||
background $primary - 10%
|
||||
border-radius 0 3px 3px 0
|
||||
|
@ -116,24 +128,18 @@
|
|||
display inline-block
|
||||
vertical-align top
|
||||
text-align center
|
||||
|
||||
button[data-active='false']
|
||||
|
||||
button[data-active='false']
|
||||
background $secondary
|
||||
|
||||
svg
|
||||
fill $primary
|
||||
|
||||
button[data-active='true']
|
||||
|
||||
button[data-active='true']
|
||||
background $tertiary
|
||||
|
||||
svg
|
||||
fill $tertiary - 70%
|
||||
|
||||
|
||||
|
||||
//.option-inactive
|
||||
|
||||
//.option-active
|
||||
|
||||
|
||||
|
||||
#post-meta
|
||||
#post_tags
|
||||
|
|
|
@ -53,22 +53,28 @@ svg.icons
|
|||
#header-one, #header-two
|
||||
z-index 10
|
||||
position relative
|
||||
|
||||
#the-logo
|
||||
width 40px
|
||||
|
||||
#header-two
|
||||
text-align right
|
||||
color $white
|
||||
|
||||
a
|
||||
text-decoration-color: $highlight
|
||||
|
||||
text-decoration-color $highlight
|
||||
|
||||
label#the-title
|
||||
font-family 'Apercu-Mono'
|
||||
font-size 1.2em
|
||||
font-weight: 300
|
||||
font-weight 400
|
||||
color $tertiary
|
||||
text-decoration none
|
||||
display block
|
||||
line-height 0.8
|
||||
// word-break: break-all;
|
||||
|
||||
#dash-menu
|
||||
text-align: right
|
||||
text-align right
|
||||
|
||||
/* Mozilla based browsers */
|
||||
::-moz-selection
|
||||
|
|
Loading…
Reference in a new issue