Skip to content

Commit

Permalink
Fix cs-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
heiglandreas committed Feb 3, 2020
1 parent 6b11cd9 commit ad20f87
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 56 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*]
end_of_line = cr
indent_size = 4
indent_style = space

[{*.js, *.json}]
indent_size = 2

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4
- nightly

matrix:
Expand Down
48 changes: 1 addition & 47 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,47 +1 @@
{
"name": "callingallpapers/cli",
"desciption" : "A CLI to fetch as many CfPs as possible for callingallpapers.com",
"type": "project",
"authors" : [{
"name" : "Andreas Heigl",
"email" : "andreas@heigl.org",
"homepage" : "https://andreas.heigl.org",
"role" : "Developer"
}],
"support" : {
"email" : "support@callingallpapers.com",
"irc" : "irc://irc.freenode.org/joindin",
"issues" : "https://github.com/joindin/callingallpapers-cli/issues",
"source" : "https://github.com/joindin/callingallpapers-cli"
},
"keywords" : ["cfp", "cli", "parser", "callingallpapers"],
"homepage" : "https://callingallpapers.com",
"license" : "MIT",
"require": {
"ext-dom" : "*",
"ext-json" : "*",
"ext-libxml": "*",
"symfony/console": "^2.7",
"org_heigl/trait-iterator": "^1.0",
"guzzlehttp/guzzle": "^6.2",
"guzzlehttp/oauth-subscriber": "^0.3.0",
"ivopetkov/html5-dom-document-php": "^0.5.5"
},
"autoload": {
"psr-4": {
"Callingallpapers\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CallingallpapersTest\\Cli\\": "tests/"
}
},
"require-dev": {
"phing/phing": "^2.14",
"mockery/mockery": "^0.9.9",
"squizlabs/php_codesniffer": "^3.0",
"phpunit/phpunit": "^7.2",
"phpunit/dbunit": "^4.0"
}
}
{ "name": "callingallpapers/cli", "description": "A CLI to fetch as many CfPs as possible for callingallpapers.com", "type": "project", "authors": [ { "name": "Andreas Heigl", "email": "andreas@heigl.org", "homepage": "https://andreas.heigl.org", "role": "Developer" } ], "support": { "email": "support@callingallpapers.com", "irc": "irc://irc.freenode.org/joindin", "issues": "https://github.com/joindin/callingallpapers-cli/issues", "source": "https://github.com/joindin/callingallpapers-cli" }, "keywords": [ "cfp", "cli", "parser", "callingallpapers" ], "homepage": "https://callingallpapers.com", "license": "MIT", "require": { "php": "^7.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "symfony/console": "^2.7", "org_heigl/trait-iterator": "^1.0", "guzzlehttp/guzzle": "^6.2", "guzzlehttp/oauth-subscriber": "^0.3.0", "ivopetkov/html5-dom-document-php": "^0.5.5" }, "autoload": { "psr-4": { "Callingallpapers\\": "src/" } }, "autoload-dev": { "psr-4": { "CallingallpapersTest\\Cli\\": "tests/" } }, "require-dev": { "phing/phing": "^2.14", "mockery/mockery": "^0.9.9", "squizlabs/php_codesniffer": "^3.0", "phpunit/phpunit": "^7.2", "phpunit/dbunit": "^4.0" }, "config": { "sort-packages": true }, "scripts": { "test": "vendor/bin/phpunit", "cs": "vendor/bin/phpcs", "csfix": "vendor/bin/phpcbf" }}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/AbstractParseEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function configure()
If you ommit the date the current date will be used instead
<info>callingallpapers parseCfPs:sessionize<env></info>
EOT
,$this->getServiceUrl()));
, $this->getServiceUrl()));
}

protected function execute(InputInterface $input, OutputInterface $output)
Expand Down
2 changes: 1 addition & 1 deletion src/Service/ServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ public function getClient() : Client
{
return $this->client;
}
}
}
24 changes: 19 additions & 5 deletions src/Subcommands/Sessionize/Parser/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
use DOMDocument;
use DOMXPath;
use function preg_replace;
use function str_replace;
use function strip_tags;
use function strpos;
use function var_dump;

