Skip to content

Commit 5b02ca2

Browse files
committed
Added a validator service for commands
1 parent 515c00e commit 5b02ca2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1211
-1592
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install:
2121
- composer install
2222

2323
script:
24-
- ./vendor/bin/phpunit
24+
- ./vendor/bin/simple-phpunit
2525
# this checks that the source code follows the Symfony Code Syntax rules
2626
- ./vendor/bin/php-cs-fixer fix --diff --dry-run -v
2727
# this checks that the YAML config files contain no syntax errors

app/Resources/translations/messages.en.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@
255255
<source>menu.rss</source>
256256
<target>Blog Posts RSS</target>
257257
</trans-unit>
258+
<trans-unit id="menu.search">
259+
<source>menu.search</source>
260+
<target>Search</target>
261+
</trans-unit>
258262

259263
<trans-unit id="post.to_publish_a_comment">
260264
<source>post.to_publish_a_comment</source>
@@ -288,6 +292,10 @@
288292
<source>post.deleted_successfully</source>
289293
<target>Post deleted successfully!</target>
290294
</trans-unit>
295+
<trans-unit id="post.search_for">
296+
<source>post.search_for</source>
297+
<target>Search for...</target>
298+
</trans-unit>
291299

292300
<trans-unit id="notification.comment_created">
293301
<source>notification.comment_created</source>

app/Resources/translations/messages.ru.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@
288288
<source>post.deleted_successfully</source>
289289
<target>Запись успешно удалена!</target>
290290
</trans-unit>
291+
<trans-unit id="post.search_for">
292+
<source>post.search_for</source>
293+
<target>Искать запись...</target>
294+
</trans-unit>
291295

292296
<trans-unit id="notification.comment_created">
293297
<source>notification.comment_created</source>

app/Resources/views/base.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<header>
2424
<div class="navbar navbar-default navbar-static-top" role="navigation">
2525
<div class="container">
26-
<div class="navbar-header">
26+
<div class="navbar-header col-md-3 col-lg-2">
2727
<a class="navbar-brand" href="{{ path('homepage') }}">
2828
Symfony Demo
2929
</a>
@@ -64,6 +64,10 @@
6464
</li>
6565
{% endif %}
6666

67+
<li>
68+
<a href="{{ path('blog_search') }}"> <i class="fa fa-search"></i> {{ 'menu.search'|trans }}</a>
69+
</li>
70+
6771
<li class="dropdown">
6872
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" id="locales">
6973
<i class="fa fa-globe" aria-hidden="true"></i>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{% extends 'base.html.twig' %}
2+
3+
{% block javascripts %}
4+
{{ parent() }}
5+
<script src="{{ asset('build/js/search.js') }}"></script>
6+
{% endblock %}
7+
8+
{% block main %}
9+
<form action="{{ path('blog_search') }}" method="get">
10+
<div class="form-group">
11+
<input name="q" type="text" class="form-control search-field" placeholder="{{ 'post.search_for'|trans }}" autocomplete="off" autofocus>
12+
</div>
13+
</form>
14+
15+
<div id="results">
16+
</div>
17+
{% endblock %}
18+
19+
{% block sidebar %}
20+
{{ parent() }}
21+
22+
{{ show_source_code(_self) }}
23+
{% endblock %}

app/config/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ framework:
5151
json_manifest_path: '%kernel.project_dir%/web/build/manifest.json'
5252
php_errors:
5353
log: true
54+
cache:
55+
# this value is used as part of the "namespace" generated for the cache item keys
56+
# to avoid collisions when multiple apps share the same cache backend (e.g. a Redis server)
57+
# See https://symfony.com/doc/current/reference/configuration/framework.html#prefix-seed
58+
prefix_seed: symfony-demo
5459

5560
# Twig Configuration (used for rendering application templates)
5661
twig:

app/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
$locales: '%app_locales%'
4343
$defaultLocale: '%locale%'
4444

45-
# needed for the localizeddate Twig filter
45+
# needed for the 'localizeddate' Twig filter
4646
Twig\Extensions\IntlExtension: ~
4747

4848
# the slugger service needs a public alias for getting it from

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ install:
4848

