Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

[WIP] Handling of CreateJs on the CMF website #9

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ba186d9
WIP - first experiments with CreatePHP
adou600 Oct 3, 2012
ef85a24
use of CreatePHP in templates
adou600 Oct 3, 2012
20c4f16
clean up
adou600 Oct 3, 2012
a6306ed
preparing for news collections and updating create bundle cleanup
dbu Oct 3, 2012
122ba74
WIP adding create.js and collections
dbu Oct 4, 2012
ef8ad92
make fos restbundle handle json for the REST controller
dbu Oct 4, 2012
9f276aa
new test for collection handling
adou600 Oct 11, 2012
cb3625a
creation of news with CreateJs
adou600 Oct 11, 2012
b2fe584
show content when adding a news
adou600 Oct 11, 2012
aef278c
WIP - first experiments with CreatePHP
adou600 Oct 3, 2012
f321971
use of CreatePHP in templates
adou600 Oct 3, 2012
d190ced
clean up
adou600 Oct 3, 2012
bc5e60a
preparing for news collections and updating create bundle cleanup
dbu Oct 3, 2012
234b50a
WIP adding create.js and collections
dbu Oct 4, 2012
d2482db
make fos restbundle handle json for the REST controller
dbu Oct 4, 2012
13ae14b
new test for collection handling
adou600 Oct 11, 2012
8bf34fa
creation of news with CreateJs
adou600 Oct 11, 2012
a919fd7
show content when adding a news
adou600 Oct 11, 2012
d99d14f
use CreateJs event to show the news content on edit
adou600 Oct 12, 2012
e481b67
Merge branch 'cmf' of github.com:symfony-cmf/symfony-cmf-website into…
adou600 Oct 12, 2012
d40573d
wip integration of a login to edit the content
adou600 Oct 16, 2012
f9ef4aa
finalization of to edit the content
adou600 Oct 17, 2012
b3ca979
login password in parameters.yml.dist
adou600 Oct 18, 2012
a34418c
1st attempt with homemande NS for news
adou600 Oct 18, 2012
454b2ef
modification of content pages with createjs and schema.org vocabulary
adou600 Oct 18, 2012
023e165
test corrections to fit new vocabulary
adou600 Oct 18, 2012
4da8044
test case for page update
adou600 Oct 19, 2012
c541629
small fixes according to the vendor updates
adou600 Oct 27, 2012
a274e17
vocabulary update for CollectionPage
adou600 Oct 27, 2012
e0640eb
Merge branch 'master' into cmf
lsmith77 Oct 27, 2012
aaf5681
ws tweaks
lsmith77 Oct 27, 2012
4fa25a0
tests fix, load fixtures again after DB update
adou600 Nov 8, 2012
0ad68fb
Merge branch 'cmf' of github.com:symfony-cmf/symfony-cmf-website into…
adou600 Nov 8, 2012
d09d580
various fixes after vendors and branches updates
adou600 Nov 8, 2012
7fc6175
no WYSIWYG in HALLO editor for titles
adou600 Nov 8, 2012
068c761
fixtures fix to support the new schema for articles
adou600 Nov 8, 2012
81845c0
template optimizations to avoid JS errors
adou600 Nov 8, 2012
96b4d43
merging master into cmf branch
adou600 Dec 4, 2012
281c37b
fix routes in layout.html.twig after master merge
adou600 Dec 4, 2012
8ce54b8
test refactoring to work with refactored createphp
adou600 Dec 6, 2012
34acc20
remove duplicated page title
adou600 Dec 6, 2012
e4b8114
cleanup of createphp mapping xml files
adou600 Dec 6, 2012
7e9ec69
test to cover the case of duplicated node insertion attempt
adou600 Dec 7, 2012
5a3aafa
make the cw:headline editable without formatting options
adou600 Dec 7, 2012
ee0d40e
use config to define title type and toolbar position
adou600 Dec 11, 2012
95507df
revert changes
lsmith77 Dec 16, 2012
2775c23
updated dependencies
lsmith77 Dec 16, 2012
eb18b1f
fix tests
lsmith77 Dec 16, 2012
2e4c058
temporary fix to hide duplicate Add buttons
adou600 Dec 18, 2012
01235b3
fix CSS bug that makes the first part of the page shifted on edit mode
adou600 Dec 18, 2012
d652cae
handle frontend wrong creation date problem
adou600 Jan 4, 2013
43b6758
dependencies update
adou600 Jan 4, 2013
be50db7
dependencies update
adou600 Jan 10, 2013
b39439b
Merge remote-tracking branch 'origin/master' into cmf
dbu Feb 21, 2013
6871f1c
Merge branch 'master' into cmf
adou600 Mar 6, 2013
19d34b4
update dependencies and fix layout bugs
adou600 Mar 9, 2013
e777632
update dependencies
adou600 Mar 22, 2013
bf004af
update news list twig to fit the latest changes on createphp
adou600 Mar 22, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ public function registerBundles()
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),

