Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernized plugin code-base #132

Open
wants to merge 196 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
37cc1a5
updated composer to make plugin installable via composer. Set namespa…
onyijne Oct 11, 2022
618c933
created the plugin entry script as per WordPress plugin standard
onyijne Oct 11, 2022
61fbe74
added license and header comments requirements to entry script as per…
onyijne Oct 11, 2022
5e93142
changed minimum PHP Version to 5.4 in composer and header requirements
onyijne Oct 11, 2022
0a5bdec
created Tool.php class that will handle html generating and shortcode…
onyijne Oct 11, 2022
d2d1b21
added generateHtml method to Tool class
onyijne Oct 11, 2022
ca1103b
added handleShortcode method to Tool class
onyijne Oct 11, 2022
4a6406b
add run method to Tool class. this will be called from the entry script
onyijne Oct 11, 2022
c75bfc7
created a docker-compose.yml file to enable docker builds
onyijne Oct 11, 2022
f0ff8cb
created a Dockerfile file to enable docker builds
onyijne Oct 11, 2022
7eb2402
created a Dockerfile file to enable docker builds
onyijne Oct 11, 2022
94e8af9
refactored Tool.php class to tot/Plugin.php
onyijne Oct 11, 2022
128984a
removed docker-compose.yml file
onyijne Oct 11, 2022
f6b1c6d
refactored spellings
onyijne Oct 11, 2022
6a49e96
make plugin containrizable
onyijne Oct 11, 2022
dbcc7ab
refactored spellings
onyijne Oct 11, 2022
811ba85
registered shortcode
onyijne Oct 11, 2022
856178c
refactor code to separate plugin logics
onyijne Oct 11, 2022
7f06d85
added abstarct class
onyijne Oct 11, 2022
1955410
added comment on data property
onyijne Oct 11, 2022
0a0a005
implemented ArrayAccess methods on Plugin class
onyijne Oct 11, 2022
30db36a
added action hook for plugin initialization
onyijne Oct 11, 2022
0d523ab
refactored spellings
onyijne Oct 11, 2022
dc4cf32
updated hook init function
onyijne Oct 11, 2022
a99e390
spellings
onyijne Oct 11, 2022
c32bb84
updated termination of transfer logic
onyijne Oct 11, 2022
c67df38
updated assets path and created result file
onyijne Oct 11, 2022
bc43a30
updated result logic
onyijne Oct 11, 2022
1bffee9
updated php version to 7.4 and WordPress version to 5.0
onyijne Oct 11, 2022
6352890
updated ResultPdf to run sode
onyijne Oct 11, 2022
2985464
changed generateHtml method to public
onyijne Oct 11, 2022
ca6dd6d
added docker-compose.dev.yml to enable real time docker testing as fi…
onyijne Oct 11, 2022
5329c36
updated services in docker-compose.dev.yml
onyijne Oct 11, 2022
cc23ca1
cd to plugin directory before runing composer install in Dockerfile
onyijne Oct 11, 2022
83ec4e3
changed composer location in Dockerfile
onyijne Oct 11, 2022
4a27e04
updated composer install in Dockerfile
onyijne Oct 11, 2022
018d8a0
updated ports in docker-compose
onyijne Oct 11, 2022
a541995
updated ports in docker-compose
onyijne Oct 11, 2022
c219dbf
updated Dockerfile comments and made it lite
onyijne Oct 11, 2022
c8df758
added phpmyadmin to docker-compose
onyijne Oct 11, 2022
33fb532
updated container ip in docker-compose
onyijne Oct 11, 2022
f0aa96c
connected to docker mariadb server
onyijne Oct 12, 2022
ed5a435
updated database name
onyijne Oct 12, 2022
8630d41
updated ip
onyijne Oct 12, 2022
3ef5559
updated namespace
onyijne Oct 12, 2022
4e63e6b
updated namespace and ip
onyijne Oct 12, 2022
6b7b513
updated namespace and ip
onyijne Oct 12, 2022
66984b4
updated namespace and ip
onyijne Oct 12, 2022
b574ee8
updated autoload include
onyijne Oct 12, 2022
86c6ca0
updated autoload include
onyijne Oct 12, 2022
9323792
updated namespace
onyijne Oct 12, 2022
58c6f21
deleted composer.lock file
onyijne Oct 12, 2022
0ca7fb0
updated Dockerfile for composer
onyijne Oct 12, 2022
fefa4f8
deleted plugin's old folder
onyijne Oct 13, 2022
22fa47b
updated generateHtml method's comment
onyijne Oct 13, 2022
507051c
updated handleShortcode method's comment
onyijne Oct 13, 2022
4b6ec6c
created assets folder to house plugin assets and moved js folder into it
onyijne Oct 13, 2022
4d93555
updated assets path from src to assets
onyijne Oct 13, 2022
2deaa80
changed __FILE__ to __DIR__ to refernece parent directory
onyijne Oct 13, 2022
f5ff8c9
updated file location
onyijne Oct 13, 2022
b93b521
removed extra-host field from docker-compose.dev.yml
onyijne Oct 14, 2022
3597142
updated network and volumn names in docker-compose.dev.yml and added…
onyijne Oct 14, 2022
bb08122
updated pdf file path
onyijne Oct 14, 2022
19b5c90
removed my.cnf file and its reference since we are not using it
onyijne Oct 14, 2022
f28300f
added composer-fix.sh as entrypoint to ensure dependencies are instal…
onyijne Oct 14, 2022
8173a02
updated pdf result url
onyijne Oct 14, 2022
89da99a
updated pdf result url
onyijne Oct 14, 2022
71e4bac
commented out unused variable Widgets
onyijne Oct 14, 2022
54a13b0
renamed var Answers to const TotAnswers
onyijne Oct 14, 2022
a7c5885
updated widget.js functions to es6 arrow function
onyijne Oct 14, 2022
270ee18
updated widget.js concatenated strings to es6 literals
onyijne Oct 14, 2022
08fbd28
renamed var Notifications to const TotNotifications
onyijne Oct 14, 2022
b4483ce
renamed var Notifications to const TotNotifications
onyijne Oct 14, 2022
61a9ead
updated widget.js functions to es6 arrow function
onyijne Oct 14, 2022
773427f
renamed var Questions to const TotQuestions
onyijne Oct 14, 2022
f16b857
updated questions.js functions to es6 arrow function
onyijne Oct 14, 2022
8668c19
updated all functions to es6 arrow function
onyijne Oct 14, 2022
6659b2c
updated all functions to es6 arrow function
onyijne Oct 14, 2022
832df12
renamed var Values to const TotValues
onyijne Oct 14, 2022
b9bbe36
used double quote
onyijne Oct 14, 2022
c667717
used double quote
onyijne Oct 14, 2022
a5fef0b
renamed var varsToTiles to const totVarsToTiles
onyijne Oct 14, 2022
de52298
updated var to let
onyijne Oct 14, 2022
13cca9b
renamed var Validation to TotValidation
onyijne Oct 14, 2022
d92a77e
updated validation.js concatenated strings to es6 literals
onyijne Oct 14, 2022
dfec407
used double quote
onyijne Oct 14, 2022
cfa828a
renamed var Rules to const TotRules
onyijne Oct 14, 2022
b06e7a6
used double quote
onyijne Oct 14, 2022
65c54da
updated var to let
onyijne Oct 14, 2022
7053bd6
updated var to let
onyijne Oct 14, 2022
edbe53d
used double quote
onyijne Oct 14, 2022
7cb70bc
updated rendering.js concatenated strings to es6 literals
onyijne Oct 14, 2022
8c9e1c3
renamed var Rendering to const TotRendering
onyijne Oct 14, 2022
36247b1
updated questions.js concatenated strings to es6 literals
onyijne Oct 14, 2022
f4417b0
used double quote
onyijne Oct 14, 2022
9688f99
renamed var PDF to const TotPdf
onyijne Oct 14, 2022
b5f43f0
updated pdf.js concatenated strings to es6 literals
onyijne Oct 14, 2022
e028d8f
updated var to let
onyijne Oct 14, 2022
250866b
used double quote
onyijne Oct 14, 2022
dff5a49
renamedconst TotValues to let TotValue to enable reassingment in rese…
onyijne Oct 14, 2022
24f88ca
fixed undefined this by changing it ti ValueStack since it is called …
onyijne Oct 14, 2022
a045b64
updated rendering option
onyijne Oct 14, 2022
1ac9d42
fixed rendering undefined check
onyijne Oct 14, 2022
4a375da
renamed var Navigation to const TotNavigation
onyijne Oct 14, 2022
cb9eb18
fixed let. type to let
onyijne Oct 14, 2022
a2b975e
install evince for test if not installed on machine
onyijne Oct 14, 2022
d5cb207
updated test url
onyijne Oct 14, 2022
f845a5e
created result-pdf.php to act as entry script for result generating s…
onyijne Oct 14, 2022
cbf2081
removed the result initializing code
onyijne Oct 14, 2022
43d3a30
added the result logic
onyijne Oct 14, 2022
0acc8fb
updated result url
onyijne Oct 14, 2022
b2dfd52
refactor pdf result to a function to avoid any possible variable coll…
onyijne Oct 14, 2022
772b6ca
added uninstall.php to remove shortcode upon plugin uninstall
onyijne Oct 14, 2022
a803ba2
added omiited shebang to composer-fix.sh used for development purpose…
onyijne Oct 15, 2022
825461f
updated test result url to reference pdf-result.php in plugin root di…
onyijne Oct 15, 2022
a825d71
replace conditional install position
onyijne Oct 15, 2022
e6d31b7
changed let to const where variables are not re-assined within their …
onyijne Oct 15, 2022
406a0b3
changed ommited var to const where not reassigned wthin scope
onyijne Oct 15, 2022
4cb53a2
fixed TotNavigation.disableNext is not a function
onyijne Oct 15, 2022
82af53d
added plugin_path property and assigned to plugin_dir_path(__DIR__) i…
onyijne Oct 15, 2022
3250666
aded ommited assets folder in result referenece
onyijne Oct 15, 2022
8053032
Removed the leading slash in assets reference
onyijne Oct 16, 2022
66454e5
renamed ommited methods to camelCase
onyijne Oct 17, 2022
b277d70
refactored add_action parameter from string to araay
onyijne Oct 17, 2022
7b9624d
commented out unused properties for runtime speeed
onyijne Oct 17, 2022
19d1415
fixed typo
onyijne Oct 17, 2022
adafc8f
updated version to 2 in header requirements
onyijne Oct 17, 2022
ff9de35
converted ommited var to const and let when re-asigned within defined…
onyijne Oct 18, 2022
85bb3ed
added conditional chaining in TotQuestions.getAnswer
onyijne Oct 19, 2022
246f5b2
formatted with prettier
onyijne Oct 19, 2022
4d94920
replaced label to value to display
onyijne Oct 19, 2022
a4c9810
updated conditional statement
onyijne Oct 19, 2022
b369a79
quote name attribute
onyijne Oct 19, 2022
ec47d66
retructured TotRendering
onyijne Oct 19, 2022
847fa03
fixed radio input name
onyijne Oct 19, 2022
5574b7b
updated click event
onyijne Oct 19, 2022
fe19cc4
updated event registration
onyijne Oct 19, 2022
844caef
rename selector
onyijne Oct 19, 2022
f247ea4
rename selector
onyijne Oct 19, 2022
38c1765
updated label selector query
onyijne Oct 19, 2022
78df19b
updated ommited closing quotey
onyijne Oct 19, 2022
6a23cbd
created npm project as per new RFC
onyijne Oct 19, 2022
3eaf1a6
added node_modules to git ignore
onyijne Oct 19, 2022
40f48c2
installed dev dependencies
onyijne Oct 19, 2022
aca3d35
installed dependencies
onyijne Oct 19, 2022
850af00
added prettier plugin to eslint
onyijne Oct 19, 2022
44ad5ad
added prettier rules
onyijne Oct 19, 2022
4c650af
updated dev dependencies
onyijne Oct 19, 2022
bdd4dd0
updated dev dependencies
onyijne Oct 19, 2022
170d632
updated dev dependencies
onyijne Oct 19, 2022
99fc431
added babel config file
onyijne Oct 19, 2022
270a27e
updated eslint config
onyijne Oct 19, 2022
828ee13
formatted with prettier
onyijne Oct 19, 2022
4352c40
removed jquery from dependencies to use the one from WordPress
onyijne Oct 19, 2022
5d585ff
updated build command to compile assets folder to dist/tot.js
onyijne Oct 19, 2022
98e3f09
updated assets dir to dist
onyijne Oct 19, 2022
3603d74
updated assets bulding to dist dir
onyijne Oct 19, 2022
55c735f
updated assets dir to dist
onyijne Oct 19, 2022
020dc48
build js assets
onyijne Oct 19, 2022
c99665e
updated assets dir
onyijne Oct 19, 2022
876446d
build js assets
onyijne Oct 19, 2022
e680824
fixed undefined variable
onyijne Oct 19, 2022
4f24c96
build js assets
onyijne Oct 19, 2022
e46cdec
created dev directory for development and deploying as per reviewed c…
onyijne Oct 21, 2022
b97814a
moved docker-composer.dev.yml file into newly created dev folder
onyijne Oct 21, 2022
4f71530
renamed docker-composer.dev.yml file to docker-compose.yml
onyijne Oct 21, 2022
abd152e
changed docker compose version to 3.2
onyijne Oct 21, 2022
41febab
moved compposer-fix.sh to dev folder
onyijne Oct 21, 2022
0f0568b
updated docker-compose.yml to reflect version change
onyijne Oct 21, 2022
d37bdff
changed server maraidb to db
onyijne Oct 21, 2022
c0b2f7d
updated Dockerfile copy path
onyijne Oct 21, 2022
88b51b8
updated service.wp volumn path
onyijne Oct 21, 2022
b6cd5c8
updated Dockerfile copy path
onyijne Oct 21, 2022
f7e6a8f
moved Dockerfile back to root directory
onyijne Oct 21, 2022
efd4e83
allow composer to install with root user
onyijne Oct 21, 2022
c91772a
updated build context path
onyijne Oct 21, 2022
d8ba2dc
removed composer-fix.sh since its no longer in use
onyijne Oct 21, 2022
3546d5b
exclude dev directory from container
onyijne Nov 7, 2022
ceb8bdb
locked php dependencies
onyijne Nov 7, 2022
d7d5946
added dbsetup service to automate db setup
onyijne Nov 7, 2022
aed2a88
linked db to dbsetup
onyijne Nov 7, 2022
e62f2fc
added hostname to db service
onyijne Nov 7, 2022
4dee431
removed phpmyadmin service
onyijne Nov 7, 2022
8f064af
restructure dbsetup service
onyijne Nov 7, 2022
4667345
added my.cnf to fix access denied issue for root
onyijne Nov 7, 2022
0d01b48
added my.cnf to volume in dbsetup
onyijne Nov 7, 2022
808ce50
removed volume in dbsetup and moved it to db service
onyijne Nov 7, 2022
54556d2
removed login details in setup
onyijne Nov 7, 2022
1d06833
used same volumes for both db and dbsetup services to fix access deni…
onyijne Nov 7, 2022
8ad7a7f
changed quotes to backticks in sql
onyijne Nov 7, 2022
a0a220a
updated grant option to localhost
onyijne Nov 7, 2022
44af219
updated sql to fix syntax error
onyijne Nov 7, 2022
01c5175
add newline at end of file
TimidRobot Apr 15, 2024
55a1020
sort and add newline at end of file
TimidRobot Apr 15, 2024
34d5e35
clean-up whitespace and add newline at end of file
TimidRobot Apr 15, 2024
c42abb4
add newline at end of files
TimidRobot Apr 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# exclude dev directory from container
dev
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"root": true,
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"babelOptions": {
"babelrc": false,
"configFile": false,
"presets": ["@babel/preset-env"]
}
},
"extends": ["plugin:prettier/recommended"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*~
.\#*
node_modules
templates_c
vendor
templates_c
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"singleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"semi": true,
"useTabs": false,
"parser": "babel",
"bracketSameLine": false
}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# syntax=docker/dockerfile:experimental

