|
@@ -29,7 +29,14 @@ $tagsmenu = Yii::$app->cache->getOrSet("tagsmenu",function () use($tmodel){
|
|
|
return $tmodel->find()->rightJoin(['m'=>Tagsfilter::find()], 'm.id = tags.id')->orderBy('sort')->All();
|
|
|
});
|
|
|
|
|
|
-//echo $news->text;
|
|
|
+$key = 'AI_time_mid';
|
|
|
+$AI_time_mid = $cache->get($key);
|
|
|
+if( $AI_time_mid == false ){
|
|
|
+ $AI_time_mid = 100;
|
|
|
+}else{
|
|
|
+ $AI_time_mid = $AI_time_mid/1000000000;
|
|
|
+}
|
|
|
+
|
|
|
?>
|
|
|
|
|
|
<ul class="nav nav-tabs">
|
|
@@ -250,16 +257,29 @@ echo $form->field($news, 'title')->textInput([
|
|
|
<div class="form-group field-news-title required">
|
|
|
<label class="control-label col-form-label" for="news-title">Заголовок</label>
|
|
|
<div class="row">
|
|
|
- <input type="text" maxlength="<?=$tcount?>" id="news-title" class="form-control js-word-count-input col-sm-10 ml-2" name="News[title]" placeholder="Заголовок новости" aria-required="true" value='<?=str_replace("'", ''', $news->title)?>'>
|
|
|
+ <input type="text" maxlength="<?=$tcount?>" id="news-title" class="form-control js-word-count-input col-sm-10 ml-2" name="News[title]" placeholder="Заголовок новости" aria-required="true" value='<?=str_replace("'", ''', $news->title)?>'>
|
|
|
+ <span class="input-group-append">
|
|
|
+ <span type="button" class="btn btn-outline-primary btn-block btn-sm aiget" style="width: fit-content;" id="aititle" data-pb="aiprogress0" data-preprompt="Подскажи привлекательный заголовок для статьи"><i class="fa fa-robot"></i> Гена</span>
|
|
|
+ </span>
|
|
|
<div class="help-block px-lg-2"><div class="news__input-word-count"><span class="badge badge-info" id="title_count"></span></div></div>
|
|
|
<a class="btn btn-primary px-lg-2" data-toggle="collapse" href="#collapseSEOTitle" role="button" aria-expanded="false" aria-controls="collapseSEOTitle">SEO title</a>
|
|
|
- <div class="help-block"></div>
|
|
|
+ <div class="help-block">
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ <div class="progress progress-sm active mt-1 mr-2 hidden">
|
|
|
+ <div class="progress-bar bg-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%" id="aiprogress0"><span class="sr-only">40</span></div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="collapse show" id="collapseSEOTitle">
|
|
|
<div class="card card-body py-1">
|
|
|
+ <span class="input-group-append">
|
|
|
<input type="text" name="News[meta_title]" maxlength="<?=$tcount?>" value="<?=htmlentities($news->meta_title)?>" placeholder="SEO Title" class="form-control js-word-count-input col-sm-10 ml-1 py-0">
|
|
|
+ <span type="button" class="btn btn-outline-primary btn-block btn-sm aiget" style="width: fit-content;" id="aistitle" data-pb="saiprogressx" data-preprompt="Подскажи SEO заголовок для статьи"><i class="fa fa-robot"></i> Гена</span>
|
|
|
+ </span>
|
|
|
<div class="help-block">Поле для альтернативного SEO Title заголовка, если не заполнять совпадёт с основным заголовком</div>
|
|
|
+ <div class="progress progress-sm active hidden" id="saiprogress">
|
|
|
+ <div class="progress-bar bg-success progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%" id="saiprogressx"><span class="sr-only">40</span></div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group field-news-lid required">
|
|
@@ -848,6 +868,7 @@ if (jQuery('#dt_pub').data('datetimepicker')) { jQuery('#dt_pub').datetimepicker
|
|
|
});
|
|
|
$(function() {
|
|
|
window.varsubmit = false;
|
|
|
+ window.robotr = false;
|
|
|
$("input[id='news-title']").keyup(function count(){
|
|
|
number = $("input[id='news-title']").val().length;
|
|
|
$("#title_count").html(number);
|
|
@@ -915,8 +936,46 @@ $(function() {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
+ $(".aiget").click(function(){
|
|
|
+ if( window.robotr ){
|
|
|
+ alert('Может быть только один запрос к роботу, подождите окончания предыдущего запроса.');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ window.robotr = true;
|
|
|
+ let text = CKEDITOR.instances.js_news_content.getData();
|
|
|
+ let preprompt = $(this).data('preprompt');
|
|
|
+ text = preprompt+': '+text;
|
|
|
+ let pbar = '#'+$(this).data('pb');
|
|
|
+ $(pbar).parent().removeClass('hidden');
|
|
|
+ $(pbar).attr('aria-valuenow', 100);
|
|
|
+ $(pbar).css('width','100%');
|
|
|
+ let data = { timer : null };
|
|
|
+ data.timer = setInterval(countprogress, 1000, pbar, data);
|
|
|
+ $.post("/manager/ai/ajax-get-title", {AI:'ollama',text:text, progress: pbar}, function( data ) {
|
|
|
+ if( data.status == 'ok' ){
|
|
|
+ var data_all = data.data;
|
|
|
+ $("#AItext").html(data_all);
|
|
|
+ $('#AI').modal('show');
|
|
|
+ $(data.progress).css('width','0%');
|
|
|
+ $(data.progress).attr('aria-valuenow', 0);
|
|
|
+ }else{
|
|
|
+ console.log(data.msg);
|
|
|
+ $("#AItext").html(data.msg);
|
|
|
+ $('#AI').modal('show');
|
|
|
+ }
|
|
|
+ window.robotr = false;
|
|
|
+ }, "json");
|
|
|
+ });
|
|
|
});
|
|
|
-
|
|
|
+function countprogress(pbar, data){
|
|
|
+ val = $(pbar).attr('aria-valuenow');
|
|
|
+ d = 100/<?=$AI_time_mid?>;
|
|
|
+ console.log(100/d);
|
|
|
+ val = val - d;
|
|
|
+ if( val <=0 ) clearTimeout(data.timer);
|
|
|
+ $(pbar).attr('aria-valuenow', val);
|
|
|
+ $(pbar).css('width',val+'%');
|
|
|
+}
|
|
|
function runSuggestions(element,query) {
|
|
|
let sug_area=$(element).parents().eq(2).find('.autocomplete .autocomplete-items');
|
|
|
if( query.length > 1 ){
|
|
@@ -978,4 +1037,21 @@ window.onbeforeunload = function(e) {
|
|
|
echo $this->render('../top-slider/modalform', ['news'=>$news]);
|
|
|
|
|
|
?>
|
|
|
-
|
|
|
+<div class="modal" tabindex="-1" data-show="true" id="AI">
|
|
|
+ <div class="modal-dialog">
|
|
|
+ <div class="modal-content">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h5 class="modal-title">Генератор текстов от Гены</h5>
|
|
|
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
+ <span aria-hidden="true">×</span>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body">
|
|
|
+ <p id="AItext"></p>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-primary" data-dismiss="modal">Закрыть</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|