new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),

// enable cmf bundles
new Symfony\Cmf\Bundle\RoutingExtraBundle\SymfonyCmfRoutingExtraBundle(),
new Symfony\Cmf\Bundle\MenuBundle\SymfonyCmfMenuBundle(),
new Symfony\Cmf\Bundle\ContentBundle\SymfonyCmfContentBundle(),
new Symfony\Cmf\Bundle\CoreBundle\SymfonyCmfCoreBundle(),
new Symfony\Cmf\Bundle\SimpleCmsBundle\SymfonyCmfSimpleCmsBundle(),
new Symfony\Cmf\Bundle\CreateBundle\SymfonyCmfCreateBundle(),

// and the website specific bundle
new Cmf\MainBundle\CmfMainBundle(),
Expand Down
13 changes: 11 additions & 2 deletions app/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
imports:
- { resource: parameters.yml }
- { resource: security.yml }

framework:
#esi: ~
Expand Down Expand Up @@ -39,10 +40,12 @@ symfony_cmf_routing_extra:
dynamic:
enabled: true


symfony_cmf_simple_cms:
routing:
templates_by_class:
Symfony\Cmf\Bundle\SimpleCmsBundle\Document\Page: SymfonyCmfSimpleCmsBundle:Page:index.html.twig
Cmf\MainBundle\Document\NewsDetail: CmfMainBundle:Cms:news_detail.html.twig
Symfony\Cmf\Bundle\SimpleCmsBundle\Document\Page: SymfonyCmfSimpleCmsBundle:Page:index.html.twig
use_sonata_admin: false

knp_menu:
Expand All @@ -63,8 +66,14 @@ fos_rest:
view:
formats:
rss: true
json: true
templating_formats:
rss: true
html: true
mime_types:
rss: 'application/rss+xml'
rss: 'application/rss+xml'

symfony_cmf_create:
phpcr_odm: true
map:
http://rdfs.org/sioc/ns#Post: Cmf\MainBundle\Document\NewsDetail
17 changes: 16 additions & 1 deletion app/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Internal routing configuration to handle ESI
#_internal:
# resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
# prefix: /_internal
# prefix: /_internal

create:
resource: "@SymfonyCmfCreateBundle/Resources/config/routing/rest.xml"
create_image:
resource: "@SymfonyCmfCreateBundle/Resources/config/routing/image.xml"

_logout:
pattern: /logout

_logout:
pattern: /login
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /
permanent: true
26 changes: 26 additions & 0 deletions app/config/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
security:
firewalls:
secured_area:
pattern: ^/
anonymous: ~
http_basic:
realm: "Acess to the content editing of the website"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsmith77 @dbu Since it's a http_basic authentication, the logout doesn't work (the browser takes care of the login). Do you want me to try a JS hack to be able to logout anyway?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not so important from my POV

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the password should be defined inside https://github.com/symfony-cmf/symfony-cmf-website/blob/master/app/config/parameters.yml
however that file should be renamed to parameters.yml.dist, so that we can change the password on the production server.

logout:
path: /logout
target: /
invalidate_session: true

access_control:
- { path: ^/login, roles: ROLE_EDITOR }

providers:
my_chain_provider:
chain:
providers: [my_memory_provider]
my_memory_provider:
memory:
users:
editor: { password: dummy, roles: 'ROLE_EDITOR' }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsmith77 how can we handle the login and password for the site on production? I went for the memory providers since it's the easiest way to deal with user authentication. To login, you just need to go to the URL cmf.symfony.com/login. Don't hesitate to tell me if you see a better way to do it.


encoders:
Symfony\Component\Security\Core\User\User: plaintext
124 changes: 124 additions & 0 deletions app/tests/CreateJsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

namespace Cmf;

use Midgard\CreatePHP\RestService;