# use wordpress image as the base image
FROM wordpress

# install unzip for composer
RUN apt-get update && apt-get install apt-utils zip unzip -y

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# copy all the files in this folder to plugins directory
COPY . /var/www/html/wp-content/plugins/termination-of-transfer

# allow root user so composer can install dependencies without having root user error
RUN export COMPOSER_ALLOW_SUPERUSER=1;

# cd to plugin directory AND install plugin dependencies
RUN cd /var/www/html/wp-content/plugins/termination-of-transfer && composer install
148 changes: 148 additions & 0 deletions assets/js/pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
Termination of Transfer - tool to help in returning authors rights.
Copyright (C) 2016 Creative Commons Corporation.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

////////////////////////////////////////////////////////////////////////////////
// PDF Generation
// (browser-side data preparation and call to server)
////////////////////////////////////////////////////////////////////////////////

const TotPdf = {};

TotPdf.url = `${jQuery("script[src*='/termination-of-transfer/dist/js/pdf.js']")
.attr("src")
.replace(/dist\/js\/pdf\.js.*$/, "")}pdf-result.php`;

TotPdf.appendProperty = (details, key, value) => {
const mapping = { key: key, value: value };
details.push(mapping);
};

TotPdf.append203Windows = (details) => {
let notice = "";
let termination = "";

if (TotValues.notice_begin != undefined) {
notice += `${TotValues.notice_begin}-${TotValues.notice_end}`;
termination += `${TotValues.term_begin}-${TotValues.term_end}`;
}

if (TotValues.p_term_begin != undefined) {
if (notice != "") {
notice += " or ";
termination += " or ";
}
notice += `${TotValues.p_notice_begin}-${TotValues.p_notice_end}`;
termination += `${TotValues.p_term_begin}-${TotValues.p_term_end}`;
}

TotPdf.appendProperty(
details,
'&sect; 203 <a href="https://rightsback.org/glossary/#notice_window" target="_blank">notice window</a>',
notice,
);
TotPdf.appendProperty(
details,
'&sect; 203 <a href="https://rightsback.org/glossary/#termination_window" target="_blank">termination window</a>',
termination,
);
};

