Skip to content

Commit

Permalink
Bootstrap Blog 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 15, 2021
1 parent bf7b815 commit 82b01a7
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 49 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<a name="2.0.0"></a>
# [2.0.0](https://github.com/flextype-plugins/themes-admin/compare/v1.9.1...v2.0.0) (2021-01-15)

* **core:** add caching for blog collection. key: `blog-collection-` + `blog_id`
* **core:** add actions for automatic blog collection cleanup `onEntries*` events.
* **core:** add random posts template.
* **core:** general performance improvements and code cleanup.
* **settings:** add new setting `blog_id` to define blog route.

### Bug Fixes

* **_project:** fix demo fieldsets and entries.
* **core:** fix broken links in layouts.

<a name="1.9.1"></a>
# [1.9.1](https://github.com/flextype-plugins/themes-admin/compare/v1.9.0...v1.9.1) (2021-01-04)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: 'Bender, I didn''t know you liked cooking. That''s so cute.'
fieldset: blog-post
visibility: visible
routable: true
uuid: 87cdfe1b-5e48-4007-83f2-e740528cf286
published_at: '26-02-2020 17:15'
created_at: '26-05-2020 17:15'
published_by: 8db5ecee-bf60-44d1-b918-866898f9b09d
created_by: ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2
summary: '<p>I had more, but you go ahead. Why would I want to know that? I just told you! You''ve killed me! This is the worst part. The calm before the battle. Anyhoo, your net-suits will allow you to experience Fry''s worm infested bowels as if you were actually wriggling through them.</p><p>Fry! Stay back! He''s too powerful! This is the worst kind of discrimination: the kind against me! There''s no part of that sentence I didn''t like! These old Doomsday Devices are dangerously unstable. I''ll rest easier not knowing where they are.</p>'
description: ''
template: blog-post
tags: bender
---
<p>Ooh, name it after me!</p><p>I had more, but you go ahead. Why would I want to know that? I just told you! You've killed me! This is the worst part. The calm before the battle. Anyhoo, your net-suits will allow you to experience Fry's worm infested bowels as if you were actually wriggling through them.</p><p>Fry! Stay back! He's too powerful! This is the worst kind of discrimination: the kind against me! There's no part of that sentence I didn't like! These old Doomsday Devices are dangerously unstable. I'll rest easier not knowing where they are.</p><p>THE BIG BRAIN AM WINNING AGAIN! I AM THE GREETEST! NOW I AM LEAVING EARTH, FOR NO RAISEN!</p><p>I suppose I could part with 'one' and still be feared… Anyone who laughs is a communist! Oh, how I wish I could believe or understand that! There's only one reasonable course of action now: kill Flexo!</p><p>Morbo will now introduce tonight's candidates… PUNY HUMAN NUMBER ONE, PUNY HUMAN NUMBER TWO, and Morbo's good friend, Richard Nixon.</p><p>Good news, everyone! There's a report on TV with some very bad news!</p><p>Say it in Russian!</p><p>Why would I want to know that?</p><p>Ok, we'll go deliver this crate like professionals, and then we'll go ride the bumper cars. Yeah, lots of people did. Dr. Zoidberg, that doesn't make sense. But, okay! Dr. Zoidberg, that doesn't make sense. But, okay!</p><p><span style="background-color: rgba(255,255,255,var(--bg-opacity)); color: rgba(22,23,26,var(--text-opacity)); font-size: var(--font-size);">You'll have all the Slurm you can drink when you're partying with Slurms McKenzie!</span><br></p><p>Guards! Bring me the forms I need to fill out to have her taken away!</p><p>Maybe I love you so much I love you no matter who you are pretending to be.</p><p>You are the last hope of the universe. Shut up and take my money! I haven't felt much of anything since my guinea pig died. Why would I want to know that? Man, I'm sore all over. I feel like I just went ten rounds with mighty Thor.</p><p>Wow, you got that off the Internet? In my day, the Internet was only used to download pornography. Do a flip! Is the Space Pope reptilian!? We don't have a brig. Yes, if you make it look like an electrical fire. When you do things right, people won't be sure you've done anything at all.</p><p>And then the battle's not so bad? Pansy. And until then, I can never die? Now what?<br></p>
5 changes: 4 additions & 1 deletion _project/entries/blog/entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ published_at: '26-05-2020 14:46'
created_at: '26-05-2020 14:46'
published_by: ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2
created_by: ea7432a3-b2d5-4b04-b31d-1c5acc7a55e2
entries_limit: 3
posts_limit: 5
posts_random_limit: 5
posts_recent_limit: 5
about_me: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
description: ''
template: blog
menu_item_title: Blog
Expand Down
2 changes: 1 addition & 1 deletion _project/entries/blog/my-god-they-found-me/entry.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: 'My god, they found me'
summary: '<p>Yeah Mom, we know, you''ve told us this story a million times. You felt sorry for him so you decided to go with him to The Fish Under The Sea Dance. Dear Doctor Brown, on the night that I go back in time, you will be shot by terrorists. Please take whatever precautions are necessary to prevent this terrible disaster. Your friend, Marty. Biff, stop it. Biff, you''re breaking his arm. Biff, stop. My god, they found me. I don''t know how but they found me. Run for it, Marty. My god, they found me. I don''t know how but they found me. Run for it, Marty. Well, because George, nice girls get angry when guys take advantage of them.</p>'
tag: ''
description: ''
tags: 'doctor, future'
template: blog-post
visibility: visible
published_at: '26-02-2020 18:20'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: 'Remember, fellas, the future is in your hands'
summary: '<p>Einstein, hey Einstein, where''s the Doc, boy, huh? Doc Yeah, well, how about my homework, McFly? No, no, George, look, it''s just an act, right? Okay, so 9:00 you''re strolling through the parking lot, you see us struggling in the car, you walk up, you open the door and you say, your line, George. Yeah Mom, we know, you''ve told us this story a million times. You felt sorry for him so you decided to go with him to The Fish Under The Sea Dance. It''s information about the future isn''t it. I warned you about this kid. The consequences could be disastrous.</p>'
tags: 'doc,future'
tags: 'einstein, future'
description: ''
template: blog-post
visibility: visible
Expand Down
17 changes: 0 additions & 17 deletions _project/entries/blog/so-what-s-it-to-you-butthead/entry.md