class CreateJsTest extends WebTestCase
{
public function testAddNews()
{
$client = $this->createClient();

//prepare the POST request
$partOfKey = '<http://purl.org/dc/terms/partOf>';
$partOf = '</cms/simple/news>';

$titleKey = '<http://purl.org/dc/terms/title>';
$title = 'news title from testAddNews';

$contentKey = '<http://rdfs.org/sioc/ns#content>';
$content = 'some new content';

$subjectKey = '@subject';
$subject = '_:bnode47';

$typeKey = '@type';
$type = '<http://www.w3.org/2002/07/owl#Thing>';

$client->request('POST', '/en/symfony-cmf/create/document/_:bnode47',
array(
$partOfKey => array($partOf),
$titleKey => $title,
$contentKey => $content,
$subjectKey => $subject,
$typeKey => $type
));

$this->assertEquals(200, $client->getResponse()->getStatusCode());

//get the created page and check if everything is contained in the page
$crawler = $client->request('GET', '/news/news-title-from-testAddNews');

$this->assertEquals(200, $client->getResponse()->getStatusCode());

$this->assertCount(1, $crawler->filter(sprintf('h2:contains("%s")', $title)));
$this->assertCount(1, $crawler->filter(sprintf('p:contains("%s")', $content)));
$this->assertCount(1, $crawler->filter(sprintf('div.subtitle:contains("%s")', 'Date: ' . date('Y-m-d'))));
}

public function testUpdateNews()
{
$client = $this->createClient();

//prepare the PUT request
$titleKey = '<http://purl.org/dc/terms/title>';
$title = 'updated title from testUpdateNews';

$contentKey = '<http://rdfs.org/sioc/ns#content>';
$content = 'some updated content';

$subjectKey = '@subject';
$subject = '</cms/simple/news/symfony-cmf-website-update>';

$typeKey = '@type';
$type = '<http://rdfs.org/sioc/ns#Post';

$crawler = $client->request('PUT', '/en/symfony-cmf/create/document/cms/simple/news/symfony-cmf-website-update',
array(
$titleKey => $title,
$contentKey => $content,
$subjectKey => $subject,
$typeKey => $type
)
);

$this->assertEquals(200, $client->getResponse()->getStatusCode());

//get the updated page and check if data has been updated
$crawler = $client->request('GET', '/news/symfony-cmf-website-update');

$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertCount(1, $crawler->filter(sprintf('h2:contains("%s")', $title)));
$this->assertCount(1, $crawler->filter(sprintf('p:contains("%s")', $content)));
}


public function testRestServiceWithPost()
{
//prepare the post request
$partOfKey = '<http://purl.org/dc/terms/partOf>';
$partOf = '</cms/simple/news>';

$titleKey = '<http://purl.org/dc/terms/title>';
$title = 'updated title from testRestService';

$contentKey = '<http://rdfs.org/sioc/ns#content>';
$content = 'updated content<br>';

$subjectKey = '@subject';
$subject = '</cms/simple/news/symfony-cmf-website-update>';

$typeKey = '@type';
$type = '<http://www.w3.org/2002/07/owl#Thing>';

$request = array(
$partOfKey => array($partOf),
$titleKey => $title,
$contentKey => $content,
$subjectKey => $subject,
$typeKey => array($type)
);

$restService = $this->getContainer()->get('symfony_cmf_create.rest.handler');

$typeFactory = $this->getContainer()->get('symfony_cmf_create.rdf_type_factory');

$classType = $typeFactory->getType('Cmf\\MainBundle\\Document\\NewsCollection');

$result = $restService->run($request, $classType, null, RestService::HTTP_POST);

$this->assertEquals($title, $result['<http://purl.org/dc/terms/title>']);
$this->assertEquals($content, $result['<http://rdfs.org/sioc/ns#content>']);
}
}
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@
"doctrine/doctrine-fixtures-bundle": "dev-master",
"liip/functional-test-bundle": "dev-master",
"lunetics/locale-bundle": "dev-master",
"liip/doctrine-cache-bundle": "dev-master"
"liip/doctrine-cache-bundle": "dev-master",
"symfony-cmf/create-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Symfony\\Cmf\\Bundle\\CreateBundle\\Composer\\ScriptHandler::initSubmodules"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Symfony\\Cmf\\Bundle\\CreateBundle\\Composer\\ScriptHandler::initSubmodules"
]
},
"config": {
Expand Down
Loading