Skip to content

Commit

Permalink
Implement module initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
mcartoixa committed Jan 6, 2018
1 parent 946ae11 commit f1f0530
Show file tree
Hide file tree
Showing 18 changed files with 738 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.sonarlint/
vendor/
tmp/

*.lock
*.log
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: php
php:
- '5.6'

env:
- DLM_PACKAGE_VERSION=1.0.$TRAVIS_BUILD_NUMBER

install:
- php bin/composer.phar install -n

script:
- vendor/bin/phing -f build.xml prepare.version release

deploy:
provider: releases
api_key:
secure: "DPhOBqvcuegjtxaSOaYkeU+9gHoV6ySLvirT1j3qH2fSKWbc8WWIyUiaIxDJavnTH+/EfraPKeySEQR4jCtB4txCLY+nSVYVc0B5p4XlvYK1nkYEnqBWlsEmnKBcApH7UJj7kvxHuO7odGYZteRveUWcUOUhVwXcBNTqAsWKMT8h+lDmOd1DvYPDhQ6ZDo31m9lu0i04u9kJa8XPx508AxcKSx3Zdg9sou42C7sqSBEa+LPEaz5/4WnmHkXvzwU6bwlRlhu+d4u6cfYslxQII2J7IaLWp+N8QaFJ505CtlGl7JYbg7PRTKaqeRcs4mOuShkQidtGf+qbZyn2Uzd63HKbyfNtKJn/68JnqFWMeVpfw9dzalXQQXSlYjoR5HTconcDSUcRoOg4hUJR/jp6eYqD9tpxlUOQvP9DPrtCDR6msuKaxo1dnP8BJ1sBuOcYvj/35R8KZLpaUyaX0EDeGyYrxzdWf/9M2+YzCtl1a+Qx+bDuwXFQujC6Yvjptv+7QFrMB/WKOZ3Zp0T3ChY7Inza1ZatcyVpj2pdsA7z67bJYHxUx0glfj6KAJ2vhV+EWhx9GJRXBFnJ/CSqtM2pEar5oL0t6MGbsha0ZagNxE6cYVU2+z5mRvG/8aBgAxsJr7rlYCzgIMJ2PwqHBZzBUkkqpp13zKJ/rP0aCtAzx1I="
file_glob: true
file: tmp/out/bin/*
skip_cleanup: true
on:
tags: true
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.insertSpaces": true,
"editor.tabSize": 4,
"files.eol": "\r\n",
"files.exclude": {
"**/.git": true,
"**/*.lock": true,
"**/*.log": true,
".sonarlint/": true,
"packages/": true,
"tmp/": true,
"**/vendor/": true
},
"files.trimTrailingWhitespace": true,
"php.validate.enable": true,
"terminal.integrated.shellArgs.windows": [
"/K",
"bin\\SetEnv.bat"
]
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# synology-dlm-ybt
YourBittorrent search module for Synology Download Manager
YourBittorrent search module for Synology Download Manager.

