powered by simpleCommunicator - 2.0.18     © 2024 Programmizd 02
Map
Форумы / Вопросы по форуму [закрыт для гостей] / Вышел патч кролика 18.09.2023, Поиск: Сообщение содержит картинки  
2 сообщений из 2, страница 1 из 1
Вопросы по форуму / Вышел патч кролика 18.09.2023
    #544712
basename
Скрыть профиль Поместить в игнор-лист
Участник
said  18.09.2023, 20:48
[игнорируется]
базя, лови патч для ссылок ютуба

- фикс коверов:
вместо дефолтной унылой ютуб-ебалы, теперь загружаются реальные картиночки

- фикс шортсов
- фикс ембеддед со старт-стопом
- фикс автозапуска плеера (раньше плеер запускался по тайм-ауту 1000 мс, и нередко этого значения не хватало - плеер не всегда запускался)
теперь на ифрейм там приаттачен эвент onload

topic.js - только для дефолтного скина
остальные, сам допилит, если надо
fix-youtube.zip
после применения патча, всем юзерам сделать обновление кеша:

хром: SHIFT/CTRL + F5
фокс: CTRL + SHIFT + R
Пока не применил. Есть вопросы. said

Кролик, ты брал версии файлов из ГитХаба из ветки NoSQL?

Ну с этим всё понятно
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
[root@dragon forum]# diff -u include/bb_parse_functions_inc.php /home/avkoudinov/nosql/tmp/fix-youtube_20230919/bb_parse_functions_inc.php
--- include/bb_parse_functions_inc.php  2023-09-17 13:16:00.000000000 +0300
+++ /home/avkoudinov/nosql/tmp/fix-youtube_20230919/bb_parse_functions_inc.php  2023-09-18 20:36:05.000000000 +0300
@@ -1141,7 +1141,14 @@
         $code = $matches[1];

         $appendix = val_or_empty($matches["2"]);
-    } elseif (preg_match('/https:\\/\\/[^\\/]*youtube\\.com\\/embed\\/([A-z0-9=\-]+?)\?(start=\\d+).*/i', $content, $matches)) {
+    }
+
+//     elseif (preg_match('/https:\\/\\/[^\\/]*youtube\\.com\\/embed\\/([A-z0-9=\-]+?)\?(start=\\d+)(&end=\\d+)?/i', $content, $matches))
+
+     elseif (preg_match("#/(https://%5B^/%5D*youtube.com/embed/(%5B0-9a-z=\-%5D+?)(\?si=%5B0-9a-z%5D+)?((\?%7C&)start=\d+)(&end=\d+)?)/i#", $content, $matches))
+
+
+     {
         $code = $matches[1];

         $appendix = val_or_empty($matches["2"]);
@@ -1153,12 +1160,13 @@
     }

     $bbcode_text = "[" . $name . "]" . $content . "[/" . $name . "]";
-
+
     return gen_youtube_html($code, $apikey, $appendix, $bbcode_text);
 } // bb_process_youtube
 //------------------------------------------------------------------------------
-function check_youtube_url($url, &$content, $message_mode)
-{
+
+function check_youtube_url($url, &$content, $message_mode) {
+
     $apikey = "";
     if (defined('YOUTUBE_API_KEY')) {
         $apikey = YOUTUBE_API_KEY;
@@ -1224,16 +1232,19 @@
         return true;
     }

-    if (preg_match('/https:\\/\\/[^\\/]*youtube\\.com\\/embed\\/([A-z0-9=\-]+?)\?(start=\\d+).*/i', $url, $matches)) {
+    if (preg_match("#(https://%5B^/%5D*youtube.com/embed/(%5B0-9a-z=\-%5D+)(\?si=%5B0-9a-z\-_%5D+)?((\?%7C&)start=\d+)?(&end=\\d+)?)?#i", $url, $matches)) {
         if ($message_mode != "message") {
             $content = "\n[Видеоклип: YouTube]\n\n";
             return true;
         }

         $content = gen_youtube_html($matches[1], $apikey, val_or_empty($matches["2"]), $url);
+
         return true;
     }

+
+
     return false;
 } // check_youtube_url
 //------------------------------------------------------------------------------
@@ -2486,12 +2497,17 @@
     }

     $html = "<div class='media_wrapper' data-bbcode='" . escape_html($bbcode) . "'><div class='short_video'><a class='youtube_short_container' href='https://youtu.be/" . escape_html($code . $appendix) . "' target='blank'>" . escape_html($title) . "</a></div>";
+
+
+    $preurl = preg_match("#/embed/#i", $code) ? '' : 'https://youtu.be/';
+    preg_match("#/embed/([0-9a-z\-_]+)\?#i", $code, $covmatch);
+    $picture = "http://img.youtube.com/vi/".($covmatch ? $covmatch[1] : $code)."/hqdefault.jpg";
     $html .= "<div class='youtube_container detailed_video'><div class='youtube_wrapper' style='background-image:url($picture)'>";
     $html .= "<div class='youtube_header'>" . escape_html($title) . "</div>";
     $html .= "<div class='youtube_play_embedded' onclick='embed_youtube(this, \"$code\", $start)'></div>";
-    $html .= "<a class='youtube_play_youtube' href='https://youtu.be/" . escape_html($code . "?t=" . $start) . "' target='blank'></a>";
+    $html .= "<a class='youtube_play_youtube' href='".$preurl."".escape_html($code."?t=".$start)."' target='blank'></a>";
     $html .= "</div></div></div>";
-
+
     return $html;
 } // gen_youtube_html
 //------------------------------------------------------
