raudius / files_scripts Goto Github PK
View Code? Open in Web Editor NEWCustom file actions app for Nextcloud
License: GNU Affero General Public License v3.0
Custom file actions app for Nextcloud
License: GNU Affero General Public License v3.0
Currently its only possible to create input in textboxes. Would be nice to include a way to add different input types
Hi,
is there a possibility to recreate function of linking mutiple files into a project?
Best Regards,
Adhai
The issue locate in
/var/www/nextcloud/apps/files_scripts/lib/Interpreter/Functions/Files/Meta_Data.php:41
Call of $node->getStorage()->getLocalFile() for folder generate exception InvalidTypeException, and it doesn't catch in your code.
It seems to me the function "file_move_unsafe" was broken in a recent update, probably with the introduction of folder support? From my testing, the function works fine when files are moved within the directory owned by the executing user but not to another user's directory (purpose of the function).
It would be great to have the capability to edit tags on files.
This would allow for a (limited) integration with other flows.
My personal usecase here is to split and merge multiple PDFs and tag the resulting file for further processing with the "Workflow external scripts" to send the result to a printer.
I was working my way up to creating a script that would allow users to tag files for ocr-scanning.
And it was working.
But at some point, I could create a new public tag called ocr in the admin-panel, but
tags = tags_find({name = "ocr"})
log(#tags)
started to return 0.
And where I was getting a single tag before (tags_find({id = 5}))
became Nil (The id is identical to the one in the headers of the network traffic when modifying it)
Add an option to make file actions available through public shares.
Would be nice to have a function to convert images to a PDF File. Just like https://github.com/josch/img2pdf
As described here:
โ ๏ธ DEPRECATED: Replace usage with user input of type "file-picker".
Hint: set the accepted mimetypes to justhttpd/unix-directory
to limit file picker to directories.
and here:
Note: to allow a user to pick a folder the
httpd/unix-directory
mimetype must be added to the filepick options.
one should replace the "Request target folder" mechanism, linked to get_target-folder() with the Filepicker from the "User inputs" mechanism, linked to get_input().
Now to the issue:
It would be nice to be able to save scripts on Ctrl-S. If this is not difficult to implement, I can add it to my existing PR.
Since nextcloud is sometimes having issues regarding dead file locks, I wanted to write a file action to force unlock. I built the following script:
local nodes = get_input_files()
for key, node in ipairs(nodes)
do
if(file_unlock(node, false))
then
add_message(node.name .." unlocked", "success")
else
add_message(node.name .." could not be unlocked", "warning")
end
end
Since video files are locked as soon as you play them, I started a video, closed the player, tried to rename the file. File cannot be renamed (as expected since it is locked). Executed the Unlock file action, got success. Tried to rename the file again. Still impossible. Did I get sth wrong or is it a bug? I'm using experimental interpreter.
Hey,
here are some QoL ideas that is got while using it.
It's possible to postpone the input options to the bottom but not up or 1 step down/up
Currently, I have to move everything to the bottom after each other to sort it. If a var is renamed, it automatically goes to the bottom and u have to reorder it.
Sorting the options in multiple choice input
Currently u have to delete and recreate the different options to reorder it if for example a new option is added
both might be possible with drag & drop to move/sort things more freely
A optional label for inputs
Currently the inputs just have an placeholder witch isn't visible on input.
Hi! Let me suggest to add a new example to the list of scripts: OCR document.
With it a user may select some PDF document, select languages, and select output file (either to use the same or create a new file (optionally)). The tesseract and installed languages are required.
Will it be possible to do it?
Hello there!
I'm looking for functionality to send selected filenames to certain email. Is it doable with this plugin? I can manage simple scripting based on documentation.
Thanks!
It would be nice to have two additional types: textarea and true multiselect. Textarea is much more convenient for multi-line comments. The current multiselect itself is just a select, there is no multiselect. Is it possible?
Hi,
you use Transifex to translate and our system to update it.
This uses nextcloud-bot to commit the changes directly to master/stable branches.
Please add therefore @nextcloud-bot as an Admin via
https://github.com/Raudius/files_scripts/settings/access
Hi! I have set up file actions app, install lua according to the updated readme as of today,
I have added row extension=lua.so
both to /etc/php/8.1/apache2/conf.d/@20-lua.ini
and /etc/php/8.1/cli/conf.d/@20-lua.ini
I do not see either the folder or the resulting file prompt at all if to compare with the screenshot from the app description:
Trying to test it with the Merge PDFs example script, which is provided with the app, I am constantly getting error
[string "line"]:8: attempt to call a nil value (global 'get_target_folder')
Ubuntu 22.04
Apache2.4.52
PHP 8.1.2
Nextcloud 26.0.5
qpdf 10.6.3
What may be wrong?
Hi,
Would it be possible to use the app direct from the app store and only for specific features additional software will be needed.
I have a managed nextcloud where I can install apps, but no option to install additional software.
Hello,
I haven't found anything in the documentation related to share handling. It would be really useful to be able deal with share the same was we can deal with files and folder: list shares (in a given folder, as a whole?) check if a node is a share, move share, delete share, create_share.
Is that already possible and if not, is that something that could be done sometimes?
Thanks!
It would be great to have the capability to get collaborative tags from selected file and user id of owner of the file (from get_input_files() in node object )
Hi! I have followed the installation manual and found that make test
prompts at least 3 errors:
$ make test
Build complete.
Don't forget to run 'make test'.
=====================================================================
PHP : /usr/bin/php8.1
PHP_SAPI : cli
PHP_VERSION : 8.1.2-1ubuntu2.14
ZEND_VERSION: 4.1.2
PHP_OS : Linux - Linux a3.local 6.2.0-26-generic #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jul 13 16:27:29 UTC 2 x86_64
INI actual : /home/server/php-lua/tmp-php.ini
More .INIs :
CWD : /home/server/php-lua
Extra dirs :
VALGRIND : Not used
=====================================================================
TIME START 2023-08-26 07:54:14
=====================================================================
PASS Basic lua check [tests/001.phpt]
PASS Check for Table Pass vic-a-verse [tests/0014.phpt]
FAIL Set and read properties [tests/002.phpt]
PASS Call lua functions [tests/003.phpt]
FAIL Type conversion from lua to PHP [tests/004.phpt]
PASS Lua phpinfo() block [tests/005.phpt]
PASS Lua::include() [tests/006.phpt]
PASS Lua return function [tests/007.phpt]
PASS register php function to lua [tests/008.phpt]
PASS Bug (eval and include compute wrong return value number) [tests/009.phpt]
PASS LuaClosure exception [tests/010.phpt]
PASS register invalid php callback to lua [tests/011.phpt]
PASS Lua::include() with error codes [tests/012.phpt]
PASS PHP Closures from Lua [tests/013.phpt]
PASS PHP Object to lua [tests/016.phpt]
PASS Bug #65097 (nApplyCount release missing) [tests/bug65097.phpt]
PASS Bug #71997 (One-Dimensional arrays cause segmentation faults) [tests/bug71997.phpt]
FAIL Bug #73964 (Segmentation fault (11)) [tests/bug73964.phpt]
PASS ISSUE #022 (Boolean FALSE is always TRUE) [tests/issue012.phpt]
PASS ISSUE #040 (segmentation fault) [tests/issue040.phpt]
PASS test basic print() functionality [tests/print.phpt]
PASS print with tables - 1 [tests/print_tables-1.phpt]
PASS print with tables - 2 [tests/print_tables-2.phpt]
=====================================================================
TIME END 2023-08-26 07:54:19
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 16
---------------------------------------------------------------------
Number of tests : 23 23
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 3 ( 13.0%) ( 13.0%)
Tests passed : 20 ( 87.0%) ( 87.0%)
---------------------------------------------------------------------
Time taken : 5 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Set and read properties [tests/002.phpt]
Type conversion from lua to PHP [tests/004.phpt]
Bug #73964 (Segmentation fault (11)) [tests/bug73964.phpt]
=====================================================================
You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it. You can then email it to [email protected] later.
Do you want to send this report now? [Yns]:
Hi,
I'm trying to create a new folder in a script, but there doesn't seem to be a function for that case. There is a new_file
function in the api, but i can't find one regarding folders. Would it be possible to implement one or is there another workaround?
This lib https://github.com/PHP-FFMpeg/PHP-FFMpeg can be added for helping to convert video/audio or extracting audio or take screenshot from video and more tools.
Also have this 3 nextcloud apps already use ffmpeg:
https://apps.nextcloud.com/apps/workflow_media_converter
https://apps.nextcloud.com/apps/video_converter
https://apps.nextcloud.com/apps/ncdownloader
I find the possiblity to link file actions in the file menu extremely useful and it's greatly appreciated. However, I would prefer to be able to define it for every file action separately, otherwise the menu gets cluttered. So the "More actions" should always be there but you can also link/highlight individual actions in the menu which would make it more tidy imo.
To Reproduce:
files = get_input_files()
for i, file in ipairs(files) do
name = file.name
if name == "a.txt" then
file_move(file, nil, "b.txt")
end
end
a.txt
, notice how it doesn't renamea.txt
, it should rename but it doesn'tWould it be useful to have a script repository with file_actions which you can activate if wanted or at least which users can use as template for there needs.
Or at least a link to a repository where you can get some inspiration.
I'm thinking on something like
https://store.kde.org/browse?cat=102&ord=latest
When selecting with the Multi-select mechanism, the first option returns (when selected) an error.
Also, the selected item does not remain visible in the list after it has been selected.
Reproduce with:
Testing this action returns the choosen animal but dog. When choosing dog, it returns "Action failed unexpectedly"
Confusing: no matter what animal i choose, only "dog" is visible.
Did I missunderstand something again?
Hi! Unable to add Lua script in File Actions app. This is an error:
Error message in Nextcloud log:
{
"reqId": "MCZrWjVXp2fM883AJdfp",
"level": 3,
"time": "2023-03-07T11:09:17+00:00",
"remoteAddr": "192.168.6.29",
"user": "serg",
"app": "files_scripts",
"method": "POST",
"url": "/apps/files_scripts/scripts",
"message": "File scripts insert error",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36",
"version": "25.0.4.1",
"data": {
"app": "files_scripts",
"trace": "#0 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(329): OC\DB\Exceptions\DbalException::wrap()#1 /var/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php(139): OC\DB\QueryBuilder\QueryBuilder->executeStatement()\n#2 /var/www/nextcloud/apps/files_scripts/lib/Controller/ScriptController.php(104): OCP\AppFramework\Db\QBMapper->insert()\n#3 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(225): OCA\FilesScripts\Controller\ScriptController->create()\n#4 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(133): OC\AppFramework\Http\Dispatcher->executeController()\n#5 /var/www/nextcloud/lib/private/AppFramework/App.php(172): OC\AppFramework\Http\Dispatcher->dispatch()\n#6 /var/www/nextcloud/lib/private/Route/Router.php(298): OC\AppFramework\App::main()\n#7 /var/www/nextcloud/lib/base.php(1047): OC\Route\Router->match()\n#8 /var/www/nextcloud/index.php(36): OC::handleRequest()\n#9 {main}"
}
}
what am I doing wrong?
I need to get a list of Nodes in an arbitrary folder. There is a directory_listing() function here, but it needs to pass an argument of type Node, not a string. How to solve this problem?
Hi Raul,
first of all: thank you so much for this great app. I am a big fan and use it at a daily basis for a growing number of solutions.
The only thing that drives me nuts, is the new get_file_tags()
function.
In the Scripting Api it says:
I gues that is a tipo (get_tags instead of get_file_tags), same in this line:
But now to my issue:
I am trying to get the tags from a previously tagged file.
My first step to understand how things work, is to return the echo into a text-file, like it works with all the meta_data etc. but in this case it does not work.
Since get_file_tags()
returns a table, I used table.concat()
to get a coma separated list of tags like this:
local files = get_input_files()
for _, input_file in ipairs(files) do
local output_filename = input_file.name .. '.tags.txt'
local out_folder = get_parent(input_file)
if exists(out_folder, output_filename) then
abort('Output file "' .. output_filename .. '" already exists. Skipping...')
goto continue
end
local tags = get_file_tags(input_file)
local tags_str = table.concat(tags, ',')
new_file(out_folder, output_filename, tags_str)
::continue::
end
.. but it does not work.
But when I do:
local tags = get_file_tags(input_file)
-- local tags_str = table.concat(tags, ',')
new_file(out_folder, output_filename, #tags)
it returns the correct number of tags.
What am I doing wrong?
Error Message "lua extension not installed on server" shown although lua is listed when executing php -m on server.
Any hints for a cause/solution?
Hi,
Tried to add very simple script (for flows) to remove tags under certain conditions.
However, it seems that function unassign works only of tag ID ( in the form od argument i.e "{ID=1}", but it ignores name= or just plain tagname as string.
Kind Regards,
Adhai
The function get_file_tags() returns the system tag id as string rather than as int.
The installation instructions tell to append extension=lua.so to your php.ini
, but how do you do that on the Snap package? I've tried editing the php.ini within the /snap/nextcloud/current/config/php
directory, but it doesn't work since snap files are in a read-only filesystem.
Would be nice to build out scripts which end up opening specified files for editing or viewing purposes.
use case:
When iterating through nodes, some nodes may be skipped due to tests. In such a case, when the script should not be aborted but only message should be thrown out (maybe with control over the collor for info, warn, error).
When using the user input "Checkbox", a litlle slider appears and when clicking once on it, it returns true but no optical feedback if checkbox is "Set".
Once the input is clicked, it is impossible to unset the checkbox again, once clicked, it stays returning "true".
How to reproduce:
Behaviour
Not set:
Set:
This is maybe a bit difficult, but it would be nice to be able to have inputs that are added/removed based on some input, like a file/folder. For example, in the directory tree example, you'd be able to select which files in the specific folder you want printed to the txt file.
I think this would be possible with a script that creates a script on-the-fly that adds necessary inputs. Any pointers welcome!
After working with the app and coding with the help of @Raudius several scripts let me give some suggestions how to improve the app's UX:
You are welcome to add your own ideas.
When running certain commands from shell I need to pass the full path to the selected file, I made a workaround but it doesn't work with group folders, maybe a full_path_unlocked() function?
In Transifex, text strings are incomplete. Strings are missing which are found in files in the "src" directory.
It would be a great enhancement if the API allowed access to file activity as well.
My aim is to export a file approval protocol based on the approval flow in the file activities.
Hi dears,
I want to access to the comments for a node, is there a possibilty?
best regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.