tiny blog: add blog component

This commit is contained in:
2018-05-02 17:21:33 +02:00
parent f9ebdfbee6
commit a72a110cf7
30 changed files with 138 additions and 1 deletions
@@ -0,0 +1,23 @@
tests
createDemoPosts
self current
writeBlogPost: ((TBPost title: 'Welcome in TinyBlog'
text: 'TinyBlog is a small blog engine made with Pharo.'
category: 'TinyBlog')
visible: true);
writeBlogPost: ((TBPost title: 'Report Pharo Sprint'
text: 'Friday, June 12 there was a Pharo sprint / Moose dojo. It was a
nice event with more than 15 motivated sprinters. With the help of candies, cakes and chocolate, huge work has been done'
category: 'Pharo')
visible: true);
writeBlogPost: ((TBPost title: 'Brick on top of Bloc - Preview'
text: 'We are happy to announce the first preview version of Brick, a new widget set created from scratch on top of Bloc. Brick is being developed primarily by Alex Syrel (together with Alain Plantec, Andrei Chis and myself), and the work is sponsored by ESUG. Brick is part of the Glamorous Toolkit effort and will provide the basis for the new versions of the development tools.'
category: 'Pharo')
visible: true);
writeBlogPost: ((TBPost title: 'The sad story of unclassified blog posts'
text: 'So sad that I can read this.')
visible: true);
writeBlogPost: ((TBPost title: 'Working with Pharo on the Raspberry Pi'
text: 'Hardware is getting cheaper and many new small devices like the famous Raspberry Pi provide new computation power that was one once only available on regular desktop computers.'
category: 'Pharo')
visible: true)
@@ -0,0 +1,3 @@
initialization
current
^ instance ifNil: [ instance := self new ]
@@ -0,0 +1,3 @@
initialization
initialize
self reset
@@ -0,0 +1,3 @@
initialization
reset
instance := nil
@@ -0,0 +1,3 @@
actions
allBlogPosts
^ posts
@@ -0,0 +1,3 @@
actions
allBlogPostsFromCategory: c
^ posts select: [ :p | p category = c ]
@@ -0,0 +1,3 @@
actions
allCategories
^ (self allBlogPosts collect: [ :p | p category ]) asSet
@@ -0,0 +1,3 @@
actions
allVisibleBlogPosts
^ posts select: [ :p | p isVisible ]
@@ -0,0 +1,3 @@
actions
allVisibleBlogPostsFromCategory: c
^ posts select: [ :p | p category = c and: [ p isVisible ] ]
@@ -0,0 +1,4 @@
initialization
initialize
super initialize.
posts := OrderedCollection new.
@@ -0,0 +1,3 @@
actions
removeAllPosts
posts := OrderedCollection new
@@ -0,0 +1,3 @@
actions
size
^ posts size
@@ -0,0 +1,3 @@
actions
writeBlogPost: p
posts add: p
@@ -0,0 +1,14 @@
{
"category" : "TinyBlog",
"classinstvars" : [
"instance" ],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"posts" ],
"name" : "TBBlog",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
@@ -0,0 +1,8 @@
tests
setUp
blog := TBBlog current.
blog removeAllPosts.
first := TBPost title: 'A title' text: 'A text' category: 'First Category'.
blog writeBlogPost: first.
post := (TBPost title: 'Another title' text: 'Another text'
category: 'Second Category') beVisible
@@ -0,0 +1,3 @@
tests
tearDown
TBBlog reset
@@ -0,0 +1,4 @@
tests
testAddBlogPost
blog writeBlogPost: post.
self assert: blog size equals: 2
@@ -0,0 +1,4 @@
tests
testAllBlogPosts
blog writeBlogPost: post.
self assert: blog allBlogPosts size equals: 2
@@ -0,0 +1,4 @@
tests
testAllBlogPostsFromCategory
self assert: (blog allBlogPostsFromCategory: 'First Category')
size equals: 1
@@ -0,0 +1,4 @@
tests
testAllCategories
blog writeBlogPost: post.
self assert: blog allCategories size equals: 2
@@ -0,0 +1,4 @@
tests
testAllVisibleBlogPosts
blog writeBlogPost: post.
self assert: blog allVisibleBlogPosts size equals: 1
@@ -0,0 +1,5 @@
tests
testAllVisibleBlogPostsFromCategory
blog writeBlogPost: post.
self assert: (blog allVisibleBlogPostsFromCategory: 'First Category') size equals: 0.
self assert: (blog allVisibleBlogPostsFromCategory: 'Second Category') size equals: 1
@@ -0,0 +1,4 @@
tests
testRemoveAllBlogPosts
blog removeAllPosts.
self assert: blog size equals: 0
@@ -0,0 +1,3 @@
tests
testSize
self assert: blog size equals: 1
@@ -0,0 +1,3 @@
tests
testUnclassifiedBlogPosts
self assert: (blog allBlogPosts select: [ :p | p isUnclassified ]) size equals: 0
@@ -0,0 +1,16 @@
{
"category" : "TinyBlog-Tests",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"blog",
"post",
"first" ],
"name" : "TBBlogTest",
"pools" : [
],
"super" : "TestCase",
"type" : "normal" }
@@ -1,3 +1,3 @@
action
isVisible
self visible
^ self visible
@@ -1 +1,2 @@
SystemOrganization addCategory: #TinyBlog!
SystemOrganization addCategory: 'TinyBlog-Tests'!