diff --git a/.gitignore b/.gitignore index d618f07..df0f8af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.iml .DS_Store/ .idea/ -out/ \ No newline at end of file +out/ +node_modules/ diff --git a/mockups/AddEditPost.png b/mockups/AddEditPost.png new file mode 100644 index 0000000..3ac4c2b Binary files /dev/null and b/mockups/AddEditPost.png differ diff --git a/mockups/DeskAuth.png b/mockups/DeskAuth.png new file mode 100644 index 0000000..254bd45 Binary files /dev/null and b/mockups/DeskAuth.png differ diff --git a/mockups/DonwloadAndDown.png b/mockups/DonwloadAndDown.png new file mode 100644 index 0000000..1d547ea Binary files /dev/null and b/mockups/DonwloadAndDown.png differ diff --git a/mockups/Errorauthorization.png b/mockups/Errorauthorization.png new file mode 100644 index 0000000..679d44e Binary files /dev/null and b/mockups/Errorauthorization.png differ diff --git a/mockups/Main.png b/mockups/Main.png new file mode 100644 index 0000000..7a88df2 Binary files /dev/null and b/mockups/Main.png differ diff --git a/mockups/Unauth.png b/mockups/Unauth.png new file mode 100644 index 0000000..a7aa031 Binary files /dev/null and b/mockups/Unauth.png differ diff --git a/mockups/authorization.png b/mockups/authorization.png new file mode 100644 index 0000000..4de274d Binary files /dev/null and b/mockups/authorization.png differ diff --git a/mockups/deleting.png b/mockups/deleting.png new file mode 100644 index 0000000..ed7f490 Binary files /dev/null and b/mockups/deleting.png differ diff --git a/mockups/error.png b/mockups/error.png new file mode 100644 index 0000000..f32c1e4 Binary files /dev/null and b/mockups/error.png differ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..add9e4c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,426 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "2.1.18", + "negotiator": "0.6.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "1.6.16" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": "2.1.2" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + } + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "requires": { + "accepts": "1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.2", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.3", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "1.4.0", + "type-is": "1.6.16", + "utils-merge": "1.0.1", + "vary": "1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.3", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.16" + } + } + } + }, + "express-package-json": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/express-package-json/-/express-package-json-1.0.2.tgz", + "integrity": "sha1-26aiwgee55z6mhxWgJexVwZLmUw=" + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.4.0", + "unpipe": "1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": "1.4.0" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", + "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + }, + "mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "requires": { + "mime-db": "1.33.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", + "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.6.0" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.4.0" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.2", + "destroy": "1.0.4", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.3", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.4.0" + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.18" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + } + } +} diff --git a/public/fonts/11451.otf b/public/fonts/11451.otf new file mode 100644 index 0000000..8c28f0b Binary files /dev/null and b/public/fonts/11451.otf differ diff --git a/public/fonts/huxley/a_huxleycaps-italic.ttf b/public/fonts/huxley/a_huxleycaps-italic.ttf new file mode 100644 index 0000000..bf666b8 Binary files /dev/null and b/public/fonts/huxley/a_huxleycaps-italic.ttf differ diff --git a/public/fonts/st/Stolzl-Thin.eot b/public/fonts/st/Stolzl-Thin.eot new file mode 100644 index 0000000..3d24967 Binary files /dev/null and b/public/fonts/st/Stolzl-Thin.eot differ diff --git a/public/fonts/st/Stolzl-Thin.svg b/public/fonts/st/Stolzl-Thin.svg new file mode 100644 index 0000000..c160fa1 --- /dev/null +++ b/public/fonts/st/Stolzl-Thin.svg @@ -0,0 +1,4406 @@ + + + + +Created by FontForge 20170910 at Mon Nov 30 20:38:32 2015 + By Jimmy Wärting +Copyright \(c\) 2015 by Mariya Pigoulevskaya. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/fonts/st/Stolzl-Thin.ttf b/public/fonts/st/Stolzl-Thin.ttf new file mode 100644 index 0000000..70499ee Binary files /dev/null and b/public/fonts/st/Stolzl-Thin.ttf differ diff --git a/public/fonts/st/Stolzl-Thin.woff b/public/fonts/st/Stolzl-Thin.woff new file mode 100644 index 0000000..ffc2e17 Binary files /dev/null and b/public/fonts/st/Stolzl-Thin.woff differ diff --git a/public/fonts/st/Stolzl-Thin.woff2 b/public/fonts/st/Stolzl-Thin.woff2 new file mode 100644 index 0000000..10711ac Binary files /dev/null and b/public/fonts/st/Stolzl-Thin.woff2 differ diff --git a/public/fonts/st/font.css b/public/fonts/st/font.css new file mode 100644 index 0000000..1b2dd1c --- /dev/null +++ b/public/fonts/st/font.css @@ -0,0 +1,12 @@ +@font-face { + font-family: 'Stolzl-Thin'; + src: url('Stolzl-Thin.eot'); + src: url('Stolzl-Thin.woff2') format('woff2'), + url('Stolzl-Thin.woff') format('woff'), + url('Stolzl-Thin.ttf') format('truetype'), + url('Stolzl-Thin.svg#Stolzl-Thin') format('svg'), + url('Stolzl-Thin.eot?#iefix') format('embedded-opentype'); + font-weight: normal; + font-style: normal; +} + diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..61cc425 --- /dev/null +++ b/public/index.html @@ -0,0 +1,97 @@ + + + + + Aperture + + + +
+

ERROR

+

+
+
+
+

Выберите новую картинку.

+
+
+ + + +

Пользователь:

+

Дата:

+ Добавить пост +
+ +
+
+

Переместите сюда файл.

+ + +
+ + + +

Пользователь:

+

Дата:

+ Добавить пост +
+
+
+ +
+

Авторизация