This file was deleted.

16 changes: 9 additions & 7 deletions _project/fieldsets/blog-post.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
title: 'Blog Post'
default_field: title
hide: false
sections:
main:
title: Main
form:
icon:
name: file-alt
set: regular
form:
tabs:
main:
title: Main
fields:
title: { title: admin_title, type: text, size: 12 }
summary: { title: admin_summary, type: html, size: 12 }
content: { title: admin_content, type: html, size: 12 }
tags: { title: admin_tags, type: tags, size: 12 }
settings:
title: admin_settings
form:
settings:
title: admin_settings
fields:
general_heading: { title: admin_general, type: heading }
description: { title: admin_description, type: textarea, size: 12 }
Expand Down
20 changes: 12 additions & 8 deletions _project/fieldsets/blog.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
title: Blog
default_field: title
hide: false
sections:
main:
title: Main
form:
icon:
name: newspaper
set: solid
form:
tabs:
main:
title: Main
fields:
title: { title: admin_title, type: text, size: 12 }
entries_limit: { title: admin_entries_limit, type: text, size: 4/12 }
settings:
title: admin_settings
form:
posts_limit: { title: "Posts limit", type: text, size: 4/12 }
posts_recent_limit: { title: "Recent posts limit", type: text, size: 4/12 }
posts_random_limit: { title: "Random posts limit", type: text, size: 4/12 }
settings:
title: admin_settings
fields:
general_heading: { title: admin_general, type: heading }
description: { title: admin_description, type: textarea, size: 12 }
Expand Down
2 changes: 1 addition & 1 deletion assets/src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ h1, h2, h3, h4, h5, h6 {
}

