From d6406d4d65bee9ba392d6010b2251509421ae837 Mon Sep 17 00:00:00 2001 From: ileyd Date: Mon, 27 Jun 2016 12:05:46 +1000 Subject: Improved MySQL to SQLite migration instructions (#38) The initial paragraph explaining why you may prefer to use SQLite was made more brief, and rephrased to sound more neutral (note that it already was neutral). The clarifying section prior to the actual migration instructions was rewritten to better convey that the changes are non-destructive, and that they do not affect the user's main site until the final command (whose purpose is made clear), after verifying there are no issues. The instructions themselves have been modified to clarify where some commands are run from, their purpose, and also made more brief (the section itself is very slightly longer, but something happened to or I forgot to commit an important paragraph that was initially there). --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0220a53..2b06d60 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Node, or NPM. So we'll just assume you already have them all running well. Assuming you already have Node and NPM working, compilation is easy. Use the following shell code: ```bash -git clone --recursive https://github.com/pomf/pomf +git clone https://github.com/pomf/pomf cd pomf/ make make install @@ -103,11 +103,17 @@ Remember to enable `deflate_module` and `filter_module` modules in your Apache configuration file. ### Migrating from MySQL to SQLite + , +Compared to SQLite, MySQL is relatively complicated to administer, brings in many unneeded dependencies, and consumes more resources. Additonally, as a network service, poorly configured installations have the potential +to pose a security risk. -For older versions of Pomf you may want to migrate to SQLite. Fortunately, it is incredibly simple to migrate your database. This may be done on a live server, and should require zero downtime. +For these reasons, you may wish to use SQLite rather than MySQL. -_If doing this on a live server, you way wish to work in a subdirectory (or vhost, or equivelant), so that any complications or mistakes do not affect your main site. -If you choose not to do so, know that mistakes in the changes outlined below, will only temporarily impact **uploading**, causing **Server error** to be displayed. None of these steps are destructive, and are easily reverted._ +Fortunately, it is incredibly simple to migrate your database. This may be done on a live server, if you desire, and requires zero downtime. + +The process described below involves running these commands on a live server. Nothing done here affects your main site, until running the very last command, which is done after verifying there are no issues. + +No changes described here are destructive, and are easily reverted. They only have the potential to cause uploading to fail gracefully, and will not affect downloading. Run the following commands as root, to dump your database, and make a SQLite database with the contents. ```bash @@ -118,14 +124,15 @@ rm /tmp/m2s chown -R nginx:nginx /var/db/pomf #replace user as appropriate chmod 0750 /var/db/pomf && chmod 0640 /var/db/pomf/sq3 ``` -Edit the file `php/includes/settings.inc.php`, in the subdirectory you just made, making the changes outlined below. +Edit the file `php/includes/settings.inc.php`, in your **source directory**, making the changes outlined below. Note, changing the second two lines is optional, as they are simply ignored when using SQLite. ```php define('POMF_DB_CONN', '[stuff]'); ---> define('POMF_DB_CONN', 'sqlite:/var/db/pomf/pomf.sq3');` define('POMF_DB_USER', '[stuff]'); ---> define('POMF_DB_USER', null); define('POMF_DB_PASS', '[stuff]'); ---> define('POMF_DB_PASS', null); ``` +Then, run `make DESTDIR=/path/to/main_site/testing_dir` (note the *testing_dir* component) to rebuild the website, and copy it into place, in a new testing subdirectory. -Then, run `make` to rebuild the website pages, and copy the new `settings.inc.php` file into place. +Now, navigate to this subdirectory in your web browser, e.g. https://try.pantsu.cat/testing_dir, and verify that uploading works fine. If so, excellent! You may rerun `make DESTDIR=/path/to/main_site` to update your main site. All done! You may disable or uninstall MySQL if you wish. -- cgit v1.2.3 From 186b9bf0aed3638845544c1dad9f54297cc23413 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 27 Jun 2016 16:09:19 -0500 Subject: Fix cloning instructions (again..) caused by commit 7ea276bbdf881905c1e2ad42ea0501de623da223 in PR #38 author being ileyd --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b06d60..0b7d9a3 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Node, or NPM. So we'll just assume you already have them all running well. Assuming you already have Node and NPM working, compilation is easy. Use the following shell code: ```bash -git clone https://github.com/pomf/pomf +git clone --recursive https://github.com/pomf/pomf cd pomf/ make make install -- cgit v1.2.3 From cfd529b532680fbd15703d601e074d4381a30b93 Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 03:22:05 +1000 Subject: Added submodule support; added moe support Now allows users to pass MODULES="..." on the command line to select which modules they would like build. Fatal error is caused if a specified submodule cannot be fount. Defaults to only php Also adds copy-moe target --- Makefile | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 96b3118..260873b 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +MAKE="make" INSTALL="install" TAR="tar" GREP="grep" @@ -6,9 +7,11 @@ NPM="npm" DESTDIR="./dist" PKG_VERSION := $( $(GREP) -Po '(?<="version": ")[^"]*' ) TMPDIR := $(shell mktemp -d) +# default modules +MODULES="php" -all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img copy-php - +all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules + swig: $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html @@ -20,7 +23,13 @@ htmlmin: $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html installdirs: - mkdir -p $(DESTDIR)/ $(DESTDIR)/img $(DESTDIR)/classes $(DESTDIR)/includes + mkdir -p $(DESTDIR)/ $(DESTDIR)/img +ifneq (,$(findstring php,$(MODULES))) + mkdir -p $(DESTDIR)/classes $(DESTDIR)/includes +endif +ifneq (,$(findstring moe,$(MODULES))) + mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates} +endif min-css: $(NODE) ./node_modules/.bin/cleancss --s0 ./static/css/pomf.css > $(CURDIR)/build/pomf.min.css @@ -36,7 +45,18 @@ copy-img: cp -vT ./static/img/favicon.ico $(CURDIR)/build/favicon.ico copy-php: +ifneq ($(wildcard $(CURDIR)/php/.),) cp -rv ./php/* $(CURDIR)/build/ +else + $(error The php submodule was not found) +endif + +copy-moe: +ifneq ($(wildcard $(CURDIR)/moe/.),) + cp -rv $(CURDIR)/moe $(CURDIR)/build/moe +else + $(error The moe submodule was not found) +endif install: installdirs cp -rv $(CURDIR)/build/* $(DESTDIR)/ @@ -59,4 +79,19 @@ npm_dependencies: $(NPM) install builddirs: - mkdir -p $(CURDIR)/build $(CURDIR)/build/img $(CURDIR)/build/classes $(CURDIR)/build/includes + mkdir -p $(CURDIR)/build $(CURDIR)/build/img +ifneq (,$(findstring php,$(MODULES))) + mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes +endif +ifneq (,$(findstring moe,$(MODULES))) + mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates} +endif + +submodules: + $(info The following modules will be enabled: $(MODULES)) +ifneq (,$(findstring php,$(MODULES))) + $(MAKE) copy-php +endif +ifneq (,$(findstring moe,$(MODULES))) + $(MAKE) copy-moe +endif -- cgit v1.2.3 From e868e78c56525941a62d43d522936f215be4ece2 Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 03:24:40 +1000 Subject: Replaced few remaining ./ with $(CURDIR) for consistency and correctness --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 260873b..1d4d553 100644 --- a/Makefile +++ b/Makefile @@ -32,21 +32,21 @@ ifneq (,$(findstring moe,$(MODULES))) endif min-css: - $(NODE) ./node_modules/.bin/cleancss --s0 ./static/css/pomf.css > $(CURDIR)/build/pomf.min.css + $(NODE) $(CURDIR)/node_modules/.bin/cleancss --s0 $(CURDIR)/static/css/pomf.css > $(CURDIR)/build/pomf.min.css min-js: echo "// @source https://github.com/pomf/pomf/tree/master/static/js" > $(CURDIR)/build/pomf.min.js echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/pomf.min.js - $(NODE) ./node_modules/.bin/uglifyjs --screw-ie8 ./static/js/app.js >> $(CURDIR)/build/pomf.min.js + $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs --screw-ie8 ./static/js/app.js >> $(CURDIR)/build/pomf.min.js echo "// @license-end" >> $(CURDIR)/build/pomf.min.js copy-img: - cp -v ./static/img/*.png $(CURDIR)/build/img/ - cp -vT ./static/img/favicon.ico $(CURDIR)/build/favicon.ico + cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/ + cp -vT $(CURDIR)/static/img/favicon.ico $(CURDIR)/build/favicon.ico copy-php: ifneq ($(wildcard $(CURDIR)/php/.),) - cp -rv ./php/* $(CURDIR)/build/ + cp -rv $(CURDIR)/php/* $(CURDIR)/build/ else $(error The php submodule was not found) endif -- cgit v1.2.3 From 4e16303887a65cf010983afa784036549362d254 Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 03:38:08 +1000 Subject: Explains how to compile submodules --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b7d9a3..6204981 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,27 @@ Node, or NPM. So we'll just assume you already have them all running well. ### Compiling -Assuming you already have Node and NPM working, compilation is easy. Use the -following shell code: +First you must get a copy of the pomf code. To do so, clone this git repo. +If you have no desire for any submodules, which includes the PHP backend, simply run +```bash +git clone https://github.com/pomf/pomf +``` +else, run ```bash git clone --recursive https://github.com/pomf/pomf +``` +to automatically fetch all of the submodules as well + +Assuming you already have Node and NPM working, compilation is easy. If you would like any additional submodules, or to exclude the default PHP submodule, use the `MODULES="..."` variable. + +Run the following commands to do so. +```bash cd pomf/ make +# alternatively +make MODULES="" # compile no submodules; exclude the default php backend module +make MODULES="php moe" # compile the php and moe submodules +# make install ``` OR -- cgit v1.2.3 From b1166c088d6d191c064b5369c160bf58346bf88f Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 07:13:05 +1000 Subject: Implemented clipboard support --- static/js/app.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/static/js/app.js b/static/js/app.js index e9e755a..dbf8176 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -81,6 +81,26 @@ document.addEventListener('DOMContentLoaded', function () { link.textContent = response.files[0].url.replace(/.*?:\/\//g, ''); link.href = response.files[0].url; url.appendChild(link); + var copy = document.createElement('button'); + copy.className = 'upload-clipboard-btn'; + var glyph = document.createElement('span'); + glyph.className = 'glyphicon glyphicon-copy'; + copy.appendChild(glyph); + url.appendChild(copy); + copy.addEventListener("click", function(event) { + /*why create element? text needs to be on screen to be selected + and thus copied. only text we have on screen is the link without + the http[s]:// part. so this creates an element with the full link + for a moment and then deletes. */ + var element = document.createElement('a'); + element.textContent = response.files[0].url; + link.appendChild(element); + var range = document.createRange(); + range.selectNode(element); + window.getSelection().addRange(range); + document.execCommand("copy"); + link.removeChild(element); + }); } else { bar.innerHTML = 'Error: ' + response.description; } @@ -172,4 +192,6 @@ document.addEventListener('DOMContentLoaded', function () { uploadButton.addEventListener('click', selectFiles.bind(this, uploadInput)); uploadButton.addEventListener('drop', handleDragDrop.bind(this, state, uploadButton), false); document.getElementById('upload-form').classList.add('js'); + + }); -- cgit v1.2.3 From 9c084fc6a22352fd9be0488a77d24ad72f8797cd Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 07:48:37 +1000 Subject: Added copy icon --- static/img/glyphicons-512-copy.png | Bin 0 -> 1356 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/img/glyphicons-512-copy.png diff --git a/static/img/glyphicons-512-copy.png b/static/img/glyphicons-512-copy.png new file mode 100644 index 0000000..4e293dc Binary files /dev/null and b/static/img/glyphicons-512-copy.png differ -- cgit v1.2.3 From 0a546f1082755fdd39c984542c2e4e63874d30fd Mon Sep 17 00:00:00 2001 From: ileyd Date: Wed, 29 Jun 2016 07:56:16 +1000 Subject: Changed glyph to png format --- static/js/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index dbf8176..44c8453 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -83,8 +83,9 @@ document.addEventListener('DOMContentLoaded', function () { url.appendChild(link); var copy = document.createElement('button'); copy.className = 'upload-clipboard-btn'; - var glyph = document.createElement('span'); - glyph.className = 'glyphicon glyphicon-copy'; + var glyph = document.createElement('img'); + glyph.src = 'img/glyphicons-512-copy.png'; + glyph.style = 'height:16px'; copy.appendChild(glyph); url.appendChild(copy); copy.addEventListener("click", function(event) { -- cgit v1.2.3 From 45b5dcc6f46c184863548a103e3a1d19de68b927 Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 28 Jun 2016 20:43:50 -0500 Subject: Switch copy button styling code to CSS file --- static/css/pomf.css | 3 +++ static/js/app.js | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/static/css/pomf.css b/static/css/pomf.css index 9bc5852..ae4e75e 100644 --- a/static/css/pomf.css +++ b/static/css/pomf.css @@ -231,6 +231,9 @@ nav > ul > li:last-child:after { .error#upload-filelist { color: #891A18; } +button.upload-clipboard-btn { + height: 16px; +} .error#upload-filelist .progress-percent { color: #B94A48; } diff --git a/static/js/app.js b/static/js/app.js index 44c8453..27a9353 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -85,7 +85,6 @@ document.addEventListener('DOMContentLoaded', function () { copy.className = 'upload-clipboard-btn'; var glyph = document.createElement('img'); glyph.src = 'img/glyphicons-512-copy.png'; - glyph.style = 'height:16px'; copy.appendChild(glyph); url.appendChild(copy); copy.addEventListener("click", function(event) { -- cgit v1.2.3 From 2e2708c050e7fd3de7fe2008c6ddf5e0d03454fd Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 28 Jun 2016 20:57:26 -0500 Subject: Reword cloning steps Users that skim thru the readme will just copy paste the first commands they see without reading, they shouldn't be hosted a clone, but should still be catered to in some case. This is just simply flipping the commands around. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6204981..81252d7 100644 --- a/README.md +++ b/README.md @@ -40,15 +40,15 @@ Node, or NPM. So we'll just assume you already have them all running well. ### Compiling First you must get a copy of the pomf code. To do so, clone this git repo. -If you have no desire for any submodules, which includes the PHP backend, simply run +You will need to recursively clone the repo to get the required PHP submodule, +and the optional user panel submodule. ```bash -git clone https://github.com/pomf/pomf +git clone --recursive https://github.com/pomf/pomf ``` -else, run +If you don't want either of the submodules run the following command, ```bash -git clone --recursive https://github.com/pomf/pomf +git clone https://github.com/pomf/pomf ``` -to automatically fetch all of the submodules as well Assuming you already have Node and NPM working, compilation is easy. If you would like any additional submodules, or to exclude the default PHP submodule, use the `MODULES="..."` variable. -- cgit v1.2.3