+
+
+ +
+
+
+
+ Aperture +
+ +
+
+
+
+ +
+
+
+
+
Загрузить еще
+ + + + + + +
+ + \ No newline at end of file diff --git a/public/js/ApplicationModule.js b/public/js/ApplicationModule.js new file mode 100644 index 0000000..8331075 --- /dev/null +++ b/public/js/ApplicationModule.js @@ -0,0 +1,225 @@ +"use strict"; +let ApplicationModule = function () { + function compareDates(a, b) { + return b.createdAt - a.createdAt; + } + function writeInLocalStoragePhotoPosts(){ + localStorage.setItem('photoPosts', JSON.stringify(ApplicationModule.photoPosts)); + } + + + + return { + userAuthorized: null, + mapHash: [], + users: [ + { + author: "Djadka.by", + authorPhoto: "./pictures/menu/mainPhoto.png", + password: "12345678" + }, + { + author: "cars", + authorPhoto: "http://skachat-kartinki.ru/img/picture/Oct/04/417e63b46e74be245aca2a969133b567/4.jpg", + password: "12345" + }, + { + author: "aadereiko", + authorPhoto: "./pictures/post/post1/avaOther.png", + password: "90a12345" + }, + { + author: "films", + authorPhoto: "https://im0-tub-by.yandex.net/i?id=3979f00131c7422720695dcb01d2dce2&n=13", + password: "90a12", + } + ], + photoPosts: [], + begOfVisiblePosts: 0, + + //we're using compareHash to sort hashMap to get the most popular posts + + compareHash: function (a, b) { + return b.count - a.count; + }, + + addHashTagsInMapHash: function (post) { + let indexOfFoundHashtag; + + //if this adding hashtag exists in container, we just add 1 to "count", else we're pushing this hashtag. + post.hashtags.forEach( + (hashtag) => { + indexOfFoundHashtag = ApplicationModule.mapHash.map(function (elem) { + return elem.word; + }).indexOf(hashtag); + if (indexOfFoundHashtag === -1) { + ApplicationModule.mapHash.push({word: hashtag, count: 1}); + } else { + ApplicationModule.mapHash[indexOfFoundHashtag].count += 1; + } + }) + }, + + getPhotoPosts: function (skip, top, filterConfing) { + let result = ApplicationModule.photoPosts; + + if(!result) + return []; + result = result.filter(function (post) { + return !post.deleted; + }); + + if (filterConfing) { + if (filterConfing.author) { + result = result.filter(function (post) { + return post.author === filterConfing.author; + }); + } + + if (filterConfing.createdAt) { + let date = new Date(filterConfing.createdAt.replace(/(\d+)[-.,;: ](\d+)[-.,;: ](\d+)/, '$3/$2/$1')) + result = result.filter(function (post) { + return post.createdAt >= date; + }); + } + + if (filterConfing.hashtags && filterConfing.hashtags.length !== 0) { + let hashtags = filterConfing.hashtags; + result = result.filter((post) => + hashtags.every((tag) => (post.hashtags || []).includes(tag)) + ); + } + } + + if (result.length === 0) { + return []; + } + + result.sort(compareDates); + + return result.slice(skip, skip + top); + }, + + getUrlAva: function (name) { + let index = ApplicationModule.users.map((elem) => { + return elem.author; + }).indexOf(name); + if (index === -1) { + return 0 + } else { + return ApplicationModule.users[index].authorPhoto; + } + }, + + getPhotoPost: function (id) { + return ApplicationModule.photoPosts.find(function (elem) { + return String(elem.id) === String(id); + }) + }, + + validatePhotoPost: function (post) { + if (isNaN(post.id)) { + return false; + } + + if (String(post.id) === '0') { + return false; + } + + let isNotUniqueID = post.hashtags.some(function (idTemp) { + return String(idTemp) === String(post.id); + }); + + if (!isNotUniqueID) { + if (typeof post.description !== "string" || post.description.length > 200 || post.description.length < 0) { + return false; + } + + if (typeof(post.author) !== "string") { + return false; + } + + if (!(post.createdAt instanceof Date)) { + return false; + } + + if (typeof(post.photoLink) !== "string") { + return false; + } + + if (!(post.id && post.description && post.createdAt && post.author && post.photoLink)) { + return false; + } + + return true; + } + }, + + addPhotoPost: function (post) { + if (ApplicationModule.validatePhotoPost(post)) { + ApplicationModule.photoPosts.push(post); + ApplicationModule.addHashTagsInMapHash(post); + + ViewModule.propHash('selectFilter'); + writeInLocalStoragePhotoPosts(); + return true; + } + return false; + }, + + removePhotoPost: function (id) { + let post = ApplicationModule.getPhotoPost(id); + if (post) { + post.deleted = true; + } + writeInLocalStoragePhotoPosts(); + return !!post; + }, + + editPost: function (id, post) { + if (post.description && post.description.length > 200) { + return false; + } + + let getTemp = ApplicationModule.getPhotoPost(id); + if (post.description) { + getTemp.description = post.description; + } + if (post.photoLink) { + getTemp.photoLink = post.photoLink; + } + if (post.hashtags) { + getTemp.hashtags = post.hashtags.slice(); + } + + return getTemp || null; + }, + + fillMapHash: function () { + for (let i = 0; i < ApplicationModule.photoPosts.length; i++) { + ApplicationModule.addHashTagsInMapHash(ApplicationModule.photoPosts[i]); + } + }, + + fillInformation: function(){ + fs.writeFile('./data/posts.json', localStorage.getItem('photoPosts')); + ApplicationModule.photoPosts = JSON.parse(localStorage.getItem('photoPosts'), (key, value)=>{ + if(key === 'createdAt'){ + return new Date(value); + } + return value; + }) || []; + // we have array of users for authorization + // ApplicationModule.users = JSON.parse(localStorage.getItem('users')) || []; + + ApplicationModule.userAuthorized = JSON.parse(localStorage.getItem('userAuthorized')); + }, + + // this function has added our posts and users in LocalStorage + putPostsAnsUsersInLocalStorage(){ + let str = JSON.stringify(ApplicationModule.photoPosts); + localStorage.setItem('photoPosts', str); + localStorage.setItem('users', JSON.stringify(ApplicationModule.users)); + } + } +}(); diff --git a/public/js/EventsModule.js b/public/js/EventsModule.js new file mode 100644 index 0000000..7a85faa --- /dev/null +++ b/public/js/EventsModule.js @@ -0,0 +1,410 @@ +"use strict"; +let EventsModule = function () { + //по частям + let inputLogin = document.getElementById('login'); + let inputData = document.getElementById('date'); + let inputHashtag = document.getElementById('hash'); + let inputLoginAuth = document.getElementById('logAuth'); + let inputPassword = document.getElementById('passAuth'); + let grayBackground = document.getElementById('grayBckd'); + let formAuth = document.getElementById('formAuth'); + let formAdding = document.getElementById('formAddPost'); + let dropArea = document.getElementById('addPhotoDrop'); + let dropAreaEdit = document.getElementById('editPhotoDrop'); + let userAdd = document.getElementById('userAdding'); + let dataAdd = document.getElementById('dataAdding'); + let hashAdd = document.getElementById('inputHashtags'); + let selectFilter = document.getElementById('selectFilter'); + let selectAdd = document.getElementById('selectAdd'); + let gallery = document.getElementById('gallery'); + let inputDescription = document.getElementById('inputDescription'); + let formEdit = document.getElementById('editFormPostId'); + let userEdit = document.getElementById('userEdit'); + let dataEdit = document.getElementById('dataEdit'); + let hashEdit = document.getElementById('inputHashtagsEdit'); + let selectEdit = document.getElementById('selectEdit'); + let inputHastagsEdit = document.getElementById('inputHashtagsEdit'); + let inputDescriptionEdit = document.getElementById('inputDescriptionEdit'); + let galleryEdit = document.getElementById('galleryEdit'); + let error = document.getElementById('error'); + let textError = document.getElementById('textError'); + let photoLnkEdit; + let photoLnk; + let edittingPostId; + let indexEditPost; + + //DOM + function highlight() { + dropArea.classList.add('highlight') + } + + //DOM + function unHighLight() { + dropArea.classList.remove('highlight') + } + + function handleFiles(files) { + files = [...files]; + files.forEach(uploadFile); + files.forEach(previewFile); + } + + function handleFilesEdit(files) { + files = [...files]; + files.forEach(uploadFileEdit); + files.forEach(previewFileEdit); + } + + function previewFileEdit(file) { + let reader = new FileReader(); + reader.readAsDataURL(file); + reader.onloadend = function () { + let img = document.createElement('img'); + img.src = reader.result; + galleryEdit.innerHTML = ''; + galleryEdit.appendChild(img); + photoLnkEdit = reader.result; + } + } + + function uploadFileEdit(file) { + // let url = 'ВАШ URL ДЛЯ ЗАГРУЗКИ ФАЙЛОВ' + //let formData = new FormData() + //formData.append('file', file) + // fetch(url, { + // method: 'POST', + // body: formData + // }) + } + + function handleDrop(e) { + let dt = e.dataTransfer; + let files = dt.files; + if(files.length === 1){ + handleFiles(files); + } + else{ + + } + } + + function handleDropEdit(e) { + let dt = e.dataTransfer; + let files = dt.files; + if(files.length === 1){ + handleFilesEdit(files); + } + else{ +// + } + } + + function uploadFile(file) { + // let url = 'ВАШ URL ДЛЯ ЗАГРУЗКИ ФАЙЛОВ' + //let formData = new FormData() + //formData.append('file', file) + // fetch(url, { + // method: 'POST', + // body: formData + // }) + } + + function previewFile(file) { + let reader = new FileReader(); + reader.readAsDataURL(file); + reader.onloadend = function () { + let img = document.createElement('img'); + img.src = reader.result; + gallery.appendChild(img); + photoLnk = reader.result; + } + } + + function preventDefaults (e) { + e.preventDefault(); + e.stopPropagation(); + } + + return { + filterPosts: function () { + let arrHashtags = []; + if(inputHashtag.value) { + arrHashtags = inputHashtag.value.replace('#', ' ').trim().split(/[#, ]+/); + } + //user didn't choose the empty string + if(selectFilter.selectedIndex !== 1){ + //user didn't choose the equal hashatgs + if(arrHashtags.indexOf(selectFilter.options[selectFilter.selectedIndex].value) === -1) { + arrHashtags.push(selectFilter.options[selectFilter.selectedIndex].value); + } + } + ViewModule.printOnScreen(0, 30, + { + createdAt: 0 || inputData.value, + hashtags: arrHashtags.length === 0 ? 0 : arrHashtags, + author: (0 || inputLogin.value) + }); + }, + + getMorePosts: function () { + ApplicationModule.begOfVisiblePosts += 10; + ViewModule.printOnScreen(ApplicationModule.begOfVisiblePosts, ApplicationModule.begOfVisiblePosts + 10); + }, + + closeForms: function () { + grayBackground.style.display = 'none'; + formAuth.style.display = 'none'; + formAdding.style.display = 'none'; + formEdit.style.display = 'none'; + error.style.display = 'none'; + }, + + enter: function () { + grayBackground.style.display = 'block'; + formAuth.style.display = 'block'; + }, + + addPost: function () { + inputDescription.value = ''; + hashAdd.value = ''; + userAdd.innerText = 'Пользователь: '; + dataAdd.innerText = 'Дата: '; + gallery.innerHTML = ''; + ViewModule.propHash('selectAdd'); + grayBackground.style.display = 'block'; + formAdding.style.display = 'block'; + userAdd.innerText += ApplicationModule.userAuthorized; + dataAdd.innerText += new Date(); + }, + + editPost: function(e) { + inputDescriptionEdit.value = ''; + inputHastagsEdit.value = ''; + userEdit.innerText = 'Пользователь: '; + dataEdit.innerText = 'Дата: '; + galleryEdit.innerHTML = ''; + edittingPostId = e.target.id.substring(5); + let imgEdit = document.createElement('img'); + indexEditPost = ApplicationModule.photoPosts.map((post)=>{ + return post.id; + }).indexOf(edittingPostId); + grayBackground.style.display = 'block'; + formEdit.style.display = 'block'; + //new object for edit post + userEdit.innerText += ApplicationModule.userAuthorized; + dataEdit.innerText += ApplicationModule.photoPosts[indexEditPost].createdAt; + inputHastagsEdit.value = ViewModule.makeStringForHashtags(ApplicationModule.photoPosts[indexEditPost].hashtags); + inputDescriptionEdit.value = ApplicationModule.photoPosts[indexEditPost].description; + imgEdit.src = ApplicationModule.photoPosts[indexEditPost].photoLink; + galleryEdit.appendChild(imgEdit); + }, + + pressLike: function(e){ + if(ApplicationModule.userAuthorized !== null) { + let indexToAction = ApplicationModule.photoPosts.map((post) => { + return post.id; + }).indexOf(e.target.id.substr(5)); + if (indexToAction !== -1) { + let indexLike = ApplicationModule.photoPosts[indexToAction].likes.indexOf(ApplicationModule.userAuthorized); + if (indexLike === -1){ + ApplicationModule.photoPosts[indexToAction].likes.push(ApplicationModule.userAuthorized); + localStorage.setItem('photoPosts', JSON.stringify(ApplicationModule.photoPosts)); + document.getElementById(e.target.id.replace('like', 'textLike')).innerText = ApplicationModule.photoPosts[indexToAction].likes.length; + document.getElementById(e.target.id).src = './pictures/post/like.png'; + } else { + ApplicationModule.photoPosts[indexToAction].likes.splice(indexLike, 1); + document.getElementById(e.target.id).src = './pictures/post/NotPressed.png'; + document.getElementById(e.target.id.replace('like', 'textLike')).innerText = ApplicationModule.photoPosts[indexToAction].likes.length; + localStorage.setItem('photoPosts', JSON.stringify(ApplicationModule.photoPosts)); + } + } + + } + }, + + logIn: function () { + let name = inputLoginAuth.value; + let pass = inputPassword.value; + + if (pass && name) { + let index = ApplicationModule.users.map((elem) => { + return elem.author; + }).indexOf(name); + if (index !== -1) { + if (ApplicationModule.users[index].password === pass) { + ViewModule.loginView(name); + document.getElementById('exitBtn').addEventListener('click', EventsModule.unAuthorization); + document.getElementById('add').addEventListener('click', EventsModule.addPost); + document.getElementById('home').addEventListener('click', EventsModule.homePosts); + localStorage.setItem('userAuthorized', JSON.stringify(ApplicationModule.userAuthorized)); + EventsModule.closeForms(); + ViewModule.printOnScreen(ApplicationModule.begOfVisiblePosts, ApplicationModule.begOfVisiblePosts + 10); + inputLoginAuth.value = 'Логин'; + inputPassword.value = 'Пароль'; + //after login we get new edit buttons + } else { + textError.innerText = 'Неправильный пароль'; + EventsModule.closeForms(); + grayBackground.style.display = 'block'; + error.style.display = 'block'; + } + } else { + textError.innerText = 'Такого пользователя не найдено'; + EventsModule.closeForms(); + grayBackground.style.display = 'block'; + error.style.display = 'block'; + } + } + }, + + homePosts: function(){ + ApplicationModule.begOfVisiblePosts = 0; + ViewModule.printOnScreen(ApplicationModule.begOfVisiblePosts, ApplicationModule.begOfVisiblePosts + 10); + }, + + unAuthorization: function () { + document.getElementById("menu").innerHTML = ''; + ViewModule.createMenuNotForUser(); + ApplicationModule.userAuthorized = null; + localStorage.setItem('userAuthorized', JSON.stringify(ApplicationModule.userAuthorized)); + ViewModule.printOnScreen(ApplicationModule.begOfVisiblePosts, ApplicationModule.begOfVisiblePosts + 10); + document.getElementById('enterMenu').addEventListener('click', EventsModule.enter); + }, + + addingPost: function () { + let arrayHashtags = []; + if(hashAdd.value){ + arrayHashtags = hashAdd.value.trim().split(/[,# ]+/); + } + if(selectAdd.selectedIndex !== 1){ + if(arrayHashtags.indexOf(selectAdd.options[selectAdd.selectedIndex].value) === -1) { + /*саша я тебя люблю :3 */ + arrayHashtags.push(selectAdd.options[selectAdd.selectedIndex].value); + } + } + + ApplicationModule.begOfVisiblePosts = 0; + let user = { + id: (ApplicationModule.photoPosts.length + 1).toString(), + description: inputDescription.value, + createdAt: new Date(), + author: ApplicationModule.userAuthorized, + authorPhoto: ApplicationModule.users[ApplicationModule.users.map((user) => { + return user.author; + }).indexOf(ApplicationModule.userAuthorized)].authorPhoto || 0, + photoLink: photoLnk, + hashtags: arrayHashtags.length === 0 ? 0 : arrayHashtags, + likes: [], + deleted: false + }; + if (ApplicationModule.addPhotoPost(user)) { + ViewModule.printOnScreen(ApplicationModule.begOfVisiblePosts, ApplicationModule.begOfVisiblePosts + 10); + } else { + textError.innerText = 'Неверные данные'; + EventsModule.closeForms(); + grayBackground.style.display = 'block'; + error.style.display = 'block'; + + } + EventsModule.closeForms(); + }, + + edittingPost: function() { + let arrayHashtags = []; + if (hashEdit.value) { + arrayHashtags = hashEdit.value.replace('#', ' ').trim().split(/[,# ]+/); + } + if (selectEdit.selectedIndex !== 1) { + if (arrayHashtags.indexOf(selectEdit.options[selectEdit.selectedIndex].value) === -1) { + arrayHashtags.push(selectEdit.options[selectEdit.selectedIndex].value); + } + } + let user = { + id: 1, + description: inputDescriptionEdit.value, + author: ApplicationModule.userAuthorized, + authorPhoto: ApplicationModule.photoPosts[indexEditPost].authorPhoto, + photoLink: photoLnkEdit, + hashtags: arrayHashtags.length === 0 ? 0 : arrayHashtags, + likes: ApplicationModule.photoPosts[indexEditPost].likes, + deleted: false + }; + + let postOld = ApplicationModule.getPhotoPost(edittingPostId); + if (ApplicationModule.editPost(postOld.id, user)) { + ViewModule.editDomPhotoPost(postOld, user); + document.getElementById('edit-'+edittingPostId).addEventListener('click', EventsModule.editPost); + document.getElementById('delete-'+edittingPostId).addEventListener('click', EventsModule.delettingPost); + document.getElementById('like-'+edittingPostId).addEventListener('click', EventsModule.pressLike); + localStorage.setItem('photoPosts', JSON.stringify(ApplicationModule.photoPosts)); + EventsModule.closeForms(); + } else { + textError.innerText = 'Неверные данные'; + EventsModule.closeForms(); + grayBackground.style.display = 'block'; + error.style.display = 'block'; + } + + }, + + delettingPost: function(e) { + let post = ApplicationModule.getPhotoPost(e.target.id.substring(7)); + if (ApplicationModule.removePhotoPost(post.id)) { + ViewModule.deleteDomPhotoPost(post); + } else + { + textError.innerText = 'Неправильный пароль'; + EventsModule.closeForms(); + grayBackground.style.display = 'block'; + error.style.display = 'block'; + } + }, + + initializeLikeButtons: function(){ + let likeButtons = document.querySelectorAll('.likePost'); + for(let i = 0; i < likeButtons.length; i++){ + likeButtons[i].addEventListener('click', EventsModule.pressLike); + } + }, + + initializeButtonsPost: function(){ + let editButtons = document.querySelectorAll('.editPost'); + let deleteButtons = document.querySelectorAll('.deletePost'); + for(let i = 0; i < editButtons.length; i++){ + editButtons[i].addEventListener('click', EventsModule.editPost); + deleteButtons[i].addEventListener('click', EventsModule.delettingPost); + } + }, + + initialization: function(){ + document.getElementById('downMore').addEventListener('click', EventsModule.getMorePosts); + document.getElementById('filtersPicture').addEventListener('click', EventsModule.filterPosts); + document.getElementById('grayBckd').addEventListener('click', EventsModule.closeForms); + if(ApplicationModule.userAuthorized === null) { + document.getElementById('enterMenu').addEventListener('click', EventsModule.enter); + } else { + document.getElementById('exitBtn').addEventListener('click', EventsModule.unAuthorization); + document.getElementById('add').addEventListener('click', EventsModule.addPost); + document.getElementById('home').addEventListener('click', EventsModule.homePosts); + EventsModule.initializeButtonsPost(); + } + document.getElementById('loginBtn').addEventListener('click', EventsModule.logIn); + ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { + dropArea.addEventListener(eventName, preventDefaults, false); + dropAreaEdit.addEventListener(eventName, preventDefaults, false); + }); + dropArea.addEventListener('drop', handleDrop, false); + dropAreaEdit.addEventListener('drop', handleDropEdit, false); + ['dragenter', 'dragover'].forEach(eventName => { + dropArea.addEventListener(eventName, highlight, false); + dropAreaEdit.addEventListener(eventName, highlight, false); + }); + ['dragleave', 'drop'].forEach(eventName => { + dropArea.addEventListener(eventName, unHighLight, false); + dropAreaEdit.addEventListener(eventName, unHighLight, false); + }); + document.getElementById('addingFormAdd').addEventListener('click', EventsModule.addingPost); + document.getElementById('editFormAdd').addEventListener('click', EventsModule.edittingPost); + } + } +}(); \ No newline at end of file diff --git a/public/js/ViewModule.js b/public/js/ViewModule.js new file mode 100644 index 0000000..b9a2d57 --- /dev/null +++ b/public/js/ViewModule.js @@ -0,0 +1,118 @@ +"use strict"; +let ViewModule = function () { + let containerPosts = document.querySelector('.posts'); + + return { + printOnScreen: function (skip, top, filterConfing) { + let arrPosts = document.querySelectorAll(".post"); + arrPosts.forEach((post) => { + post.remove(); + }); + let arrForPrint = ApplicationModule.getPhotoPosts(skip, top, filterConfing); + + arrForPrint.forEach((post) => { + ViewModule.addDomPhotoPost(post); + }); + + if (ApplicationModule.userAuthorized !== null) { + EventsModule.initializeLikeButtons(); + EventsModule.initializeButtonsPost(); + } + }, + + loginView: function (name) { + ApplicationModule.userAuthorized = name || null; + if (name) { + document.getElementById("menu").innerHTML = ''; + ViewModule.createMenuForUser(); + } + }, + + makeStringForHashtags: function (hashtags) { + return (hashtags || []).map((ht) => '#' + ht).join(' '); + }, + + addDomPhotoPost: function (post) { + let imgForLike; + if (ApplicationModule.userAuthorized !== null && post.likes.indexOf(ApplicationModule.userAuthorized) !== -1) { + imgForLike = './pictures/post/like.png'; + } else { + imgForLike = './pictures/post/NotPressed.png'; + } + let newDiv = document.createElement("div"); + newDiv.className = "post"; + newDiv.id = post.id; + newDiv.innerHTML = ` + Фото пользователя +

${post.author}

+

${post.createdAt.getDate()}.${post.createdAt.getMonth()}.${post.createdAt.getFullYear()}

+

${post.createdAt.getHours()}:${post.createdAt.getUTCMinutes()}:${post.createdAt.getSeconds()}

+

Фото поста

+ Лайк +

${post.likes.length.toString()}

+

${post.description}

+

${ViewModule.makeStringForHashtags(post.hashtags) || 0}

+ `; + if (post.author === ApplicationModule.userAuthorized) { + newDiv.innerHTML += ` + Изменить пост + Удалить пост + ` + } + containerPosts.appendChild(newDiv); + }, + + deleteDomPhotoPost: function (post) { + let deletedPost = document.getElementById(post.id); + containerPosts.removeChild(deletedPost); + }, + + editDomPhotoPost: function (post, newPost) { + let editedPost = document.getElementById(post.id); + let result = document.createElement("div"); + + result.innerHTML = editedPost.innerHTML; + result.id = post.id; + result.className = "post"; + if (newPost.description) { + let re = result.querySelector(".textComment"); + re.textContent = newPost.description; + } + if (newPost.photoLink) { + result.querySelector(".photoPost").src = newPost.photoLink; + } + if (newPost.hashtags) { + result.querySelector(".textHashTag").textContent = ViewModule.makeStringForHashtags(newPost.hashtags); + } + containerPosts.replaceChild(result, editedPost); + }, + + createMenuForUser: function () { + let menu = document.querySelector(".menu"); + menu.innerHTML = ` + + + + +` + }, + + createMenuNotForUser: function () { + let menu = document.querySelector(".menu"); + menu.innerHTML = `Войти + ` + }, + + propHash: function (name) { + //here we're printing the most popular hashtags (we get 4 the most popular) + if (ApplicationModule.mapHash.length !== 0) { + ApplicationModule.mapHash.sort(ApplicationModule.compareHash); + let sF = document.getElementById(name); + for (let i = 0; i < 4; i++) + if (ApplicationModule.mapHash[i]) { + sF.children[i + 2].innerText = ApplicationModule.mapHash[i].word; + } + } + } + } +}(); \ No newline at end of file diff --git a/public/js/scrypt.js b/public/js/scrypt.js new file mode 100644 index 0000000..307c9a0 --- /dev/null +++ b/public/js/scrypt.js @@ -0,0 +1,14 @@ +"use strict"; +// const appM = require('./ApplicationModele'); +// const eveM = require('./EventsModule'); +// const vieM = require('./ViewModule'); + ApplicationModule.fillInformation(); +ViewModule.printOnScreen(ApplicationModule.begOfVisiblePosts, ApplicationModule.begOfVisiblePosts + 10); +if (ApplicationModule.userAuthorized === null) { + ViewModule.createMenuNotForUser(); +} else { + ViewModule.createMenuForUser(); +} +ApplicationModule.fillMapHash(); +ViewModule.propHash('selectFilter'); +EventsModule.initialization(); \ No newline at end of file diff --git a/public/pictures/authorization/enter.png b/public/pictures/authorization/enter.png new file mode 100644 index 0000000..4bf5333 Binary files /dev/null and b/public/pictures/authorization/enter.png differ diff --git a/public/pictures/authorization/logoWithAuth.png b/public/pictures/authorization/logoWithAuth.png new file mode 100644 index 0000000..e069e98 Binary files /dev/null and b/public/pictures/authorization/logoWithAuth.png differ diff --git a/public/pictures/downloadYet.png b/public/pictures/downloadYet.png new file mode 100644 index 0000000..6b54bae Binary files /dev/null and b/public/pictures/downloadYet.png differ diff --git a/public/pictures/filters/filter.png b/public/pictures/filters/filter.png new file mode 100644 index 0000000..aa9b993 Binary files /dev/null and b/public/pictures/filters/filter.png differ diff --git a/public/pictures/filters/filterAnim.png b/public/pictures/filters/filterAnim.png new file mode 100644 index 0000000..0ab8b27 Binary files /dev/null and b/public/pictures/filters/filterAnim.png differ diff --git a/public/pictures/logo/apertureText.png b/public/pictures/logo/apertureText.png new file mode 100644 index 0000000..81206af Binary files /dev/null and b/public/pictures/logo/apertureText.png differ diff --git a/public/pictures/menu/add.png b/public/pictures/menu/add.png new file mode 100644 index 0000000..f06d3b5 Binary files /dev/null and b/public/pictures/menu/add.png differ diff --git a/public/pictures/menu/exit.png b/public/pictures/menu/exit.png new file mode 100644 index 0000000..f2f8eb7 Binary files /dev/null and b/public/pictures/menu/exit.png differ diff --git a/public/pictures/menu/home.png b/public/pictures/menu/home.png new file mode 100644 index 0000000..e7cdaca Binary files /dev/null and b/public/pictures/menu/home.png differ diff --git a/public/pictures/menu/mainPhoto.png b/public/pictures/menu/mainPhoto.png new file mode 100644 index 0000000..15445ac Binary files /dev/null and b/public/pictures/menu/mainPhoto.png differ diff --git a/public/pictures/post/NotPressed.png b/public/pictures/post/NotPressed.png new file mode 100644 index 0000000..7bb1c78 Binary files /dev/null and b/public/pictures/post/NotPressed.png differ diff --git a/public/pictures/post/delete.png b/public/pictures/post/delete.png new file mode 100644 index 0000000..eac8042 Binary files /dev/null and b/public/pictures/post/delete.png differ diff --git a/public/pictures/post/edit.png b/public/pictures/post/edit.png new file mode 100644 index 0000000..58c36ea Binary files /dev/null and b/public/pictures/post/edit.png differ diff --git a/public/pictures/post/like.png b/public/pictures/post/like.png new file mode 100644 index 0000000..c118e83 Binary files /dev/null and b/public/pictures/post/like.png differ diff --git a/public/pictures/post/post1/avaOther.png b/public/pictures/post/post1/avaOther.png new file mode 100644 index 0000000..5cf300a Binary files /dev/null and b/public/pictures/post/post1/avaOther.png differ diff --git a/public/pictures/post/post1/gory-cvety-rassvet-solnce.jpg b/public/pictures/post/post1/gory-cvety-rassvet-solnce.jpg new file mode 100644 index 0000000..d67c23a Binary files /dev/null and b/public/pictures/post/post1/gory-cvety-rassvet-solnce.jpg differ diff --git a/public/pictures/post/post2/Russia_Mountains_Lake_469922.jpg b/public/pictures/post/post2/Russia_Mountains_Lake_469922.jpg new file mode 100644 index 0000000..56f76cb Binary files /dev/null and b/public/pictures/post/post2/Russia_Mountains_Lake_469922.jpg differ diff --git a/public/pictures/post/post3/index.php b/public/pictures/post/post3/index.php new file mode 100644 index 0000000..d8b4651 Binary files /dev/null and b/public/pictures/post/post3/index.php differ diff --git a/public/pictures/post/post4/oboik.ru_34817.jpg b/public/pictures/post/post4/oboik.ru_34817.jpg new file mode 100644 index 0000000..50eeadd Binary files /dev/null and b/public/pictures/post/post4/oboik.ru_34817.jpg differ diff --git a/public/pictures/post/post5/niceimage.ru-41516.jpg b/public/pictures/post/post5/niceimage.ru-41516.jpg new file mode 100644 index 0000000..bf675cc Binary files /dev/null and b/public/pictures/post/post5/niceimage.ru-41516.jpg differ diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..7018744 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,601 @@ +@font-face { + font-family: Stolzl-Thin; + src: url('./fonts/st/Stolzl-Thin.eot'); + src: url('./fonts/st/Stolzl-Thin.woff2') format('woff2'), + url('./fonts/st/Stolzl-Thin.woff') format('woff'), + url('./fonts/st/Stolzl-Thin.ttf') format('truetype'), + url('./fonts/st/Stolzl-Thin.svg#Stolzl-Thin') format('svg'), + url('./fonts/st/Stolzl-Thin.eot?#iefix') format('embedded-opentype'); + font-weight: normal; + font-style: normal; +} + +.logoImg { + height: 10vh; +} + +.addingHashtags { + font-family: Stolzl-Thin; + vertical-align: middle; + border: 1px solid #cecece; + background: #F6F6f6; + border-radius: 8px; + width: 30%; + height: 5%; +} + +.filter-blocks { + float: left; + font-family: Stolzl-Thin; + vertical-align: middle; + margin: 5px; +} + +.filters-picture { + float: right; + height: 10vh; + width: 50px; + text-align: right; + background: url("pictures/filters/filter.png"); + background-size: 50px; +} + +.filters-picture:active { + float: right; + width: 50px; + text-align: right; + background: url("pictures/filters/filterAnim.png"); + background-size: 50px; + text-align: right; + color: #e3bd8c; +} + +.filter-input { + color: #e3bd8c; + max-height: 10vh; + max-width: 40vw; + border-radius: 3px; +} + +.filter-input:focus { + color: #e3bd8c; + max-height: 10vh; + max-width: 10vm; + border-radius: 3px; + border: 1px solid #e3bd8c; +} + +.filters-text { + text-align: left; + vertical-align: middle; + font-family: Stolzl-Thin, Century Gothic, Georgia; + paddging: auto; +} + +.filters { + height: 10vh; + max-height: 15vh; +} + +.filters-picture { + height: 50px; +} + +.menu-picture { + margin: 5px; + max-height: 15vh; + height: 50px; + max-width: 15vw; + max-height: 15vh; +} + +.menu-block-picture { + float: left; + margin: 5px; + height: 50px; + max-height: 15vh; +} + +.menu-picture:active { + margin: 5px; + height: 40px; + max-width: 15vw; + max-height: 15vh; + +} + +.menu-block-add { + float: right; + width: 15vw; + padding: 5px 30vw 10px 40px; + max-width: 15vw; + max-height: 15vh; + +} + +.menu-block-avatar { + border-radius: 100px; + float: right; + max-width: 15vw; + height: 50px; + padding: 5px 5vw 0vw 0px; + max-width: 15vw; + max-height: 15vh; + +} + +.menu-picture-margin { + height: 50px; + max-width: 40px; + transition-duration: 0.8s; + transition-property: transform; + border-radius: 100px; +} + +.menu-picture-margin:hover { + transform: rotate(360deg); +} + +.menu { + clear: both; + height: 60px; + border-top-color: #e3bd8c; + border-top-style: solid; + border-top-width: 1px; +} + +body { + font-family: Stolzl-Thin, Century Gothic, Georgia; + height: 94vh; + /*min-width: 556px;*/ +} + +.scroll-block { + clear: both; + height: 63vh; + max-height: 250vw; + overflow-y: scroll; + text-align: center; +} + +.downloadMore { + clear: both; + text-align: center; + height: 100px; +} + +.downloadMore:active { + clear: both; + text-align: center; + height: 105px; +} + +.post { + float: left; + margin: 5px 5px 5px 5%; +} + +.photoPost { + width: 250px; + height: 250px; + clear: both; +} + +.editPost { + margin: 0; + width: 30px; + float: right; +} + +.deletePost{ + margin: 0; + width: 30px; + float: right; +} + +.editPost:active { + margin: 0; + width: 28px; + float: right; +} + +.deletePost:active { + margin: 0; + width: 28px; + float: right; +} + +.avaPost { + border-radius: 100px; + width: 50px; + float: left; +} + +.postUser { + font-family: Stolzl-Thin, Century Gothic, Georgia; + color: black; + font-size: 15px; + margin: 0px 5px +} + +.dataUser { + font-family: Stolzl-Thin, Century Gothic, Georgia; + color: gray; + font-size: 15px; + text-indent: 20px; + margin: 0px 5px +} + +.likePost { + width: 30px; + height: 30px; + margin: 0px 5px 0px 0px; + float: left; +} + +.inpDivAuth { + margin-top: 10px; +} + +.main { + top: 0px; + bottom: 0px; + right: 0px; + left: 0px; + z-index: 90; +} + +#error{ + margin-left: 30vw; + margin-top: 5vh; + background-color: white; + width: 50vw; + max-width: 360px; + height: 30vh; + position: fixed; + text-align: center; + display: none; + z-index: 200; + border: 1px solid #E3BD8C; + border-radius: 8px; +} + +.formAuthorization { + margin-left: 30vw; + margin-top: 5vh; + background-color: white; + width: 50vw; + max-width: 360px; + height: 80vh; + position: fixed; + text-align: center; + display: none; + z-index: 150; + border: 1px solid #E3BD8C; + border-radius: 8px; +} + +.authLogo { + width: 15vw; + max-width: 110px; +} + +.pAuth { + font-size: 20px; + +} + +.enterBtn { + width: 43vw; + max-width: 300px; + margin-top: 10px; + height: 8vh; + font-size: 20px; + color: #c09f76; + font-family: Stolzl-Thin, Century Gothic, Georgia; + padding: 6px 0 4px 10px; + border: 1px solid #E3BD8C; + background: #FFFFFF; + border-radius: 8px; +} + +#textError{ + font-family: Stolzl-Thin, Century Gothic, Georgia; +} + +#addPhotoDrop{ + border: 2px dashed #ccc; + margin-left: 5%; + margin-top: 2%; + border-radius: 20px; + width: 90%; + height: 220px; + font-family: Stolzl-Thin, Century Gothic, Georgia; +} + +#editPhotoDrop{ + border: 2px dashed #ccc; + margin-left: 5%; + margin-top: 2%; + border-radius: 20px; + width: 90%; + height: 220px; + font-family: Stolzl-Thin, Century Gothic, Georgia; +} + +#addPhotoDrop.highlight{ + border-color: purple; +} + + +#gallery { + margin-top: 10px; +} + +#galleryEdit { + margin-top: 10px; +} + +#galleryEdit img { + width: 200px; + max-height: 130px; + margin-bottom: 10px; + margin-right: 10px; + vertical-align: middle; + } + +#gallery img { + width: 200px; + max-height: 130px; + margin-bottom: 10px; + margin-right: 10px; + vertical-align: middle; +} + +#fileElem { + display: none; +} + +/*#loaderFileStand{*/ + /*font-family: Stolzl-Thin, Century Gothic, Georgia;*/ + /*margin-bottom: 2%;*/ +/*}*/ + +.formForFile { + background: #E3BD8C; + color: #FFFFFF; + border-radius: 18px; + border: 1px solid #E3BD8C; + margin-top: 10%; + margin-left: 10%; + width: 80%; + height: 300px; +} + +.descriptionAdding { + margin-top: 10px; +} + +.editFormPost{ + margin-left: 30vw; + margin-top: 5vh; + background-color: white; + width: 50vw; + max-width: 360px; + height: 80vh; + position: fixed; + text-align: center; + display: none; + z-index: 150; + border: 1px solid #E3BD8C; + border-radius: 8px; +} + +.formAddingPost { + margin-left: 30vw; + margin-top: 5vh; + background-color: white; + width: 50vw; + max-width: 360px; + height: 80vh; + position: fixed; + text-align: center; + display: none; + z-index: 150; + border: 1px solid #E3BD8C; + border-radius: 8px; +} + +.inputAuth { + width: 40vw; + max-width: 300px; + height: 5vh; + font-size: 13px; + font-family: Stolzl-Thin, Century Gothic, Georgia; + padding: 6px 0 4px 10px; + border: 1px solid #cecece; + background: #F6F6f6; + border-radius: 8px; +} + +.inputAddingDescr { + width: 50%; + max-width: 300px; + height: 5%; + font-size: 13px; + font-family: Stolzl-Thin, Century Gothic, Georgia; + padding: 6px 0 4px 10px; + border: 1px solid #cecece; + background: #F6F6f6; + border-radius: 8px; + margin-top: 10px; +} + +.inputAddingHashtags { + width: 30%; + max-width: 300px; + height: 5%; + font-size: 13px; + font-family: Stolzl-Thin, Century Gothic, Georgia; + padding: 6px 0 4px 10px; + border: 1px solid #cecece; + background: #F6F6f6; + border-radius: 8px; + margin-top: 10px; +} + +.authInputes { + margin-top: 20vh; +} + +.likePostUnAuth { + width: 30px; + height: 30px; + margin: 0px 5px 0px 0px; + float: left; +} + +.grayBackground { + position: fixed; + left: 0; + right: 0; + bottom: 0; + top: 0; + display: none; + z-index: 100; + background-color: rgba(1, 1, 1, 0.75); +} + +.textLike { + font-family: Stolzl-Thin, Century Gothic, Georgia; + color: #e3bd8c; + font-size: 15px; + margin: 5px 5px 5px 0px; + float: left; +} + +.textComment { + font-family: Stolzl-Thin, Century Gothic, Georgia; + color: black; + font-size: 15px; + margin: 5px 5px 5px 10px; +} + +.textHashTag { + text-overflow: ellipsis; + white-space: nowrap; + max-width: 250px; + overflow: hidden; + font-family: Stolzl-Thin, Century Gothic, Georgia; + color: gray; + font-size: 15px; + clear: left; +} + +header { + border-bottom-style: solid; + border-bottom-width: 1px; + border-bottom-color: #e3bd8c; + text-align: center; + height: 10vh; +} + +footer { + clear: both; + background: #e3bd8c; + font-family: Stolzl-Thin, Century Gothic, Georgia; + text-align: center; + height: 6vh; + position: absolute; + margin-bottom: 0px; + width: 100%; +} + +@media screen and (max-width: 1044px) { + .posts { + clear: both; + height: 60vh; + overflow-y: scroll; + text-align: center; + } + + footer { + clear: both; + background: #e3bd8c; + font-family: Stolzl-Thin, Century Gothic, Georgia; + text-align: center; + font-size: 10px; + height: 7vh; + position: absolute; + margin-bottom: 0px; + width: 100%; + } +} + +@media screen and (max-width: 540px) { + + .filter-blocks { + float: left; + font-family: Stolzl-Thin; + vertical-align: middle; + max-width: 40px; + margin: 5px; + font-size: 15px; + } + + .menu-block-add { + float: left; + width: 2vw; + padding: 0 0 0 15px; + max-width: 5vw; + max-height: 5vh; + } + + .menu-block-avatar { + float: right; + width: 10vw; + max-height: 15vh; + } + + .menu-block-picture { + float: left; + max-height: 10vh; + max-width: 10vw; + } + + .menu-picture:active { + height: 40px; + max-width: 10vw; + max-height: 10vh; + } + + footer { + clear: both; + background: #e3bd8c; + font-family: Stolzl-Thin, Century Gothic, Georgia; + text-align: center; + font-size: 10px; + height: 6vh; + position: absolute; + margin-bottom: 0px; + width: 100%; + } + + .menu { + clear: both; + height: 70px; + border-top-color: #e3bd8c; + border-top-style: solid; + border-top-width: 1px; + } +} + +/*@media screen and (max-width: 285px){*/ +/*.scroll-block{*/ +/*clear: both;*/ +/*height: 56vh;*/ +/*!*max-height: 200vw;*!*/ +/*overflow-y: scroll;*/ +/*text-align: center;*/ +/*}*/ +/*}*/ diff --git a/server/ServerApplicationModule.js b/server/ServerApplicationModule.js new file mode 100644 index 0000000..6559ba4 --- /dev/null +++ b/server/ServerApplicationModule.js @@ -0,0 +1,229 @@ +"use strict"; +let ApplicationModule = function () { + function compareDates(a, b) { + return b.createdAt - a.createdAt; + } + + // function writeInLocalStoragePhotoPosts(){ + // localStorage.setItem('photoPosts', JSON.stringify(ApplicationModule.photoPosts)); + // } + + const fs = require('fs'); + const jsonUsers = fs.readFileSync('F:/learning/up/server/data/users.json'); + const jsonPosts = fs.readFileSync('F:/learning/up/server/data/posts.json'); + + return { + userAuthorized: null, + mapHash: [], + users: [], + photoPosts: [], + begOfVisiblePosts: 0, + + //we're using compareHash to sort hashMap to get the most popular posts + + compareHash: function (a, b) { + return b.count - a.count; + }, + + addHashTagsInMapHash: function (post) { + let indexOfFoundHashtag; + + //if this adding hashtag exists in container, we just add 1 to "count", else we're pushing this hashtag. + post.hashtags.forEach( + (hashtag) => { + indexOfFoundHashtag = ApplicationModule.mapHash.map(function (elem) { + return elem.word; + }).indexOf(hashtag); + if (indexOfFoundHashtag === -1) { + ApplicationModule.mapHash.push({word: hashtag, count: 1}); + } else { + ApplicationModule.mapHash[indexOfFoundHashtag].count += 1; + } + }) + }, + + getPhotoPosts: function (skip, top, filterConfing) { + let result = ApplicationModule.photoPosts; + + if(!result) + return []; + result = result.filter(function (post) { + return !post.deleted; + }); + + if (filterConfing) { + if (filterConfing.author) { + result = result.filter(function (post) { + return post.author === filterConfing.author; + }); + } + + if (filterConfing.createdAt) { + let date = new Date(filterConfing.createdAt.replace(/(\d+)[-.,;: ](\d+)[-.,;: ](\d+)/, '$3/$2/$1')) + result = result.filter(function (post) { + return post.createdAt >= date; + }); + } + + if (filterConfing.hashtags && filterConfing.hashtags.length !== 0) { + let hashtags = filterConfing.hashtags; + result = result.filter((post) => + hashtags.every((tag) => (post.hashtags || []).includes(tag)) + ); + } + } + + if (result.length === 0) { + return []; + } + + result.sort(compareDates); + + return result.slice(skip, skip + top); + }, + + getUrlAva: function (name) { + let index = ApplicationModule.users.map((elem) => { + return elem.author; + }).indexOf(name); + if (index === -1) { + return 0 + } else { + return ApplicationModule.users[index].authorPhoto; + } + }, + + getPhotoPost: function (id) { + return ApplicationModule.photoPosts.find(function (elem) { + return String(elem.id) === String(id); + }) + }, + + validatePhotoPost: function (post) { + if (isNaN(post.id)) { + return false; + } + + if (String(post.id) === '0') { + return false; + } + + let isNotUniqueID = post.hashtags.some(function (idTemp) { + return String(idTemp) === String(post.id); + }); + + if (!isNotUniqueID) { + if (typeof post.description !== "string" || post.description.length > 200 || post.description.length < 0) { + return false; + } + + if (typeof(post.author) !== "string") { + return false; + } + + if (!(post.createdAt instanceof Date)) { + return false; + } + + if (typeof(post.photoLink) !== "string") { + return false; + } + + if (!(post.id && post.description && post.createdAt && post.author && post.photoLink)) { + return false; + } + + return true; + } + }, + + addPhotoPost: function (post) { + if (typeof post.createdAt === "string") { + post.createdAt = new Date(post.createdAt); + } + if (ApplicationModule.validatePhotoPost(post)) { + ApplicationModule.photoPosts.push(post); + ApplicationModule.addHashTagsInMapHash(post); + ApplicationModule.writeInTheFilePosts(); + // writeInLocalStoragePhotoPosts(); + return true; + } + return false; + }, + + removePhotoPost: function (id) { + let post = ApplicationModule.getPhotoPost(id); + if (post) { + post.deleted = true; + } + ApplicationModule.writeInTheFilePosts(); + // writeInLocalStoragePhotoPosts(); + return !!post; + }, + + editPost: function (id, post) { + if (post.description && post.description.length > 200) { + return false; + } + + let getTemp = ApplicationModule.getPhotoPost(id); + if(!getTemp) + return null; + if (post.description) { + getTemp.description = post.description; + } + if (post.photoLink) { + getTemp.photoLink = post.photoLink; + } + if (post.hashtags) { + getTemp.hashtags = post.hashtags.slice(); + } + ApplicationModule.writeInTheFilePosts(); + return getTemp; + }, + + fillMapHash: function () { + for (let i = 0; i < ApplicationModule.photoPosts.length; i++) { + ApplicationModule.addHashTagsInMapHash(ApplicationModule.photoPosts[i]); + } + }, + + initializeFromFiles: function(){ + ApplicationModule.photoPosts = JSON.parse(jsonPosts, (key, value) => { + if(key === 'createdAt'){ + return new Date(value); + } + return value; + }) || []; + ApplicationModule.users = JSON.parse(jsonUsers) || []; + }, + writeInTheFilePosts: function(){ + fs.writeFile('./data/posts.json', JSON.stringify(ApplicationModule.photoPosts), (error) => { + if(error){ + console.log("Error"); + } + }); + } + // fillInformation: function(){ + // ApplicationModule.photoPosts = JSON.parse(localStorage.getItem('photoPosts'), (key, value)=>{ + // if(key === 'createdAt'){ + // return new Date(value); + // } + // return value; + // }) || []; + // // we have array of users for authorization + // // ApplicationModule.users = JSON.parse(localStorage.getItem('users')) || []; + // + // ApplicationModule.userAuthorized = JSON.parse(localStorage.getItem('userAuthorized')); + // }, + + // this function has added our posts and users in LocalStorage + // putPostsAnsUsersInLocalStorage(){ + // let str = JSON.stringify(ApplicationModule.photoPosts); + // localStorage.setItem('photoPosts', str); + // localStorage.setItem('users', JSON.stringify(ApplicationModule.users)); + // } + } +}(); +ApplicationModule.initializeFromFiles(); +module.exports = ApplicationModule; diff --git a/server/app.js b/server/app.js new file mode 100644 index 0000000..ee13bc4 --- /dev/null +++ b/server/app.js @@ -0,0 +1,61 @@ +var http = require('http'); +var express = require('express'); +var bodyParser = require('body-parser'); +var app = express(); +var fs = require('fs'); +var path = require('path'); +app.use(bodyParser.json()); + +var AM = require('./ServerApplicationModule'); + +app.get('/getPhotoPost', (req, res) => { + let post = AM.getPhotoPost(req.query.id.toString()); + if (post) { + res.send(post).end(); + } else { + res.send(404).end(); + } +}); + +app.post('/getPhotoPosts', (req, res) => { + let gotPhotoPosts = AM.getPhotoPosts(req.query.skip, req.query.top, req.body); + if(gotPhotoPosts && gotPhotoPosts.length !== 0){ + res.send(gotPhotoPosts).end(); + } else { + res.send(404).end(); + } +}); + +app.post('/addPhotoPost', (req, res)=>{ + let addingPost = req.body; + if(addingPost){ + if(AM.addPhotoPost(addingPost)){ + res.status(200).send(addingPost).end(); + } else { + res.send(404).end(); + } + } else { + res.send(404).end(); + } +}); + +app.put('/editPhotoPost', (req, res) => { + let edittingPost = AM.editPost(req.query.id, req.body); + if(edittingPost){ + res.status(200).send(edittingPost).end(); + } else { + res.send(404).end(); + } +}); + +app.delete('/removePhotoPost', (req, res)=>{ + if(AM.removePhotoPost(req.query.id)){ + res.status(200).send("Post with id " + req.query.id + " is deleted\n"); + } else { + res.send(404).end(); + } +}); + +app.listen(3000, function () { + console.log('Server is running'); +}); \ No newline at end of file diff --git a/server/data/posts.json b/server/data/posts.json new file mode 100644 index 0000000..35eb177 --- /dev/null +++ b/server/data/posts.json @@ -0,0 +1 @@ +[{"id":"1","description":"красота!","createdAt":"2016-02-29T11:02:21.000Z","author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","photoLink":"http://i.artfile.ru/1920x1080_663213_%5Bwww.ArtFile.ru%5D.jpg","hashtags":["природа","пейзаж","1","2","3434123413241323123213123123"],"likes":["aadereiko","taxi","djadka.by"],"deleted":false},{"id":"2","description":"В горах","createdAt":"2016-03-26T12:03:41.000Z","author":"aadereiko","authorPhoto":"./pictures/post/post1/avaOther.png","photoLink":"https://s1.1zoom.ru/big0/81/Russia_Mountains_Lake_469922.jpg","hashtags":["природа","пейзаж","горы"],"likes":["aadereiko","arina"],"deleted":true},{"id":"3","description":"Вода","createdAt":"2018-05-20T21:12:16.666Z","author":"aadereiko","authorPhoto":"./pictures/post/post1/avaOther.png","photoLink":"https://i.ytimg.com/vi/9NKyArdusj8/maxresdefault.jpg","hashtags":["вода","горы"],"likes":["djadka.by"],"deleted":true},{"id":"4","description":"Дерево","createdAt":"2018-05-20T21:12:16.666Z","author":"aadereiko","authorPhoto":"./pictures/post/post1/avaOther.png","photoLink":"http://www.fonstola.ru/download.php?file=201506/1920x1200/fonstola.ru-187130.jpg","hashtags":["дерево","пейзаж"],"likes":["aadereiko","taxi","djadka.by","pipi"],"deleted":false},{"id":"5","description":"Водопад","createdAt":"2018-05-20T21:12:16.667Z","author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","photoLink":"https://s1.1zoom.ru/big3/137/371625-svetik.jpg","hashtags":["водопад","пейзаж"],"likes":["aadereiko","taxi","djadka.by","taxi","remember"],"deleted":false},{"id":"6","description":"На лугу","createdAt":"2018-05-20T21:12:16.667Z","author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","photoLink":"http://desktopwallpapers.org.ua/pic/201211/2560x1600/desktopwallpapers.org.ua-21746.jpg","hashtags":["луг","лужок"],"likes":["aadereiko"],"deleted":false},{"id":"7","description":"Цветы","createdAt":"2018-05-20T21:12:16.667Z","author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","photoLink":"https://s1.1zoom.ru/big0/328/252677-svetik.jpg","hashtags":["цветы"],"likes":["mashinka","autos"],"deleted":false},{"id":"8","description":"Одуванчики","createdAt":"2018-05-20T21:12:16.667Z","author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","photoLink":"https://storge.pic2.me/c/1360x800/981/584872400b299.jpg","hashtags":["Одуваны","Машина"],"likes":["bojenka"],"deleted":false},{"id":"9","description":"F430","createdAt":"2018-05-20T21:12:16.667Z","author":"aadereiko","authorPhoto":"./pictures/post/post1/avaOther.png","photoLink":"http://oboi-na-stol.com/pub/original_images/oboi-na-stol.com-98967-mashiny-ferrari-f430-avto-mashiny-avtomobili.jpg","hashtags":["Ferrari","F430"],"likes":["tachki","chai","ss"],"deleted":false},{"id":"10","description":"Ламборгини","createdAt":"2018-05-20T21:12:16.667Z","author":"cars","authorPhoto":"http://skachat-kartinki.ru/img/picture/Oct/04/417e63b46e74be245aca2a969133b567/4.jpg","photoLink":"https://w-dog.ru/wallpapers/1/4/497672376362454/lamborghini-aventador-lp700-4-avto-superkar-doroga-zelnyj-green-nebo.jpg","hashtags":["Машины"],"likes":["cars","taxi"],"deleted":false},{"id":"11","description":"59","createdAt":"2018-05-20T21:12:16.667Z","author":"cars","authorPhoto":"http://skachat-kartinki.ru/img/picture/Oct/04/417e63b46e74be245aca2a969133b567/4.jpg","photoLink":"http://skachat-kartinki.ru/img/picture/Oct/04/417e63b46e74be245aca2a969133b567/4.jpg","hashtags":["59"],"likes":["aadereiko","taxi","djadka.by","egor"],"deleted":false},{"id":"12","description":"Lamborghini","createdAt":"2018-05-20T21:12:16.667Z","author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","photoLink":"https://autowall.ru/wallpapers/original/29402.jpg","hashtags":["Одуваны","Детки","Lamborghini"],"likes":["pacani","djadka.by"],"deleted":false},{"id":"13","description":"Тренажер","createdAt":"2018-05-20T21:12:16.667Z","author":"aadereiko","authorPhoto":"./pictures/post/post1/avaOther.png","photoLink":"http://lolopepe.kg/wp-content/uploads/2017/08/body_src_1021.jpg","hashtags":["качаться","лето","Одуваны","Детки"],"likes":[],"deleted":false},{"id":"14","description":"Кач","createdAt":"2018-05-20T21:12:16.667Z","author":"trener","authorPhoto":"https://onsport.by/upload/resize_cache/iblock/23a/540_350_187651f930238ae42a94b52b10d934176/23a8370963af42ff33de0d9ef78f6c60.jpg","photoLink":"https://onsport.by/upload/resize_cache/iblock/23a/540_350_187651f930238ae42a94b52b10d934176/23a8370963af42ff33de0d9ef78f6c60.jpg","hashtags":["тренажер"],"likes":["kekochka","life","sport"],"deleted":false},{"id":"15","description":"Зал","createdAt":"2018-05-20T21:12:16.667Z","author":"trener","authorPhoto":"https://onsport.by/upload/resize_cache/iblock/23a/540_350_187651f930238ae42a94b52b10d934176/23a8370963af42ff33de0d9ef78f6c60.jpg","photoLink":"https://onsport.by/upload/resize_cache/iblock/fcf/540_350_187651f930238ae42a94b52b10d934176/fcf7286441ab8fd5ed140c65282a35ec.png","hashtags":["ВЗале","Сидим"],"likes":["brother","syster"],"deleted":false},{"id":"16","description":"crupo7","createdAt":"2018-05-20T21:12:16.667Z","author":"films","authorPhoto":"https://static.kinoafisha.info/k/movie_posters/1920x1080/upload/movie_posters/7/8/9/8143987/804fe6d00e2cfb98841de815d5a3fce0.jpg","photoLink":"https://static.kinoafisha.info/k/movie_posters/1920x1080/upload/movie_posters/7/8/9/8143987/804fe6d00e2cfb98841de815d5a3fce0.jpg","hashtags":["Antonio"],"likes":["aadereiko"],"deleted":false},{"id":"17","description":"Найди меня","createdAt":"2018-05-20T21:12:16.667Z","author":"films","authorPhoto":"https://static.kinoafisha.info/k/movie_posters/1920x1080/upload/movie_posters/7/8/9/8143987/804fe6d00e2cfb98841de815d5a3fce0.jpg","photoLink":"https://www.kinocitymall.ru/images/posters/fdad9ac238d6034e.jpg","hashtags":["Бумажные города"],"likes":["lubov","zhizhn"],"deleted":false},{"id":"18","description":"Без компромиссов","createdAt":"2018-05-20T21:12:16.667Z","author":"films","authorPhoto":"https://static.kinoafisha.info/k/movie_posters/1920x1080/upload/movie_posters/7/8/9/8143987/804fe6d00e2cfb98841de815d5a3fce0.jpg","photoLink":"http://glass-kino.ucoz.ru/_nw/15/46383748.jpg","hashtags":["стэтхем"],"likes":[],"deleted":false},{"id":"19","description":"Смертельная гонка","createdAt":"2018-05-20T21:12:16.667Z","author":"cars","authorPhoto":"http://skachat-kartinki.ru/img/picture/Oct/04/417e63b46e74be245aca2a969133b567/4.jpg","photoLink":"http://hdrezka.me/i/2014/5/6/x3a2391d33a7fry78q63d.jpg","hashtags":["гонка"],"likes":["shmonka","dashka"],"deleted":false},{"id":"20","description":"Лучшее во мне","createdAt":"2018-05-20T21:12:16.667Z","author":"films","authorPhoto":"https://static.kinoafisha.info/k/movie_posters/1920x1080/upload/movie_posters/7/8/9/8143987/804fe6d00e2cfb98841de815d5a3fce0.jpg","photoLink":"https://disput.azstatic.com/uploads/monthly_2017_06/596362.jpg.80fcd483cdbed4a9572f79ce745fd097.jpg","hashtags":["InMe"],"likes":["arts","draws","films"],"deleted":false},{"id":"112312","description":"pipiska","createdAt":"2018-09-23T20:00:00.000Z","author":"Иванов Иван","photoLink":"http://www.vladtime.ru/uploads/posts/2018-01/1515326200_navalnyi-o-alishere-usmanove-mitingah-i-kirille-serebrennikove.jpg","hashtags":["2017","Kostyak"],"likes":["Иванов Иван"],"isDelete":false,"deleted":true},{"id":"112312","description":"pipi","createdAt":"2018-09-23T20:00:00.000Z","author":"Иванов Иван","photoLink":"http://www.vladtime.ru/uploads/posts/2018-01/1515326200_navalnyi-o-alishere-usmanove-mitingah-i-kirille-serebrennikove.jpg","hashtags":["2017","Kostyak"],"likes":["Иванов Иван"],"isDelete":false},{"id":"112312","description":"pipiskadriska","createdAt":"2018-09-23T20:00:00.000Z","author":"Иванов Иван","photoLink":"http://www.vladtime.ru/uploads/posts/2018-01/1515326200_navalnyi-o-alishere-usmanove-mitingah-i-kirille-serebrennikove.jpg","hashtags":["2017","Kostyak"],"likes":["Иванов Иван"],"isDelete":false},{"id":"112312","description":"lolkakekochka","createdAt":"2018-09-23T20:00:00.000Z","author":"Иванов Иван","photoLink":"http://www.vladtime.ru/uploads/posts/2018-01/1515326200_navalnyi-o-alishere-usmanove-mitingah-i-kirille-serebrennikove.jpg","hashtags":["2017","Kostyak"],"likes":["Иванов Иван"],"isDelete":false},{"id":"1122","description":"EditedSasha","createdAt":"2018-09-23T20:00:00.000Z","author":"aadereiko","photoLink":"https://i.ytimg.com/vi/AorT6fmFkHs/maxresdefault.jpg","hashtags":["2017","Kostyak"],"likes":["Kek"],"deleted":true},{"id":"1122","description":"Sasha","createdAt":"2018-09-23T20:00:00.000Z","author":"aadereiko","photoLink":"https://i.ytimg.com/vi/AorT6fmFkHs/maxresdefault.jpg","hashtags":["2017","Kostyak"],"likes":["Kek"],"deleted":false}] \ No newline at end of file diff --git a/server/data/users.json b/server/data/users.json new file mode 100644 index 0000000..a629460 --- /dev/null +++ b/server/data/users.json @@ -0,0 +1 @@ +[{"author":"Djadka.by","authorPhoto":"./pictures/menu/mainPhoto.png","password":"12345678"},{"author":"cars","authorPhoto":"http://skachat-kartinki.ru/img/picture/Oct/04/417e63b46e74be245aca2a969133b567/4.jpg","password":"12345"},{"author":"aadereiko","authorPhoto":"./pictures/post/post1/avaOther.png","password":"90a12345"},{"author":"films","authorPhoto":"https://im0-tub-by.yandex.net/i?id=3979f00131c7422720695dcb01d2dce2&n=13","password":"90a12"}] \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json new file mode 100644 index 0000000..f487064 --- /dev/null +++ b/server/package-lock.json @@ -0,0 +1,369 @@ +{ + "name": "public", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "2.1.18", + "negotiator": "0.6.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "1.6.16" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": "2.1.2" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + } + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", + "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", + "requires": { + "accepts": "1.3.5", + "array-flatten": "1.1.1", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.2", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.3", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "1.4.0", + "type-is": "1.6.16", + "utils-merge": "1.0.1", + "vary": "1.1.2" + } + }, + "express-package-json": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/express-package-json/-/express-package-json-1.0.2.tgz", + "integrity": "sha1-26aiwgee55z6mhxWgJexVwZLmUw=" + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.4.0", + "unpipe": "1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": "1.4.0" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", + "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + }, + "mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "requires": { + "mime-db": "1.33.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.3.tgz", + "integrity": "sha512-jQTChiCJteusULxjBp8+jftSQE5Obdl3k4cnmLA6WXtK6XFuWRnvVL7aCiBqaLPM8c4ph0S4tKna8XvmIwEnXQ==", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.6.0" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.2", + "destroy": "1.0.4", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.3", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.4.0" + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.18" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + } + } +} diff --git a/server/package.json b/server/package.json new file mode 100644 index 0000000..69c46bf --- /dev/null +++ b/server/package.json @@ -0,0 +1,17 @@ +{ + "name": "public", + "version": "1.0.0", + "description": "", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "body-parser": "^1.18.3", + "express": "^4.16.3", + "express-package-json": "^1.0.2" + } +} diff --git a/task8withScreensAndJSON/AddPhotoPost.jpg b/task8withScreensAndJSON/AddPhotoPost.jpg new file mode 100644 index 0000000..9c76215 Binary files /dev/null and b/task8withScreensAndJSON/AddPhotoPost.jpg differ diff --git a/task8withScreensAndJSON/EditPhotoPost.jpg b/task8withScreensAndJSON/EditPhotoPost.jpg new file mode 100644 index 0000000..0f668e3 Binary files /dev/null and b/task8withScreensAndJSON/EditPhotoPost.jpg differ diff --git a/task8withScreensAndJSON/GetPhotoPost.jpg b/task8withScreensAndJSON/GetPhotoPost.jpg new file mode 100644 index 0000000..c0875b9 Binary files /dev/null and b/task8withScreensAndJSON/GetPhotoPost.jpg differ diff --git a/task8withScreensAndJSON/getPhotoPosts.jpg b/task8withScreensAndJSON/getPhotoPosts.jpg new file mode 100644 index 0000000..ff6c029 Binary files /dev/null and b/task8withScreensAndJSON/getPhotoPosts.jpg differ diff --git a/task8withScreensAndJSON/lab8Collection.json b/task8withScreensAndJSON/lab8Collection.json new file mode 100644 index 0000000..b3a9320 --- /dev/null +++ b/task8withScreensAndJSON/lab8Collection.json @@ -0,0 +1,320 @@ +{ + "info": { + "_postman_id": "480f13b8-7f28-4c14-b2f9-6353c31c7863", + "name": "lab8", + "description": "lab8", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "AddPhotoPost true", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"id\": \"1122\",\r\n \"description\": \"Sasha\",\r\n \"createdAt\": \"2018-09-23T23:00:00\",\r\n \"author\": \"aadereiko\",\r\n \"photoLink\": \"https://i.ytimg.com/vi/AorT6fmFkHs/maxresdefault.jpg\",\r\n \"hashtags\": [\"2017\", \"Kostyak\"],\r\n \"likes\": [\"Kek\"],\r\n \"deleted\": false\r\n }" + }, + "url": { + "raw": "localhost:3000/addPhotoPost", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "addPhotoPost" + ] + } + }, + "response": [] + }, + { + "name": "AddPhotoPostError", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"id\": \"1122\",\n \"description\": \"Sasha\",\n \"createdAt\": \"2018-09-23T20:00:00.000Z\",\n \"photoLink\": \"https://i.ytimg.com/vi/AorT6fmFkHs/maxresdefault.jpg\",\n \"hashtags\": [\n \"2017\",\n \"Kostyak\"\n ],\n \"likes\": [\n \"Kek\"\n ],\n \"deleted\": false\n}" + }, + "url": { + "raw": "localhost:3000/addPhotoPost", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "addPhotoPost" + ] + } + }, + "response": [] + }, + { + "name": "getPhotoPost true", + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "localhost:3000/getPhotoPost?id=1", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "getPhotoPost" + ], + "query": [ + { + "key": "id", + "value": "1" + } + ] + } + }, + "response": [] + }, + { + "name": "getPhotoPost Error", + "request": { + "method": "GET", + "header": [], + "body": {}, + "url": { + "raw": "localhost:3000/getPhotoPost?id=312371283912798", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "getPhotoPost" + ], + "query": [ + { + "key": "id", + "value": "312371283912798" + } + ] + } + }, + "response": [] + }, + { + "name": "getPhotoPosts True", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"author\": \"Djadka.by\"\n}" + }, + "url": { + "raw": "localhost:3000/getPhotoPosts?skip=0&top=12", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "getPhotoPosts" + ], + "query": [ + { + "key": "skip", + "value": "0" + }, + { + "key": "top", + "value": "12" + } + ] + } + }, + "response": [] + }, + { + "name": "getPhotoPosts Error", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"author\": \"xml\"\n}" + }, + "url": { + "raw": "localhost:3000/getPhotoPosts?skip=0&top=12", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "getPhotoPosts" + ], + "query": [ + { + "key": "skip", + "value": "0" + }, + { + "key": "top", + "value": "12" + } + ] + } + }, + "response": [] + }, + { + "name": "editPhotoPost true", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"description\": \"EditedSasha\"\r\n }" + }, + "url": { + "raw": "localhost:3000/editPhotoPost?id=1122", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "editPhotoPost" + ], + "query": [ + { + "key": "id", + "value": "1122" + } + ] + } + }, + "response": [] + }, + { + "name": "editPhotoPost Error", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"description\": \"EditedSasha\"\r\n }" + }, + "url": { + "raw": "localhost:3000/editPhotoPost?id=11223123126378", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "editPhotoPost" + ], + "query": [ + { + "key": "id", + "value": "11223123126378" + } + ] + } + }, + "response": [] + }, + { + "name": "removePhotoPost true", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"description\": \"EditedSasha\"\r\n }" + }, + "url": { + "raw": "localhost:3000/removePhotoPost?id=1122", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "removePhotoPost" + ], + "query": [ + { + "key": "id", + "value": "1122" + } + ] + } + }, + "response": [] + }, + { + "name": "removePhotoPost Error", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"description\": \"EditedSasha\"\r\n }" + }, + "url": { + "raw": "localhost:3000/removePhotoPost?id=112241324123", + "host": [ + "localhost" + ], + "port": "3000", + "path": [ + "removePhotoPost" + ], + "query": [ + { + "key": "id", + "value": "112241324123" + } + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/task8withScreensAndJSON/removePhotoPost.jpg b/task8withScreensAndJSON/removePhotoPost.jpg new file mode 100644 index 0000000..d5aa541 Binary files /dev/null and b/task8withScreensAndJSON/removePhotoPost.jpg differ