This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
[WIP] Handling of CreateJs on the CMF website #9
Open
adou600
wants to merge
58
commits into
master
Choose a base branch
from
cmf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 ef85a24
use of CreatePHP in templates
adou600 20c4f16
clean up
adou600 a6306ed
preparing for news collections and updating create bundle cleanup
dbu 122ba74
WIP adding create.js and collections
dbu ef8ad92
make fos restbundle handle json for the REST controller
dbu 9f276aa
new test for collection handling
adou600 cb3625a
creation of news with CreateJs
adou600 b2fe584
show content when adding a news
adou600 aef278c
WIP - first experiments with CreatePHP
adou600 f321971
use of CreatePHP in templates
adou600 d190ced
clean up
adou600 bc5e60a
preparing for news collections and updating create bundle cleanup
dbu 234b50a
WIP adding create.js and collections
dbu d2482db
make fos restbundle handle json for the REST controller
dbu 13ae14b
new test for collection handling
adou600 8bf34fa
creation of news with CreateJs
adou600 a919fd7
show content when adding a news
adou600 d99d14f
use CreateJs event to show the news content on edit
adou600 e481b67
Merge branch 'cmf' of github.com:symfony-cmf/symfony-cmf-website into…
adou600 d40573d
wip integration of a login to edit the content
adou600 f9ef4aa
finalization of to edit the content
adou600 b3ca979
login password in parameters.yml.dist
adou600 a34418c
1st attempt with homemande NS for news
adou600 454b2ef
modification of content pages with createjs and schema.org vocabulary
adou600 023e165
test corrections to fit new vocabulary
adou600 4da8044
test case for page update
adou600 c541629
small fixes according to the vendor updates
adou600 a274e17
vocabulary update for CollectionPage
adou600 e0640eb
Merge branch 'master' into cmf
lsmith77 aaf5681
ws tweaks
lsmith77 4fa25a0
tests fix, load fixtures again after DB update
adou600 0ad68fb
Merge branch 'cmf' of github.com:symfony-cmf/symfony-cmf-website into…
adou600 d09d580
various fixes after vendors and branches updates
adou600 7fc6175
no WYSIWYG in HALLO editor for titles
adou600 068c761
fixtures fix to support the new schema for articles
adou600 81845c0
template optimizations to avoid JS errors
adou600 96b4d43
merging master into cmf branch
adou600 281c37b
fix routes in layout.html.twig after master merge
adou600 8ce54b8
test refactoring to work with refactored createphp
adou600 34acc20
remove duplicated page title
adou600 e4b8114
cleanup of createphp mapping xml files
adou600 7e9ec69
test to cover the case of duplicated node insertion attempt
adou600 5a3aafa
make the cw:headline editable without formatting options
adou600 ee0d40e
use config to define title type and toolbar position
adou600 95507df
revert changes
lsmith77 2775c23
updated dependencies
lsmith77 eb18b1f
fix tests
lsmith77 2e4c058
temporary fix to hide duplicate Add buttons
adou600 01235b3
fix CSS bug that makes the first part of the page shifted on edit mode
adou600 d652cae
handle frontend wrong creation date problem
adou600 43b6758
dependencies update
adou600 be50db7
dependencies update
adou600 b39439b
Merge remote-tracking branch 'origin/master' into cmf
dbu 6871f1c
Merge branch 'master' into cmf
adou600 19d34b4
update dependencies and fix layout bugs
adou600 e777632
update dependencies
adou600 bf004af
update news list twig to fit the latest changes on createphp
adou600 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
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' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.