Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Articles reactions #539

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
14 changes: 13 additions & 1 deletion www/application/views/templates/articles/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@
<?= View::factory('templates/quizzes/quiz', array('quizData' => $quiz->quiz_data)); ?>
<? endif ?>

<div class="js_reactions-page_voting" data-module="reactionsCreate">
<textarea name="module-settings" hidden>
{
"parent" : "js_reactions-page_voting",
"title" : "How do you like this article?"
}
Copy link
Member

Choose a reason for hiding this comment

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

эмоции можно тоже тут задавать, а не в модуле

</textarea>
</div>

<?= View::factory('templates/blocks/share', array('share' => array(
'offer' => 'Если вам понравилась статья, поделитесь ссылкой на нее',
'url' => 'https://' . Arr::get($_SERVER, 'HTTP_HOST', Arr::get($_SERVER, 'SERVER_NAME', 'codex.so')) . '/' . $article->uri ?: 'article/' . $article->id,
Expand Down Expand Up @@ -208,4 +217,7 @@
->set('course', $course)
?>
<? endif; ?>
</div>
</div>


<script type="text/javascript" src="/public/build/codex.bundle.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

зачем? этот бандл и так подключается в главном шаблоне всех страниц

13,628 changes: 13,628 additions & 0 deletions www/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions www/public/app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ codex.vkWidget = require('./modules/vkWidget');
codex.codeStyling = require('./modules/codeStyling');
codex.deeplinker = require('@codexteam/deeplinker');
codex.pluginsFilter = require('./modules/pluginsFilter');
codex.reactions = require('@codexteam/reactions');
Copy link
Contributor

Choose a reason for hiding this comment

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

Не нужно реквайрить пакет в общую сборку. Лучше сделай это в модуле


import EditorLanding from './modules/editorLanding';
codex.editorLanding = new EditorLanding();

import ArticleCreate from './modules/articleCreate';
codex.articleCreate = new ArticleCreate();

import Reactions from './modules/reactionsArticles';
codex.reactionsCreate = new Reactions();
Copy link
Contributor

Choose a reason for hiding this comment

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

А этот модуль назови codex.reactions


module.exports = codex;

2 changes: 1 addition & 1 deletion www/public/app/js/modules/reactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ module.exports = require('@codexteam/reactions');
//
// }
//
// module.exports = new ReactionsModule();
// module.exports = new ReactionsModule();
Copy link
Member

Choose a reason for hiding this comment

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

зачем два одинаковых по смыслу модуля? надо сделать один универсальный

23 changes: 23 additions & 0 deletions www/public/app/js/modules/reactionsArticles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

/**
* Module for reactions module initialization and inserting it in a specified place on an article's page
*/

export default class Reactions {

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

/**
* Initialize reactions on pages
* @param {Object} settings - reactions parameters
* @param {String} settings.parent - container's class name for reactions module
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {String} settings.parent - container's class name for reactions module
* @param {String} settings.parent - container's selector for reactions module

* @param {String} settings.title - title for reactions module
*
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
*

Copy link
Member

Choose a reason for hiding this comment

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

тогда уж и массив с эмоциями можно тоже передавать через настройки

*/
init(settings) {

let parentElement = document.querySelector('.' + settings.parent),
Copy link
Member

Choose a reason for hiding this comment

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

после поиска parentElement нужно проверять, нашелся ли такой. а вдруг нет?

Copy link
Member

Choose a reason for hiding this comment

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

'.' + settings.parent — то есть строго ограничиваем задание патента через класс? а через # и id не будем давать возможность?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Я изначально сделала так, что можно любой передевать селектор, но меня попросили переделать только на класс. Тоже считаю, что правильнее дать возможность передавать какой-то еще селектор

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let parentElement = document.querySelector('.' + settings.parent),
let parentElement = document.querySelector(settings.parent),

reactionsModule = new codex.reactions({parent: parentElement, title: settings.title, reactions: ['👍', '❤', '👎']});

};

};
2 changes: 1 addition & 1 deletion www/public/build/codex.bundle.css

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions www/public/build/codex.bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions www/public/build/codex.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion www/public/build/editor.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion www/public/build/hawk.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions www/public/build/reactions.bundle.js

Large diffs are not rendered by default.