4949
test_script:
5050
- cd c:\projects\symfony-demo
51-
- php vendor/bin/phpunit
51+
- php vendor/bin/simple-phpunit
File renamed without changes.
File renamed without changes.
File renamed without changes.

assets/js/jquery.instantSearch.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* jQuery plugin for an instant searching.
3+
*
4+
* @author Oleg Voronkovich <[email protected]>
5+
*/
6+
(function($) {
7+
$.fn.instantSearch = function(config) {
8+
return this.each(function() {
9+
initInstantSearch(this, $.extend(true, defaultConfig, config || {}));
10+
});
11+
};
12+
13+
var defaultConfig = {
14+
minQueryLength: 2,
15+
maxPreviewItems: 10,
16+
previewDelay: 500,
17+
noItemsFoundMessage: 'No results found.'
18+
};
19+
20+
function debounce(fn, delay) {
21+
var timer = null;
22+
return function () {
23+
var context = this, args = arguments;
24+
clearTimeout(timer);
25+
timer = setTimeout(function () {
26+
fn.apply(context, args);
27+
}, delay);
28+
};
29+
}
30+
31+
var initInstantSearch = function(el, config) {
32+
var $input = $(el);
33+
var $form = $input.closest('form');
34+
var $preview = $('<ul class="search-preview list-group">').appendTo($form);
35+
36+
var setPreviewItems = function(items) {
37+
$preview.empty();
38+
39+
$.each(items, function(index, item) {
40+
if (index > config.maxPreviewItems) {
41+
return;
42+
}
43+
44+
addItemToPreview(item);
45+
});
46+
}
47+
48+
var addItemToPreview = function(item) {
49+
var $link = $('<a>').attr('href', item.url).text(item.title);
50+
var $title = $('<h3>').attr('class', 'm-b-0').append($link);
51+
var $summary = $('<p>').text(item.summary);
52+
var $result = $('<div>').append($title).append($summary);
53+
54+
$preview.append($result);
55+
}
56+
57+
var noItemsFound = function() {
58+
var $result = $('<div>').text(config.noItemsFoundMessage);
59+
60+
$preview.empty();
61+
$preview.append($result);
62+
}
63+
64+
var updatePreview = function() {
65+
var query = $.trim($input.val()).replace(/\s{2,}/g, ' ');
66+
67+
if (query.length < config.minQueryLength) {
68+
$preview.empty();
69+
return;
70+
}
71+
72+
$.getJSON($form.attr('action') + '?' + $form.serialize(), function(items) {
73+
if (items.length === 0) {
74+
noItemsFound();
75+
return;
76+
}
77+
78+
setPreviewItems(items);
79+
});
80+
}
81+
82+
$input.focusout(function(e) {
83+
$preview.fadeOut();
84+
});
85+
86+
$input.focusin(function(e) {
87+
$preview.fadeIn();
88+
updatePreview();
89+
});
90+
91+
$input.keyup(debounce(updatePreview, config.previewDelay));
92+
}
93+
})(window.jQuery);
File renamed without changes.

assets/js/search.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import './jquery.instantSearch.js';
2+
3+
$(function() {
4+
$('.search-field').instantSearch({
5+
previewDelay: 100,
6+
});
7+
});
File renamed without changes.

app/Resources/assets/scss/app.scss renamed to assets/scss/app.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// setting the value of this variable to an empty data URL is the only working solution
2+
// to load the Bootswatch web fonts locally and avoid loading them from Google servers
3+
// see https://github.com/thomaspark/bootswatch/issues/55#issuecomment-298093182
4+
$web-font-path: 'data:text/css;base64,';
5+
16
@import "~bootswatch/flatly/variables";
27
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
38
@import "~bootswatch/flatly/bootswatch";

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
"white-october/pagerfanta-bundle" : "^1.0"
3636
},
3737
"require-dev": {
38-
"dama/doctrine-test-bundle" : "^1.0",
38+
"dama/doctrine-test-bundle" : "^3.0",
3939
"friendsofphp/php-cs-fixer" : "^2.0",
40-
"phpunit/phpunit" : "^4.8 || ^5.0",
4140
"sensio/generator-bundle" : "^3.0",
4241
"symfony/phpunit-bridge" : "^3.0"
4342
},

0 commit comments

Comments
 (0)