TotPdf.append304Windows = (details) => {
TotPdf.appendProperty(
details,
'&sect; 304(c) <a href="https://rightsback.org/glossary/#notice_window" target="_blank">notice window</a> begins',
TotValues.notice_begin,
);
TotPdf.appendProperty(
details,
'&sect; 304(c) <a href="https://rightsback.org/glossary/#notice_window" target="_blank">notice window</a> ends',
TotValues.notice_end,
);
TotPdf.appendProperty(
details,
'&sect; 304(c) <a href="https://rightsback.org/glossary/#termination_window" target="_blank">termination window</a> begins',
TotValues.term_begin,
);
TotPdf.appendProperty(
details,
'&sect; 304(c) <a href="https://rightsback.org/glossary/#termination_window" target="_blank">termination window</a> ends',
TotValues.term_end,
);
if (TotValues.d_notice_begin != undefined) {
TotPdf.appendProperty(
details,
'&sect; 304(d) <a href="https://rightsback.org/glossary/#notice_window" target="_blank">notice window</a> begins',
TotValues.d_notice_begin,
);
TotPdf.appendProperty(
details,
'&sect; 304(d) <a href="https://rightsback.org/glossary/#notice_window" target="_blank">notice window</a> ends',
TotValues.d_notice_end,
);
TotPdf.appendProperty(
details,
'&sect; 304(d) <a href="https://rightsback.org/glossary/#termination_window" target="_blank">termination window</a> begins',
TotValues.d_term_begin,
);
TotPdf.appendProperty(
details,
'&sect; 304(d) <a href="https://rightsback.org/glossary/#termination_window" target="_blank">termination window</a> ends',
TotValues.d_term_end,
);
}
};