class Description
{
Expand All @@ -25,18 +28,29 @@ public function parse(DOMDocument $dom, DOMXPath $xpath)

$text = [];
for ($i = 0; $i < $result->length; $i++) {
$resultI = $result->item($i)->parentNode->childNodes;
$currentItem = $result->item($i);
$resultI = $currentItem->parentNode->childNodes;
if ($currentItem->childNodes->length > 0) {
$resultI = $currentItem->childNodes;
}

if ($resultI->length <= 0) {
return '';
continue;
}
foreach ($resultI as $key => $node) {
$nodeText = trim($dom->saveXML($node));

if (false !== strpos($nodeText, 'submit-your-session-button')) {
continue;
}

foreach ($resultI as $node) {
$text[] = $dom->saveXML($node);
$nodeText = str_replace('</hr>', '', $nodeText);
$nodeText = str_replace('<hr class="m-t-none">', '', $nodeText);
$text[] = $nodeText;
}
}
$description = trim(implode('', $text));
$description = preg_replace(['/\<\!\-\-.*?\-\-\>/si', '/\<script.*?\<\/script\>/si'],'', $description);
$description = preg_replace(['/\<\!\-\-.*?\-\-\>/si', '/\<script.*?\<\/script\>/si', '/\<script.*?src=\".*?\/\>/'], '', $description);

return $description;
}
Expand Down
9 changes: 7 additions & 2 deletions tests/Subcommands/Sessionize/Parser/EventDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function testThatLocationIsReturnedCorrectly($file, $result)

$dom->load($file, LIBXML_NOBLANKS ^ LIBXML_NOERROR ^ LIBXML_NOENT);

$result = str_replace("\r", "\n", $result);

$this->assertEquals($result, $parser->parse($dom, new DOMXPath($dom)));
}

Expand All @@ -45,7 +47,10 @@ public function uriIsReturnedCorrectlyProvider() : array
l\'utilizzo di tecniche di DevOps che si possono implementare all\'interno
di Azure.</p>
</p>
</p>',
</p><p>Azure Day è l\'evento dedicato al Cloud di
casa Microsoft, come organizzatori dell\'evento ci aspettiamo delle
sessioni ricche di contenuti che mostrino al pubblico come sfruttare
Azure all\'interno della propria attività professionale.</p><p><br/></p>',
], [
__DIR__ . '/../__assets/React Week Medellín 2019: Call for Speakers @ Sessionize.com.html',
'<p>En Globant Medellín vamos a realizar la
Expand All @@ -62,7 +67,7 @@ public function uriIsReturnedCorrectlyProvider() : array
This event is in SA Pacific Standard Time time zone.
</small><div class="displayNone" style="display: block;"><small class="text-muted">
Closing time in your time zone is <span class="js-closedate" data-date="2019-01-30T04:59:00.0000000Z">30 Jan 2019 at 5:59 AM</span>.
</small></div></div></div><div class="row"><div class="col-md-12"><hr class="m-t-none"><p>Algunos temassugeridos:</p><p><br/><p>React Foundations.</p><p>State manager: Redux, MobX, flux.</p><p>Style Components.</p><p>React Native</p><p>React Integrations</p><p>Jest Unit Testing in React</p><p>End to End Testing in React</p></p></hr></div></div></div></div></div></p></p></p></form><div class="cookiebanner" style="position: fixed; left: 0px; right: 0px; height: auto; min-height: 21px; z-index: 2055; background: rgb(244, 244, 244) none repeat scroll 0% 0%; color: rgb(51, 51, 51); line-height: 21px; padding: 5px 16px; font-family: arial, sans-serif; font-size: 11px; text-align: left; bottom: 0px; opacity: 1;"><div class="cookiebanner-close" style="float: left; padding-left: 5px; padding-right: 5px; color: rgb(23, 157, 130); cursor: pointer;">✖</div><span>We use cookies to improve your browsing experience. <a href="https://sessionize.com/privacy-policy/" target="_blank" style="text-decoration: none; color: rgb(170, 170, 170); font-weight: normal;">Details</a></span></div></div>'
</small></div></div></div><div class="row"><div class="col-md-12"><p>Algunos temassugeridos:</p><p><br/><p>React Foundations.</p><p>State manager: Redux, MobX, flux.</p><p>Style Components.</p><p>React Native</p><p>React Integrations</p><p>Jest Unit Testing in React</p><p>End to End Testing in React</p></p></div></div></div></div></div></p></p></p><p>Algunos temassugeridos:</p><p><br/><p>React Foundations.</p><p>State manager: Redux, MobX, flux.</p><p>Style Components.</p><p>React Native</p><p>React Integrations</p><p>Jest Unit Testing in React</p><p>End to End Testing in React</p></p>'
],];
}
}

0 comments on commit ad20f87

Please sign in to comment.