.blog-post-meta {
margin-bottom: 1.25rem;
margin-bottom: 2rem;
color: #999;
display: flex;
align-items: center;
Expand Down
12 changes: 9 additions & 3 deletions templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
{% set tag = request.getQueryParams().tag %}

{% set blogID = flextype.registry.get('themes.bootstrap-blog.settings.blog_id') %}
{% set blogCollectionCacheID = strings('collectionCacheID-' ~ blogID).hash().toString() %}
{% set blogCollectionCacheID = strings('blog-collection-' ~ blogID).hash().toString() %}
{% if flextype.cache.has(blogCollectionCacheID) %}
{% set blog = flextype.cache.get(blogCollectionCacheID) %}
{% else %}
{% set blog = flextype.entries.fetch(blogID, {'collection': true}).exceptFromCollection(['content']) %}
{% do flextype.cache.set(blogCollectionCacheID, blog) %}
{% endif %}

{% set blogPostsLimit = flextype.entries.fetch(blogID).posts_limit %}
{% if blogPostsLimit == 0 %}{% set blogPostsLimit = 5 %}{% endif %}
{% set blogPostData = flextype.entries.fetch(blogID) %}
{% if blogPostData.posts_limit == 0 %}{% set blogPostsLimit = 5 %}{% else %}{% set blogPostsLimit = blogPostData.posts_limit %}{% endif %}
{% if blogPostData.posts_recent_limit == 0 %}{% set blogPostsRecentLimit = 5 %}{% else %}{% set blogPostsRecentLimit = blogPostData.posts_recent_limit %}{% endif %}
{% if blogPostData.posts_random_limit == 0 %}{% set blogPostsRandomLimit = 5 %}{% else %}{% set blogPostsRandomLimit = blogPostData.posts_random_limit %}{% endif %}

{% if tag %}
{% set blogPostsLength = blog.copy()
Expand Down Expand Up @@ -90,6 +92,10 @@
{% include 'themes/' ~ flextype.registry.get('plugins.site.settings.theme') ~ '/templates/partials/blog/about-me.html' %}
{# /about-me #}

{# random-posts #}
{% include 'themes/' ~ flextype.registry.get('plugins.site.settings.theme') ~ '/templates/partials/blog/random-posts.html' %}
{# /random-posts #}

{# recent-posts #}
{% include 'themes/' ~ flextype.registry.get('plugins.site.settings.theme') ~ '/templates/partials/blog/recent-posts.html' %}
{# /recent-posts #}
Expand Down
6 changes: 3 additions & 3 deletions templates/partials/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<link href="https://fonts.googleapis.com/css?family=Playfair+Display:700,900" rel="stylesheet">

{% set theme = flextype.registry.get('plugins.site.settings.theme') %}
{% do registry.set('assets.site.css.bootstrap-blog', 'project/themes/' ~ theme ~ '/assets/src/css/styles.css') %}
{% do flextype.registry.set('assets.site.css.bootstrap-blog', 'project/themes/' ~ theme ~ '/assets/src/css/styles.css') %}

{% if registry.has('assets.site.css') %}
{% if flextype.registry.has('assets.site.css') %}
{% for css in flextype.registry.get('assets.site.css') %}
<link href="{{ url() }}/{{ css }}" rel="stylesheet">
{% endfor %}
Expand Down Expand Up @@ -76,7 +76,7 @@
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

{% if registry.has('assets.site.js') %}
{% if flextype.registry.has('assets.site.js') %}
{% for js in flextype.registry.get('assets.site.js') %}
{% if js %}
<script type="text/javascript" src="{{ url() }}/{{ js }}"></script>
Expand Down
8 changes: 8 additions & 0 deletions templates/partials/blog/random-posts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h3 class="text-left mb-2">Random Posts</h3>
<ul class="pl-0 list-unstyled">
{% for post in blog.copy()
.where('visibility', 'nin', ['draft', 'hidden'])
.random(blogPostsRandomLimit) %}
<li class="mb-1"><a href="{{ url() }}/{{ post.id }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
2 changes: 1 addition & 1 deletion templates/partials/blog/recent-posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h3 class="text-left mb-2">Recent Posts</h3>
{% for post in blog.copy()
.where('visibility', 'nin', ['draft', 'hidden'])
.sortBy('published_at', 'DESC')
.limit(blogPostsLimit) %}
.limit(blogPostsRecentLimit) %}
<li class="mb-1"><a href="{{ url() }}/{{ post.id }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
11 changes: 9 additions & 2 deletions theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
return arrays($result);
});


$blogCollectionCacheID = strings('collectionCacheID-' . flextype('registry')
$blogCollectionCacheID = strings('blog-collection-' . flextype('registry')
->get('themes.bootstrap-blog.settings.blog_id'))
->hash()
->toString();
Expand All @@ -42,6 +41,14 @@
flextype('cache')->delete($blogCollectionCacheID);
});

flextype('emitter')->addListener('onEntriesCopy', function () use ($blogCollectionCacheID) {
flextype('cache')->delete($blogCollectionCacheID);
});

flextype('emitter')->addListener('onEntriesMove', function () use ($blogCollectionCacheID) {
flextype('cache')->delete($blogCollectionCacheID);
});

flextype('emitter')->addListener('onEntriesUpdate', function () use ($blogCollectionCacheID) {
flextype('cache')->delete($blogCollectionCacheID);
});
8 changes: 4 additions & 4 deletions theme.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Bootstrap Blog
version: 1.9.1
version: 2.0.0
description: Twitter Bootstrap Blog theme for Flextype.
author:
name: Sergey Romanenko
email: support@flextype.org
email: sergey.romanenko@flextype.org
url: https://flextype.org
homepage: https://github.com/flextype-themes/bootstrap-blog
bugs: https://github.com/flextype-themes/bootstrap-blog/issues
license: MIT

dependencies:
flextype: 0.9.15
flextype: 0.9.16
site: '>=1.0.0'
twig: '>=1.0.0'
twig: '>=2.0.0'

0 comments on commit 82b01a7

Please sign in to comment.