惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - AuOK?

深夜发文,惨痛教训,在redis集群中,不能使用 multi docker-compose 记录一个让人抓狂的错误 SVN 同一个仓库下,不同目录的自动更新方法 写点正则表达式的 MySQL 事务嵌套的方法 go mod PHP笔记 NGINXConfig windows 下修改文件属性值 记录一下搞nextcloud的辛酸事吧 nextcloud环境搭建及部署 docker容器内访问宿主机,访问不通 错误:Host is unreachable 记录一下SQL的行行比较 记录一次nginx平滑升级 letsencrypt免费SSL证书自动续期 守护进程因echo挂掉的原因,以及重定向标准输入、标准输出和标准错误 openresty lua-nginx-module模块中文文档 记录一下,php正则获取字符串子串技巧 nginx localhost的坑
nextcloud 应用开发
AuOK? · 2021-12-16 · via 博客园 - AuOK?

nextcloud app文件夹目录结构

+---appinfo
+---css
+---js
+---l10n
+---lib
|   +---AppInfo (必须)
|   +---Command
|   +---Controller  (必须)
|   +---Cron
|   +---Db
|   +---Exceptions
|   +---Listeners
|   +---Migration
|   +---Model
|   +---Plugins
|   +---Service
|   +---Storage
|   \---Tools
|       +---Db
|       +---Exceptions
|       +---Traits
+---screenshots
+---vendor

目录结构解析

* appinfo
    * info.xml 信息说明文件
        ```
        <?xml version="1.0"?>
        <info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
            <id>ai_test</id> // id
            <name>AI测试</name> // 名称
            <summary>对接AI测试</summary> // 摘要
            <description>对接AI测试</description> //  描述
            <version>1.0</version> //  版本
            <licence>agpl</licence> //  开源许可
            <author>Eason</author> // 作者
            <namespace>AiTest</namespace> //  代码命名空间
            <types> //  类型
                <filesystem/>
            </types>
            <documentation> //  文档地址
                <admin>https://github.com/nextcloud/files_lock/blob/master/README.md</admin>
            </documentation>
            <category>tools</category> //  分类
            <category>files</category> //  分类
            <website>https://github.com/nextcloud/files_lock</website> // web站点
            <bugs>https://github.com/nextcloud/files_lock/issues</bugs> // bug提交地址
            <repository>https://github.com/nextcloud/files_lock.git</repository> //  代码仓库
            <screenshot>https://raw.githubusercontent.com/nextcloud/files_lock/master/screenshots/0.7.0.png</screenshot> //  预览图
            <dependencies> 
                <nextcloud min-version="21" max-version="23"/> //  兼容nc的版本
            </dependencies>
        </info>
        ```
    * routes.php 路由文件
        ```
     declare(strict_types=1); return [ 'routes' => [ ['name' => 'AiTest#doRun', 'url' => '/{ownerId}/{fileId}', 'verb' => 'PUT'], ] ]; ``` * css 样式文件 * js javascript脚本 * main.js ``` /** AI测试 **/ (function() { _.extend(OC.Files.Client, { PROPERTY_AI_TEST: '{' + OC.Files.Client.NS_NEXTCLOUD + '}test', }); var AIPlugin = { /** 文件列表渲染时 **/ attach: function(fileList) { var self = this; /** 增加 webdav属性 **/ var oldGetWebdavProperties = fileList._getWebdavProperties; fileList._getWebdavProperties = function() { var props = oldGetWebdavProperties.apply(this, arguments); props.push(OC.Files.Client.PROPERTY_AI_TEST); return props }; /** 注册右边三个点中的菜单选择 **/ fileList.fileActions.registerAction({ name: 'test', displayName: function(context) { if (context && context.$file) { return "AI测试" } return ''; }, mime: 'all', order: -999, iconClass: 'icon-details', permissions: OC.PERMISSION_UPDATE, actionHandler: function (filename,context) { var fileId = context.$file.data("id"); var fileOwnerId = typeof context.$file.data("shareOwnerId") == 'undefined' ? OC.getCurrentUser().uid : context.$file.data("shareOwnerId"); $.ajax({ method: 'PUT', url: OC.generateUrl('/apps/ai_test/' + fileOwnerId + '/' + fileId) }).done(function(res) { console.log(res); }).fail(function(res) { OCP.Toast.warning(res.responseJSON.message) }); } }) }, }; /** 向全局的插件对象注册该插件 **/ OC.Plugins.register('OCA.Files.FileList', AIPlugin) })(); ``` * l10n 语言文件 * lib * AppInfo * Application.php ```
       declare(strict_types=1); namespace OCA\AiTest\AppInfo; use OCA\DAV\Connector\Sabre\Node as SabreNode; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\AiTest\Listeners\LoadAdditionalScripts; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\IServerContainer; use OCP\SabrePluginEvent; use Sabre\DAV\INode; use Sabre\DAV\PropFind; use Throwable; use Closure class Application extends App implements IBootstrap { const APP_ID = 'ai_test'; //向文件 webdav中添加属性的固定格式:{http://nextcloud.org/ns} = nc 在系统中定义好了的 const AI_TEST = '{http://nextcloud.org/ns}test'; /** * @param array $params */ public function __construct(array $params = array()) { parent::__construct(self::APP_ID, $params); } /** * @param IRegistrationContext $context * 注册事件监听 * event OCA\Files\Event\LoadAdditionalScriptsEvent::class 访问 /apps/files*路由 会触发 * handle 事件处理 在此处 将app的css、js等静态文件加载进去 */ public function register(IRegistrationContext $context): void { $context->registerEventListener( LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class ); } /** * @param IBootContext $context * 在服务启动后,会触发方法 * @throws Throwable */ public function boot(IBootContext $context): void { $context->injectFn(Closure::fromCallable([$this, 'registerHooks'])); } /** * @param IServerContainer $container 服务器容器,可以通过类获取相应的对象 */ public function registerHooks(IServerContainer $container) { $eventDispatcher = \OC::$server->getEventDispatcher(); $eventDispatcher->addListener( 'OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $e) { $server = $e->getServer(); //注册文件的webdav属性 $server->on('propFind', function(PropFind $propFind, INode $node){ if (!$node instanceof SabreNode) { return; } $nodeId = $node->getId(); //注册webdav属性的处理方法 $propFind->handle( Application::AI_TEST, function () use ($nodeId) { return $nodeId; } ); }); } ); } } ``` * Command cli命令 * Controller 控制器 * Cron 后台任务 * Db * Exceptions 异常处理 * Listeners 事件处理 * Migration 数据迁移 * Model * Plugins * Service * Storage * Tools * screenshots 预览图 * vendor 第三方库

未完待续...