[![Build status](https://travis-ci.org/mcartoixa/synology-dlm-ybt.svg?branch=master)](https://travis-ci.org/mcartoixa/synology-dlm-ybt)
## Installation
- Download [the latest version of the module](https://github.com/mcartoixa/synology-dlm-ybt/releases/latest) and install it in the [BT Search section of Download Station](https://www.synology.com/en-global/knowledgebase/DSM/help/DownloadStation/download_setup#torrent).

## Development
### Build

- Run the following command from this directory: `build.bat`
- Prerequisites:
* PHP 5.6:
+ Make sure the following extensions are activated:
- php_curl
- php_mbstring
- php_openssl
+ Set an environment variable `PHP_HOME` that points to the PHP installation folder (e.g `C:\PROGRA~2\PHP\5.6`).
5 changes: 5 additions & 0 deletions bin/SetEnv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF

ECHO SET PHP_HOME=%PHP_HOME%

SET PATH=%CD%\bin;%PHP_HOME%;%PATH%
3 changes: 3 additions & 0 deletions bin/composer.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

%PHP_HOME%\php.exe "%~dp0composer.phar" %*
Binary file added bin/composer.phar
Binary file not shown.
111 changes: 111 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
@ECHO OFF
::--------------------------------------------------------------------
:: Usage: "build [/clean | /rebuild | /release] [/NoPause] [/?]"
::
:: /clean - Cleans the project
:: /rebuild - Cleans and builds the project (default)
:: /release - Rebuilds the project and creates the packages
::
:: /NoPause - Does not pause after completion
:: /? - Gets the usage for this script
::--------------------------------------------------------------------



COLOR 07

:: Reset ERRORLEVEL
VERIFY OTHER 2>nul
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
IF ERRORLEVEL 1 GOTO ERROR_EXT

SET NO_PAUSE=0
SET PROJECT=build.xml
SET TARGET=rebuild
GOTO ARGS



:: -------------------------------------------------------------------
:: Builds the project
:: -------------------------------------------------------------------
:BUILD

CALL .\bin\composer.bat install -q -n
IF ERRORLEVEL 1 GOTO END_ERROR
ECHO.

CALL .\vendor\bin\phing.bat -f %PROJECT% %TARGET%
IF ERRORLEVEL 1 GOTO END_ERROR
GOTO END



:: -------------------------------------------------------------------
:: Parse command line argument values
:: Note: Currently, last one on the command line wins (ex: /rebuild /clean == /clean)
:: -------------------------------------------------------------------
:ARGS
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (
"C:\Windows\Sysnative\cmd.exe" /C "%0 %*"

IF ERRORLEVEL 1 EXIT /B 1
EXIT /B 0
)
::IF NOT "x%~5"=="x" GOTO ERROR_USAGE

:ARGS_PARSE
IF /I "%~1"=="/clean" SET TARGET=clean& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/rebuild" SET TARGET=rebuild& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/release" SET TARGET=prepare.version release& SHIFT & GOTO ARGS_PARSE
::IF /I "%~1"=="/log" SET VERBOSITY=diagnostic& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/NoPause" SET NO_PAUSE=1& SHIFT & GOTO ARGS_PARSE
IF /I "%~1"=="/?" GOTO ERROR_USAGE
IF "%~1" EQU "" GOTO ARGS_DONE
ECHO Unknown command-line switch: %~1
GOTO ERROR_USAGE

:ARGS_DONE
IF "%DEV_BUILD%"=="True" GOTO SETENV_DEV ELSE GOTO SETENV



:: -------------------------------------------------------------------
:: Set environment variables
:: -------------------------------------------------------------------
:SETENV
CALL bin\SetEnv.bat
ECHO.
GOTO BUILD



:: -------------------------------------------------------------------
:: Errors
:: -------------------------------------------------------------------
:ERROR_EXT
ECHO Could not activate command extensions
GOTO END_ERROR

:ERROR_USAGE
ECHO Usage: "build [/clean | /rebuild | /release] [/NoPause] [/?]"
ECHO.
ECHO /clean - Cleans the project
ECHO /rebuild - Cleans and builds the project (default)
ECHO /release - Rebuilds the project and creates the packages
ECHO.
ECHO /NoPause - Does not pause after completion
ECHO /? - Gets the usage for this script
GOTO END



:: -------------------------------------------------------------------
:: End
:: -------------------------------------------------------------------
:END_ERROR
COLOR 4E

:END
@IF NOT "%NO_PAUSE%"=="1" PAUSE
ENDLOCAL
84 changes: 84 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="synology-dlm-ybt" default="build">
<autoloader />

<property environment="env" />

<property name="bin.dir" value="${project.basedir}/bin" />
<property name="dlm.dir" value="${project.basedir}/dlm" />
<property name="tmp.dir" value="${project.basedir}/tmp" />

<property name="tmp.bin.dir" value="${tmp.dir}/bin" />
<property name="tmp.obj.dir" value="${tmp.dir}/obj" />
<property name="tmp.out.dir" value="${tmp.dir}/out" />
<property name="tmp.test.dir" value="${tmp.dir}/test" />



<target name="prepare.version" depends="prepare.dlm">
<if>
<and>
<isset property="env.DLM_PACKAGE_VERSION" />
<not>
<equals arg1="${env.DLM_PACKAGE_VERSION}" arg2="0.0.0" />
</not>
</and>
<then>
<phing phingfile="build.xml" dir="./dlm" target="prepare.version" inheritAll="true" haltonfailure="true" />
</then>
</if>
</target>

<target name="prepare.dlm">
<composer command="update" composer="${bin.dir}/composer.phar">
<arg value="-q" />
<arg value="-d" />
<arg path="${dlm.dir}" />
<arg value="-n" />
</composer>
</target>



<target name="clean" depends="prepare.clean">
<phing phingfile="build.xml" dir="${dlm.dir}" target="clean" inheritAll="true" haltonfailure="true" />
</target>

<target name="prepare.clean" depends="prepare.dlm">
<delete dir="${tmp.dir}" includeemptydirs="true" quiet="true" failonerror="false" />
</target>



<target name="build" depends="prepare.build">
<phing phingfile="build.xml" dir="${dlm.dir}" target="build" inheritAll="true" haltonfailure="true" />
</target>

<target name="prepare.build" depends="prepare.dlm">
<mkdir dir="${tmp.dir}" />

<composer command="update" composer="${bin.dir}/composer.phar">
<arg value="-q" />
<arg value="-n" />
</composer>
</target>



<target name="test" depends="prepare.build">
<phing phingfile="build.xml" dir="${dlm.dir}" target="test" inheritAll="true" haltonfailure="true" />
</target>



<target name="rebuild" depends="prepare.clean,prepare.build">
<phing phingfile="build.xml" dir="${dlm.dir}" target="rebuild" inheritAll="true" haltonfailure="true" />
</target>



<target name="release" depends="prepare.clean,prepare.build">
<phing phingfile="build.xml" dir="${dlm.dir}" target="release" inheritAll="true" haltonfailure="true" />
</target>
</project>
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "mcartoixa/synology-dlm-ybt",
"description": "YourBittorrent search module for Synology Download Manager",
"type": "project",
"license": "MIT",
"require-dev": {
"phing/phing": "2.*",
"pear/archive_tar": "*"
}
}
10 changes: 10 additions & 0 deletions dlm/INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "mcartoixa_yourbittorrent",
"displayname": "YourBittorrent",
"description": "YourBittorrent search module for Synology Download Manager",
"version": "0.0.0",
"site": "https://yourbittorrent.com/",
"module": "search.php",
"type": "search",
"class": "SynoDLMSearchYourBittorrent"
}
86 changes: 86 additions & 0 deletions dlm/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>

<project name="mcartoixa_yourbittorrent.dlm" default="build">
<autoloader />

<property environment="env" />

<property name="build.bin.dir" value="${tmp.bin.dir}/dlm" />
<property name="build.obj.dir" value="${tmp.obj.dir}/dlm" />
<property name="build.out.dir" value="${tmp.out.dir}/bin" />

<fileset id="src.files" dir=".">
<type type="file" />
<include name="*" />
<exclude name="*.lock" />
<exclude name="build.xml" />
</fileset>



<target name="clean" />
<target name="rebuild" depends="clean,build" />
<target name="release" depends="rebuild,package" />

<target name="prepare.version">
<echo message="Preparing version ${env.DLM_PACKAGE_VERSION}" />
<replaceregexp file="INFO" pattern="(?&lt;=&quot;version&quot;\W)\s+&quot;\d+\.\d+\.\d+&quot;" replace=" &quot;${env.DLM_PACKAGE_VERSION}&quot;" />
</target>



<target name="build" depends="test">
<phplint haltonfailure="true">
<fileset dir=".">
<include name="*.php"/>
</fileset>
</phplint>

<copy todir="${build.bin.dir}">
<fileset refid="src.files" />
</copy>

<composer command="install" composer="${bin.dir}/composer.phar">
<arg value="-q" />
<arg value="-d" />
<arg path="${build.bin.dir}" />
<arg value="-n" />
<arg value="--no-dev" />
</composer>
</target>



<target name="test" depends="test.prepare">
<phpunit printsummary="true" bootstrap="vendor/autoload.php" haltonerror="true" haltonfailure="true">
<formatter type="plain" usefile="false" />
<batchtest>
<fileset dir="./tests">
<include name="**/*Test*.php"/>
</fileset>
</batchtest>
</phpunit>
</target>

<target name="test.prepare">
<composer command="update" composer="${bin.dir}/composer.phar">
<arg value="-q" />
<arg value="-n" />
</composer>
</target>



<target name="package" depends="package.prepare,build">
<tar destfile="${build.out.dir}/${phing.project.name}" compression="gzip">
<fileset dir="${build.bin.dir}">
<include name="**/**" />
<exclude name="composer.*"/>
</fileset>
</tar>
</target>

<target name="package.prepare">
<mkdir dir="${build.out.dir}" />
</target>
</project>
Loading

0 comments on commit f1f0530

Please sign in to comment.