Skip to content

Commit

Permalink
Merge pull request #4 from openclassify/vedat
Browse files Browse the repository at this point in the history
create addBlock ajax service && added profile ads block
  • Loading branch information
diashalabi authored Sep 30, 2020
2 parents f88f93f + 15581ba commit 2cebc93
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
14 changes: 14 additions & 0 deletions resources/js/block-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function getBlock(location, params = {}) {
var html = "";
$.ajax({
type: 'POST',
data: {'location': location, 'params': params},
async: false,
url: service_url,
success: function (r) {
html = r.html;
},
});

return html;
}
4 changes: 4 additions & 0 deletions resources/views/theme/partials/assets/additional-assets.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ asset_add('scripts.js','visiosoft.extension.addblock::js/block-service.js') }}
<script>
var service_url = "{{ url_route('visiosoft.extension.addblock::api_get_block') }}";
</script>
7 changes: 6 additions & 1 deletion src/AddblockExtensionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ class AddblockExtensionServiceProvider extends AddonServiceProvider
*
* @type array|null
*/
protected $routes = [];
protected $routes = [
'api/get-block' => [
'as' => 'visiosoft.extension.addblock::api_get_block',
'uses' => 'Visiosoft\AddblockExtension\Http\Controller\AddBlockController@getBlock',
],
];

/**
* The addon middleware.
Expand Down
17 changes: 17 additions & 0 deletions src/Http/Controller/AddBlockController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php namespace Visiosoft\AddblockExtension\Http\Controller;

use Anomaly\Streams\Platform\Http\Controller\PublicController;
use Visiosoft\AddblockExtension\Command\addBlock;

class AddBlockController extends PublicController
{
public function getBlock()
{
$html = "";
if ($location = $this->request->location) {
$html = new addBlock($location, $this->request->params);
$html = $html->handle();
}
return $this->response->json(['html' => $html]);
}
}

0 comments on commit 2cebc93

Please sign in to comment.