commit 19fe71b4c1dd22ebff0948c90dcaea82b8f5b3c9 Author: root Date: Mon Nov 9 02:00:13 2026 +0400 initial commit diff --git a/action.php b/action.php new file mode 100644 index 0000000..96f2764 --- /dev/null +++ b/action.php @@ -0,0 +1,26 @@ +linkExist && file_exists(rTorrentSettings::get()->directory)) { + $partitionDirectories = [rTorrentSettings::get()->directory => '']; + } else { + $partitionDirectories = [$topDirectory => '']; + } +} +$ret = []; +foreach (array_keys($partitionDirectories) as $dir) { + $item = [ + "total" => 0, + "free" => 0, + ]; + if (is_dir($dir)) { + $item["total"] = disk_total_space($dir); + $item["free"] = disk_free_space($dir); + } + $ret[] = $item; +} +CachedEcho::send(JSON::safeEncode($ret), "application/json"); diff --git a/conf.php b/conf.php new file mode 100644 index 0000000..8255597 --- /dev/null +++ b/conf.php @@ -0,0 +1,6 @@ + 'media1', '/mnt/media2' => 'media2']; // path => label shown on the bar. If empty, the rtorrent download directory is used +$freeBytesInMeter = false; // show free space instead of % diff --git a/init.js b/init.js new file mode 100644 index 0000000..02d310b --- /dev/null +++ b/init.js @@ -0,0 +1,114 @@ +plugin.loadLang(); +plugin.loadMainCSS(); + +plugin.setValue = function( i, full, free ) +{ + var used = full-free; + var percent = iv(full ? used/full*100 : 0); + if(percent>100) + percent = 100; + var name = (plugin.diskNames && plugin.diskNames[i]) ? plugin.diskNames[i] + ': ' : ''; + $("[id='meter-disk-value']").eq(i).width( percent+"%" ).css( { "background-color": (new RGBackground()).setGradient(this.prgStartColor,this.prgEndColor,percent).getColor(), + visibility: !percent ? "hidden" : "visible" } ); + if(plugin.freeBytesInMeter) $("[id='meter-disk-text']").eq(i).text(name + theConverter.bytes(free)); + else $("[id='meter-disk-text']").eq(i).text(name + percent+'%'); + if(theUILang.diskUsage) { + $("[id='meter-disk-holder']").eq(i).prop("title", + theUILang.diskUsage + .replace(/%USED%/, theConverter.bytes(used)) + .replace(/%TOTAL%/, theConverter.bytes(full)) + .replace(/%FREE%/, theConverter.bytes(free) + ", " + iv(full ? free/full*100 : 0) + "%") + ); + } +} + +plugin.setValues = function( data ) +{ + var low = false; + $.each(data, function(i, d) + { + plugin.setValue(i, d.total, d.free); + if(d.free"); + for(var i = 0; i < plugin.diskCount; i++) + holders.append( + $("
").attr({id: "meter-disk-holder"}).append( + $("
").attr({id: "meter-disk-value"}).width(0), + $("
").attr({id: "meter-disk-text"}), + ) + ); + plugin.addPaneToStatusbar( + "meter-disk-pane", + $("
").append( + $("
").addClass("icon"), + holders.children(), + ), + 1, true, + ); + + plugin.check = function() + { + jQuery.ajax( + { + type: "GET", + timeout: theWebUI.settings["webui.reqtimeout"], + async : true, + cache: false, + url : "plugins/multidisk/action.php", + dataType : "json", + success : function(data) + { + plugin.setValues( data ); + }, + complete : function(jqXHR, textStatus) + { + plugin.diskTimeout = window.setTimeout(plugin.check,plugin.interval*1000); + } + }); + }; + plugin.check(); + plugin.markLoaded(); + } + else + window.setTimeout(arguments.callee,500); +}; + +plugin.onRemove = function() +{ + plugin.removePaneFromStatusbar("meter-disk-pane"); + if(plugin.diskTimeout) + { + window.clearTimeout(plugin.diskTimeout); + plugin.diskTimeout = null; + } +} + +plugin.init(); diff --git a/init.php b/init.php new file mode 100644 index 0000000..79dfada --- /dev/null +++ b/init.php @@ -0,0 +1,30 @@ +linkExist && file_exists(rTorrentSettings::get()->directory)) { + $partitionDirectories = [rTorrentSettings::get()->directory => '']; + } else { + $partitionDirectories = [$topDirectory => '']; + } +} + +$diskOk = function_exists('disk_total_space') && function_exists('disk_free_space'); +if ($diskOk) { + foreach (array_keys($partitionDirectories) as $dir) { + if ((disk_total_space($dir) === false) || (disk_free_space($dir) === false)) { + $diskOk = false; + } + } +} + +if (!$diskOk) { + $jResult .= "plugin.disable();"; +} else { + $jResult .= "plugin.interval = " . $diskUpdateInterval . "; plugin.notifySpaceLimit = " . ($notifySpaceLimit * 1024 * 1024) . ";"; + $jResult .= "plugin.freeBytesInMeter = " . ($freeBytesInMeter ? 1 : 0) . ";"; + $jResult .= "plugin.diskCount = " . count($partitionDirectories) . ";"; + $jResult .= "plugin.diskNames = " . json_encode(array_values($partitionDirectories)) . ";"; + $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); +} diff --git a/lang/cs.js b/lang/cs.js new file mode 100644 index 0000000..42d7d72 --- /dev/null +++ b/lang/cs.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Czech language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/da.js b/lang/da.js new file mode 100644 index 0000000..313739c --- /dev/null +++ b/lang/da.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Danish language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/de.js b/lang/de.js new file mode 100644 index 0000000..df27796 --- /dev/null +++ b/lang/de.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * German language file. + * + * Author: Dario Rugani (kontakt@rugani.de) + */ + + theUILang.diskNotification = "Warnung! Die Festplatte ist voll. Es könnte sein, dass rTorrent nicht ordnungsgemäß funktioniert und es werden keine Daten heruntergeladen, bis Speicherplatz freigeben wird."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/el.js b/lang/el.js new file mode 100644 index 0000000..858ef76 --- /dev/null +++ b/lang/el.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Greek language file. + * + * Author: Chris Kanatas (ckanatas@gmail.com) + */ + + theUILang.diskNotification = "Προειδοποίηση! Ο δίσκος είναι πλήρης. Το rTorrent μπορεί να μην λειτουργεί σωστά, και δεν θα γίνεται λήψη δεδομένων μέχρι να ελευθερώσετε χώρο στο δίσκο."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% ελεύθερα)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/en.js b/lang/en.js new file mode 100644 index 0000000..e79a52a --- /dev/null +++ b/lang/en.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * English language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/es.js b/lang/es.js new file mode 100644 index 0000000..f968130 --- /dev/null +++ b/lang/es.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Spanish language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/fi.js b/lang/fi.js new file mode 100644 index 0000000..1a6b3d9 --- /dev/null +++ b/lang/fi.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Finnish language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/fr.js b/lang/fr.js new file mode 100644 index 0000000..1a110ea --- /dev/null +++ b/lang/fr.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * French language file. + * + * Author: Nicobubulle (nicobubulle@gmail.com) + */ + + theUILang.diskNotification = "Attention! Votre espace disque est plein. rTorrent peut ne pas fonctionner normalement, et aucune donnée ne sera téléchargée jusqu'à ce que vous libériez de l'espace."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% libres)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/hu.js b/lang/hu.js new file mode 100644 index 0000000..ef5ab6c --- /dev/null +++ b/lang/hu.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Hungarian language file. + * + * Author: + */ + + theUILang.diskNotification = "Figyelem! A lemez megtelt. Az rTorrent nem fog megfelelően futni, és addig nem töltődnek le adatok, amíg nem szabadít fel némi helyet a lemezen."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/it.js b/lang/it.js new file mode 100644 index 0000000..762b0f1 --- /dev/null +++ b/lang/it.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Italian language file. + * + * Author: + */ + + theUILang.diskNotification = "Attenzione! Il disco è pieno. rTorrent potrebbe non funzionare correttamente, nessun dato verrà scaricato fino a che non liberi spazio su disco."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/ko.js b/lang/ko.js new file mode 100644 index 0000000..1efcbf6 --- /dev/null +++ b/lang/ko.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Korean language file. + * + * Author: Limerainne (limerainne@gmail.com) + */ + + theUILang.diskNotification = "경고! 디스크가 가득 찼습니다. rTorrent가 정상적으로 동작하지 않을 수 있으며, 여유 공간을 확보하기 전까지는 어떤 데이터도 다운로드되지 않습니다."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/lv.js b/lang/lv.js new file mode 100644 index 0000000..8413b18 --- /dev/null +++ b/lang/lv.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Latvian language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/nl.js b/lang/nl.js new file mode 100644 index 0000000..d7d794d --- /dev/null +++ b/lang/nl.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Dutch language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/nn.js b/lang/nn.js new file mode 100644 index 0000000..e06ad6e --- /dev/null +++ b/lang/nn.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Norwegian (nynorsk) language file. + * + * Author: jakobbg (jakob@grimstveit.no) + */ + + theUILang.diskNotification = "Åtvaring! Disken er full. rTorrent vil kanskje feile. Ingen data vert lasta ned før du frigjer diskplass."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% ledig)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/no.js b/lang/no.js new file mode 100644 index 0000000..ad3e8b2 --- /dev/null +++ b/lang/no.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Norwegian language file. + * + * Author: nirosa (nirosax@gmail.com) + */ + + theUILang.diskNotification = "Advarsel! Disken er full. rTorrent vil kanskje feile. Ingen data blir lastest ned før du frigjør diskplass."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/pl.js b/lang/pl.js new file mode 100644 index 0000000..afa7b16 --- /dev/null +++ b/lang/pl.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Polish language file. + * + * Author: + */ + + theUILang.diskNotification = "Uwaga! Dysk jest pełny. rTorrent może nie działać poprawnie i żadne dane nie zostaną pobrane, dopóki nie zwolnisz miejsca na dysku."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/pt-br.js b/lang/pt-br.js new file mode 100644 index 0000000..c9d0389 --- /dev/null +++ b/lang/pt-br.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Portuguese (Brazil) language file. + * + * Author: + */ + +theUILang.diskNotification = "Atenção! O disco está cheio. O rTorrent pode não funcionar corretamente, e nenhum dado será baixado até que você libere espaço em disco."; +theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/pt-pt.js b/lang/pt-pt.js new file mode 100644 index 0000000..3c85fb9 --- /dev/null +++ b/lang/pt-pt.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Portuguese (Portugal) language file. + * + * Author: + */ + + theUILang.diskNotification = "Aviso! O disco está cheio. O rTorrent pode não funcionar corretamente e nenhum dado será descarregado até espaço em disco ser libertado."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/ru.js b/lang/ru.js new file mode 100644 index 0000000..ef8a52d --- /dev/null +++ b/lang/ru.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Russian language file. + * + * Author: + */ + + theUILang.diskNotification = "Внимание! Ваш диск переполнен. До тех пор, пока Вы не освободите дисковое пространство, данные загружаться не будут, и rTorrent может работать не корректно."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/sk.js b/lang/sk.js new file mode 100644 index 0000000..63e5f77 --- /dev/null +++ b/lang/sk.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Slovak language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/sr.js b/lang/sr.js new file mode 100644 index 0000000..d3c87eb --- /dev/null +++ b/lang/sr.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Serbian language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/sv.js b/lang/sv.js new file mode 100644 index 0000000..e08e285 --- /dev/null +++ b/lang/sv.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Swedish language file. + * + * Author: Magnus Holm (holmen@brasse.se) + */ + + theUILang.diskNotification = "Varning! Disken är full. rTorrent kan inte köras korrekt och ingen data kommer att laddas ner förrän du frigör diskutrymme."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/tr.js b/lang/tr.js new file mode 100644 index 0000000..a576d41 --- /dev/null +++ b/lang/tr.js @@ -0,0 +1,13 @@ +/* + * PLUGIN DISKSPACE + * + * Turkish language file. + * + * Authors: Müslüm Barış Korkmazer (bkbabinco@gmail.com) + * Selim Şumlu + */ + + theUILang.diskNotification = "Uyarı! Disk dolu. rTorrent düzgün çalışmayabilir. Yeni veri indirmek için disk alanınızı boşaltmalısınız."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/uk.js b/lang/uk.js new file mode 100644 index 0000000..9a9bbb7 --- /dev/null +++ b/lang/uk.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Ukrainian language file. + * + * Author: Oleksandr Natalenko (oleksandr@natalenko.name) + */ + + theUILang.diskNotification = "Попередження! Диск заповнено. Програма rTorrent може працювати некоректно, а дані не завантажуватимуться, поки не з’явиться вільне місце на диску."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/vi.js b/lang/vi.js new file mode 100644 index 0000000..07f5247 --- /dev/null +++ b/lang/vi.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Vietnamese language file. + * + * Author: Ta Xuan Truong (truongtx8 AT gmail DOT com) + */ + + theUILang.diskNotification = "Chú ý! Ổ đĩa đầy. rTorrent có thể chạy không ổn định, và sẽ không có dữ liệu nào được tải về thêm cho tới khi bạn dọn bớt ổ đĩa."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/zh-cn.js b/lang/zh-cn.js new file mode 100644 index 0000000..325e5b8 --- /dev/null +++ b/lang/zh-cn.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Chinese Simplified language file. + * + * Author: + */ + + theUILang.diskNotification = "警告! 存储空间已满. rTorrent 可能不会正常运行, 并且在你释放一些空间之前, 将不会下载数据."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/lang/zh-tw.js b/lang/zh-tw.js new file mode 100644 index 0000000..d5d5d33 --- /dev/null +++ b/lang/zh-tw.js @@ -0,0 +1,12 @@ +/* + * PLUGIN DISKSPACE + * + * Chinese Traditional language file. + * + * Author: + */ + + theUILang.diskNotification = "Warning! The disk is full. rTorrent may not run correctly, and no data will be downloaded until you free some disk space."; + theUILang.diskUsage = "%USED%/%TOTAL% (%FREE% free)"; + +thePlugins.get("diskspace").langLoaded(); diff --git a/multidisk.css b/multidisk.css new file mode 100644 index 0000000..8e5ba16 --- /dev/null +++ b/multidisk.css @@ -0,0 +1,50 @@ +#StatusBar { + --pane-disk-icon: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABIUlEQVR4AWKgGOTmZzbkFWQDOCMDFQZhGIju/39TAWrSoLYguupt14K2DJgoPHJc4gMRT+C7L4YnT4wxS7Jg33eYGbz38GU2WO6ZLe+ZQwyXIL0TRLUgAv0iWtC6E4USVYRQCbZtg3MDhqHGwZV87ao5z/MlWNc1S/q+vwW/f5qmVmBmdyS84W0rWJYFXdedEjKOIzvCnLuUEm/O7hQcx/H3lxERIb+CDxdjoEExCEDR//+KAbYGg9kzAlVUqSoK1Lfc94To4TjXxfHeQ2u9IKVc9j+11iUwzm3bcF0XKKUQQkAphRgjCCHIOU+/7wtjDGbAOQfOOc6T4L5vMMZmwFqLYz+QUvp5H/48zxrovaO1NimlDEII3+HCcAMoz0yUAgBzjuKercwF7wAAAABJRU5ErkJggg==); +} + +#meter-disk-pane .icon { + background-image: var(--pane-disk-icon); +} +#meter-disk-holder { + border: inset 1px #BBBBBB; + position: relative; + height: 18px; +} +#meter-disk-value { + height: 100%; +} +#meter-disk-text { + position: absolute; + top: 0; + text-align: center; + width: 100%; + height: 100%; +} + +/* Custom break point settings for responsiveness */ + +/* X-Small devices (portrait phones, less than 576px) */ +/* No media query for `xs` since this is the default in Bootstrap */ +/* Custom rules for x-small devices */ +#meter-disk-holder { + width: 50px; +} + +/* Large devices (desktops, 992px and up) */ +@media (min-width: 992px) { + /* Custom rules for large devices */ + #meter-disk-holder { + width: 100px; + } +} + +#meter-disk-holder { + display: inline-block; + vertical-align: top; +} + +#meter-disk-holder { + display: inline-block; + vertical-align: top; + margin-right: 4px; +} diff --git a/plugin.info b/plugin.info new file mode 100644 index 0000000..f9c24a7 --- /dev/null +++ b/plugin.info @@ -0,0 +1,6 @@ +plugin.description: Disk meters for several partitions in the bottom bar. +plugin.author: pyrschtjag +plugin.version: 1.0 +rtorrent.need: 0 +php.extensions.error: json +plugin.help: https://github.com/Novik/ruTorrent/wiki/PluginDiskspace