Skip to content

Use local resources, start using npm #49

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
public_html/php
public_html/php
node_modules
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor
public_html/php
classes
classes
node_modules/
dist/
17 changes: 16 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
FROM node:12 as npm

WORKDIR /installing
COPY ./ /installing
RUN npm ci --only=production

FROM composer@sha256:d374b2e1f715621e9d9929575d6b35b11cf4a6dc237d4a08f2e6d1611f534675 as composer
# composer is pinned at a PHP 7 version

WORKDIR /installing
COPY ./ /installing
RUN composer install --no-dev --no-progress && rm -rf vendor/wbstack/magnustools

## 1. composer install
## 2. move magnus tools resources to a temp fold to select from (some are selected at the very end)
## 3. finally remove magnustools because it contains so much stuff
RUN composer install --no-dev --no-progress \
&& mv vendor/wbstack/magnustools /installing/magnustools \
&& rm -rf vendor/wbstack/magnustools

FROM php:7.2-apache

Expand All @@ -27,5 +38,9 @@ COPY --from=composer /installing /var/www/html/quickstatements
COPY --from=composer /installing/classes /var/www/html/magnustools/classes
COPY --from=composer /installing/public_html/php /var/www/html/magnustools/public_html/php

## TODO make some kind of sane magnus tools js lib to be included in the bundle
COPY --from=composer /installing/magnustools/public_html/resources /var/www/html/quickstatements/public_html/magnustools/resources
COPY --from=npm /installing/node_modules /var/www/html/quickstatements/public_html/resources

ENTRYPOINT ["/bin/bash"]
CMD ["/entrypoint.sh"]
21 changes: 21 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,24 @@ Using addwiki:
https://github.com/addwiki/mediawiki-api

Copy public_html/config.json.template to config.json and modify for your needs

## NPM Dependencies

Currently the external dependencies are managed by npm, they are installed during the building of the Dockerfile by running the following command

```
npm ci --only=production
```

and then moving the installed libraries to the public_html/ folder.

## TODO
### Add some kind of offline version of https://bitbucket.org/magnusmanske/tooltranslate.git

This could potentially be some kind of homebrew thing that looks at the toolinfo.json and pulls the all the translations when the Dockerfile builds and puts these in the `public_html/` folder

```
https://tools-static.wmflabs.org/tooltranslate/data/quickstatements/toolinfo.json
```

This would also require a rewrite of https://tools-static.wmflabs.org/tooltranslate/tt.js
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "quickstatements",
"version": "0.0.1",
"description": "",
"main": "quickstatements.js",
"private": true,
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"leaflet": "1.3.1",
"vue-router": "3.0.1",
"vue": "2.5.13",
"bootstrap": "4.0.0",
"jquery": "3.3.1"
}
}
23 changes: 12 additions & 11 deletions public_html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title tt="toolname"></title>
<link rel="stylesheet" href="https://tools-static.wmflabs.org/cdnjs/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://tools-static.wmflabs.org/magnustools/resources/html/wikimedia.css">
<link rel="stylesheet" href="https://tools-static.wmflabs.org/cdnjs/ajax/libs/leaflet/1.3.1/leaflet.css">
<script src="https://tools-static.wmflabs.org/cdnjs/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://tools-static.wmflabs.org/cdnjs/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
<script src="https://tools-static.wmflabs.org/cdnjs/ajax/libs/vue/2.5.13/vue.min.js"></script>
<script src="https://tools-static.wmflabs.org/cdnjs/ajax/libs/vue-router/3.0.1/vue-router.min.js"></script>
<script src="https://tools-static.wmflabs.org/cdnjs/ajax/libs/leaflet/1.3.1/leaflet.js"></script>
<script src="https://tools-static.wmflabs.org/tooltranslate/tt.js"></script>
<script src="https://tools-static.wmflabs.org/magnustools/resources/js/wikidata.js"></script>
<script src="https://tools-static.wmflabs.org/magnustools/resources/vue/shared.js"></script>
<link rel="stylesheet" href="resources/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="magnustools/resources/html/wikimedia.css">
<link rel="stylesheet" href="resources/leaflet/dist/leaflet.css">
<script src="resources/jquery/dist/jquery.min.js"></script>
<script src="resources/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="resources/vue/dist/vue.min.js"></script>
<script src="resources/vue-router/dist/vue-router.min.js"></script>
<script src="resources/leaflet/dist/leaflet.js"></script>
<script src="magnustools/resources/js/wikidata.js"></script>
<script src="magnustools/resources/vue/shared.js"></script>
<script src="https://tools-static.wmflabs.org/tooltranslate/tt.js"></script><!-- ToolTranslate still exists only on wmflabs.org -->
<script src="quickstatements.js"></script>

<style>
.navthing {
Expand Down