TotPdf.appendWindows = (details) => {
if (TotRules.is203()) {
TotPdf.append203Windows(details);
} else if (TotRules.is304()) {
TotPdf.append304Windows(details);
}
};

TotPdf.details = () => {
let details = [];
Object.getOwnPropertyNames(totVarsToTitles).forEach((key) => {
if (TotValues[key] != undefined && TotValues[key] != "") {
TotPdf.appendProperty(details, totVarsToTitles[key], TotValues[key]);
}
});
TotPdf.appendWindows(details);
return details;
};

TotPdf.request = () => {
const data = {
report_timestamp: TotValues.current_date.getTime() / 1000,
flags: TotValues.flags.sort(), // Sorts inline & returns, so OK here
conclusion: TotValues.conclusion,
details: TotPdf.details(),
};
const totform = document.createElement("FORM");
totform.setAttribute("action", TotPdf.url);
totform.setAttribute("method", "post");
totform.setAttribute("enctype", "multipart/form-data");
totform.setAttribute("target", "_blank");
const data_field = document.createElement("INPUT");
data_field.setAttribute("type", "hidden");
data_field.setAttribute("name", "data");
data_field.setAttribute("value", JSON.stringify(data));
totform.appendChild(data_field);
jQuery("body").append(totform);
totform.submit();
};
Loading