[root@dragon forum]#
А вот здесь что-то не совсем понятно.
Код
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
[root@dragon forum]# diff -u skins/default/desktop/topic.js /home/avkoudinov/nosql/tmp/fix-youtube_20230919/topic.js
--- skins/default/desktop/topic.js      2023-08-30 08:46:00.000000000 +0300
+++ /home/avkoudinov/nosql/tmp/fix-youtube_20230919/topic.js    2023-09-18 20:17:39.000000000 +0300
@@ -160,34 +160,32 @@
   elms[pos].classList.add('active');
 }

-function embed_youtube(elm, code, start)
-{
-  var parent = elm.parentNode;
-  while(parent)
-  {
-    if(parent.classList && parent.classList.contains('youtube_container'))
-    {
+function embed_youtube(elm, code, start) {
+  var
+   fc,
+   iframe,
+   preurl = /\/embed\//i.test(code) ? '' : 'https://www.youtube.com/embed/' + code + "?autoplay=1" + "&start=" + start,
+   parent = elm.parentNode;
+
+  while(parent)  {
+    if(parent.classList && parent.classList.contains('youtube_container')) {
       // remove all previous children
-      var fc = parent.firstChild;
-      while(fc)
-      {
+      fc = parent.firstChild;
+
+      while(fc) {
         parent.removeChild(fc);
         fc = parent.firstChild;
       }

-      // add iframe
-      var iframe = document.createElement('iframe');
+      iframe = document.createElement('iframe');
       iframe.style.width = parent.clientWidth + "px";
       iframe.style.height = parent.clientHeight + "px";
       iframe.style.border = "0";
-      iframe.src = "https://www.youtube.com/embed/" + code + "?autoplay=1" + "&start=" + start + "&enablejsapi=1";
-
+      iframe.src = preurl + code + "&enablejsapi=1";
       iframe.setAttribute("allowfullscreen", "1");
+      iframe.addEventListener('load', () => iframe.contentWindow.postMessage('{ "event": "command", "func": "playVideo", "args": ""}', '*'), true);

       parent.appendChild(iframe);
-
-      setTimeout(() => { iframe.contentWindow.postMessage('{ "event": "command", "func": "playVideo", "args": ""}', '*'); }, 1000);
-
       break;
     }

@@ -195,6 +193,7 @@
   }
 }

+
 function embed_vimeo(elm, code, at)
 {
   var parent = elm.parentNode;
@@ -1404,10 +1403,7 @@
           exec_reload_online_users();
         }, 200);

-        if(messages) {
-          Forum.handle_response_messages(messages);
-          changeChatAvatar();
-        }
+        if(messages) Forum.handle_response_messages(messages);
       }
       catch(err)
       {
@@ -1871,48 +1867,12 @@
   }
 }

-// for kroleg-pipe
-function getChatAuthor(pid, author) {
- var
-  msgObj = document.querySelector('#message_text_' + pid),
-  userNick = msgObj.querySelector('.kroleg_pipe');
-
- return (userNick)
-  ? { author: userNick.innerText.replace(/:$/, ''), krolegPipe: true }
-  : { author: author, krolegPipe: false };
-}//func
-
-
-function changeChatAvatar() {
- var
-  img,
-  chatArray = document.querySelectorAll('.kroleg_pipe');
-
-  chatArray.forEach((v) => {
-   if(!v.dataset.uid || !v.dataset.ext) return true;
-   img = document.createElement('img');
-   img.src = /^a_/.test(v.dataset.uid)
-    ? 'https://news.kroleg.tk/pic/avatars/' + v.dataset.uid
-    : 'https://chat.kroleg.tk/pic/avatars/p_' + v.dataset.uid + '.' + v.dataset.ext;
-   img.onload = function() {
-    var
-     img = v.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('.avatar_container').querySelector('img');
-
-    img.src = this.src;
-    img.className = 'kroleg_pipe';
-   }
-  });
-}//func
-
 function answer_to_author(pid, author, tid, subject, profiled_topic, stringent_rules)
 {
   var elm = document.getElementById("post_table_" + pid);

   var cid = 'post_container_' + pid;

-  // for kroleg-pipe
-  author = getChatAuthor(pid, author);
-
   elm = document.getElementById("load_last_version");
   if(elm) elm.style.visibility = has_auto_saved_message ? "visible" : "hidden";

@@ -1921,11 +1881,11 @@

   if(elm.value != "") elm.value += "\n\n";

-  if(author.author != '') {
-    elm.value += "[b]" + author.author;
-    if(!archive_mode && !author.krolegPipe) elm.value += "#" + pid;
-    elm.value += "[/b]";
-    if(author.krolegPipe) elm.value += ", "; else elm.value += "\n\n";
+  if(author != '')
+  {
+    elm.value += "[b]" + author;
+    if(!archive_mode) elm.value += "#" + pid;
+    elm.value += "[/b]\n\n";
   }

   elm.defaultValue = elm.value;
@@ -2361,19 +2321,14 @@
     citation_text = citation_text.replace(new RegExp("[\r\n]{2,}", "g"), "\n\n");
   }

-// for kroleg-pipe
-  author_found = getChatAuthor(pid, author_found);
-  if(author_found.krolegPipe) citation_text = citation_text.replace(/\[color=#[0-9a-z]+\][^"]+:\[\/color\]/i, '');
-//
-
   if(citation_text == '')
   {
-    return answer_to_author(pid, author_found.author, tid, subject, profiled_topic, stringent_rules);
+    return answer_to_author(pid, author_found, tid, subject, profiled_topic, stringent_rules);
   }

-  if(parent_pid == '' || pid_found == '' || author_found.author === false) return false;
+  if(parent_pid == '' || pid_found == '' || author_found === false) return false;

-  return citate_text(parent_pid, pid_found, author_found.author, tid, subject, profiled_topic, stringent_rules, citation_text);
+  return citate_text(parent_pid, pid_found, author_found, tid, subject, profiled_topic, stringent_rules, citation_text);
 }

 function citate_text(parent_pid, pid, author, tid, subject, profiled_topic, stringent_rules, text)
@@ -3868,7 +3823,6 @@
   init_lightbox_images();
   init_more_buttons();
   init_citations();
-  changeChatAvatar();

   debug_line("Topic history intialization", 'history');
   window.history.scrollRestoration = 'manual';
[root@dragon forum]#
Ты трубу выпилил? Зачем?
- Если ты захочешь её вернуть, опять этот злоебучий topic.js править во всех скинах там 6 штук этих файлов?
- Помимо topic.js - там ещё правки в css, bb_parse

Ну беспорядок так пздц. Я не хочу править 6 js файлов + 9 css.
...
Рейтинг: 0 / 0
Вопросы по форуму / Вышел патч кролика 18.09.2023
    #544851
basename
Скрыть профиль Поместить в игнор-лист
Участник
said [игнорируется] 

Твой цикл работ с Гит примерно следующий

1. Создал рабочую директорию, например, перешёл в неё

2. В рабочую директориюю клонируешь проект (точка в конце клонировать в директорию, где находишься)
Код
1.
git clone https://github.com/avkoudinov/simpleCommunicator.git .
3. После клонирования переключаешься на ветку NoSQL и скачиваешь/обновляешь код
Код
1.
2.
git checkout NoSQL
git pull origin NoSQL
4. Ветку мастер можешь в принципе удалить, она тебе не нужна, чтобы не смущало. Он варнинг вывалит, но по фиг, тебе больше ничего не надо будет делать с этим, поэтому можно удалить, ну или перед рабоотой проверять, что находишься в нужнйо ветке.
Код
1.
git branch -d master
Проверить можно командами
Код
1.
2.
git status
git branch -av
5. Если дед выпустил новый патч, обновлять также, git pull origin NoSQL. ну и далее копируешь куда-нибудь, правишь, что хочешь.

Всё. Больше тебе с гитом ничего не надо делать.
pasted_image.png
pasted_image.png
...
Рейтинг: 1 / 0
Нравится: Гарыныч
2 сообщений из 2, страница 1 из 1
Форумы / Вопросы по форуму [закрыт для гостей] / Вышел патч кролика 18.09.2023, Поиск: Сообщение содержит картинки  
Читали тему (1): Анонимы (1)
Игнорируют тему (1): erbol
Читали форум (18): Анонимы (17), Yandex Bot
Пользователи онлайн (62): Анонимы (58), Yandex Bot, Ветер 1 мин., Брюквенные годы 6 мин., Bing Bot 9 мин.
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]