From e5aa506c5a166ca069329436a5e827f4bad0150b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 5 Aug 2020 01:50:34 -0600 Subject: [PATCH 1/3] Update Hashtag.vue, add nsfw toggle. Fixes #2225 --- .../Api/StatusHashtagTransformer.php | 2 +- resources/assets/js/components/Hashtag.vue | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/Transformer/Api/StatusHashtagTransformer.php b/app/Transformer/Api/StatusHashtagTransformer.php index 1dfdba3b..f5a8d79e 100644 --- a/app/Transformer/Api/StatusHashtagTransformer.php +++ b/app/Transformer/Api/StatusHashtagTransformer.php @@ -18,7 +18,7 @@ class StatusHashtagTransformer extends Fractal\TransformerAbstract 'id' => (int) $status->id, 'type' => $status->type, 'url' => $status->url(), - 'thumb' => $status->thumb(), + 'thumb' => $status->thumb(true), 'filter' => $status->firstMedia()->filter_class, 'sensitive' => (bool) $status->is_nsfw, 'like_count' => $status->likes_count, diff --git a/resources/assets/js/components/Hashtag.vue b/resources/assets/js/components/Hashtag.vue index 89719331..e737859b 100644 --- a/resources/assets/js/components/Hashtag.vue +++ b/resources/assets/js/components/Hashtag.vue @@ -4,7 +4,7 @@
-
#
+
#
@@ -12,14 +12,20 @@

#{{hashtag}}

{{tags.length ? hashtagCount : '0'}} posts

-

- - -

+
+

+ + +

+
+ + +
+
@@ -30,7 +36,8 @@
-
+
+
@@ -50,7 +57,8 @@
-
+
+
@@ -105,6 +113,7 @@ following: false, tags: [], top: [], + forceNsfw: false, } }, beforeMount() { From 7150bda37afd0ba72a7a619744582524e754edc9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 5 Aug 2020 01:51:39 -0600 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50756640..d7864560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ - Updated PostComponent.vue, improve MetroUI and fixes ([#2363](https://github.com/pixelfed/pixelfed/issues/2363)). ([0c8ebf26](https://github.com/pixelfed/pixelfed/commit/0c8ebf26)) - Updated Timeline.vue, fixes ([#2363](https://github.com/pixelfed/pixelfed/issues/2363)). ([f53f10fd](https://github.com/pixelfed/pixelfed/commit/f53f10fd)) - Updated Profile.vue, add atom feed link to context menu. Fixes ([#2313](https://github.com/pixelfed/pixelfed/issues/2313)). ([89f29072](https://github.com/pixelfed/pixelfed/commit/89f29072)) +- Update Hashtag.vue, add nsfw toggle. Fixes ([#2225](https://github.com/pixelfed/pixelfed/issues/2225)). ([e5aa506c](https://github.com/pixelfed/pixelfed/commit/e5aa506c)) ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9) ### Added From cdc06aca4fb57ee761a0f122d48197d7d9454ca7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 5 Aug 2020 01:52:28 -0600 Subject: [PATCH 3/3] Update compiled assets --- public/js/hashtag.js | 2 +- public/mix-manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/hashtag.js b/public/js/hashtag.js index 1ba73386..73ba54ec 100644 --- a/public/js/hashtag.js +++ b/public/js/hashtag.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{16:function(t,e,n){t.exports=n("gqTO")},"9tPo":function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,s=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var a,r=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(r)?t:(a=0===r.indexOf("//")?r:0===r.indexOf("/")?n+r:s+r.replace(/^\.\//,""),"url("+JSON.stringify(a)+")")}))}},HVjR:function(t,e,n){(t.exports=n("I1BE")(!1)).push([t.i,"\n.tag-header[data-v-7f9b7575] {\n\tfont-size: 28px;\n\tfont-weight: 300;\n}\n",""])},I1BE:function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",s=t[3];if(!s)return n;if(e&&"function"==typeof btoa){var a=(o=s,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),r=s.sources.map((function(t){return"/*# sourceURL="+s.sourceRoot+t+" */"}));return[n].concat(r).concat([a]).join("\n")}var o;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var s={},a=0;a(this.authenticated?29:10)?t.complete():axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(n){var a=n.data;if(a.tags.length){var r,o=a.tags.filter((function(t){return!(!t||0==t.length)}));if((r=e.tags).push.apply(r,s(o)),o.length>9)return void t.complete();e.page++,t.loaded()}else t.complete()}))},followHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(e){t.following=!0}))},unfollowHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(e){t.following=!1}))}}},r=(n("ncWY"),n("KHd+")),o=Object(r.a)(a,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t.loaded?n("div",{staticClass:"container"},[n("div",{staticClass:"profile-header row my-5"},[t._m(0),t._v(" "),n("div",{staticClass:"col-12 col-md-9 d-flex align-items-center"},[n("div",{staticClass:"profile-details"},[n("div",{staticClass:"username-bar pb-2"},[n("p",{staticClass:"tag-header mb-0"},[t._v("#"+t._s(t.hashtag))]),t._v(" "),n("p",{staticClass:"lead"},[n("span",{staticClass:"font-weight-bold"},[t._v(t._s(t.tags.length?t.hashtagCount:"0"))]),t._v(" posts")]),t._v(" "),t.authenticated&&t.tags.length?n("p",{staticClass:"pt-3"},[t.following?n("button",{staticClass:"btn btn-outline-secondary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.unfollowHashtag}},[t._v("\n\t\t\t\t\t\t\t\tUnfollow\n\t\t\t\t\t\t\t")]):n("button",{staticClass:"btn btn-primary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.followHashtag}},[t._v("\n\t\t\t\t\t\t\t\tFollow\n\t\t\t\t\t\t\t")])]):t._e()])])])]),t._v(" "),t.tags.length?n("div",{staticClass:"tag-timeline"},[t.top.length?n("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Top Posts")]):t._e(),t._v(" "),n("div",{staticClass:"row pb-5"},t._l(t.top,(function(e,s){return n("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[n("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[n("div",{staticClass:"square-content",style:"background-image: url("+e.status.thumb+")"}),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",{staticClass:"pr-4"},[n("span",{staticClass:"far fa-heart fa-lg pr-1"}),t._v(" "+t._s(e.status.like_count)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),n("span",[n("span",{staticClass:"fas fa-retweet fa-lg pr-1"}),t._v(" "+t._s(e.status.share_count)+"\n\t\t\t\t\t\t\t\t\t")])])])])])])})),0),t._v(" "),n("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Most Recent")]),t._v(" "),n("div",{staticClass:"row"},[t._l(t.tags,(function(e,s){return n("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[n("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[n("div",{staticClass:"square-content",style:"background-image: url("+e.status.thumb+")"}),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",{staticClass:"pr-4"},[n("span",{staticClass:"far fa-heart fa-lg pr-1"}),t._v(" "+t._s(e.status.like_count)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),n("span",[n("span",{staticClass:"fas fa-retweet fa-lg pr-1"}),t._v(" "+t._s(e.status.share_count)+"\n\t\t\t\t\t\t\t\t\t")])])])])])])})),t._v(" "),t.tags.length&&t.loaded?n("div",{staticClass:"card card-body text-center shadow-none bg-transparent border-0"},[n("infinite-loading",{on:{infinite:t.infiniteLoader}},[n("div",{staticClass:"font-weight-bold",attrs:{slot:"no-results"},slot:"no-results"}),t._v(" "),n("div",{staticClass:"font-weight-bold",attrs:{slot:"no-more"},slot:"no-more"})])],1):t._e()],2)]):n("div",[n("p",{staticClass:"text-center lead font-weight-bold"},[t._v("No public posts found.")])])]):n("div",{staticClass:"container text-center"},[t._m(1)])])}),[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"col-12 col-md-3"},[e("div",{staticClass:"profile-avatar"},[e("div",{staticClass:"bg-pixelfed mb-3 d-flex align-items-center justify-content-center display-4 font-weight-bold text-white",staticStyle:{width:"172px",height:"172px","border-radius":"100%"}},[this._v("#")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"mt-5 spinner-border",attrs:{role:"status"}},[e("span",{staticClass:"sr-only"},[this._v("Loading...")])])}],!1,null,"7f9b7575",null);e.default=o.exports},"aET+":function(t,e,n){var s,a,r={},o=(s=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===a&&(a=s.apply(this,arguments)),a}),i=function(t,e){return e?e.querySelector(t):document.querySelector(t)},l=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var s=i.call(this,t,n);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}}(),c=null,u=0,f=[],d=n("9tPo");function p(t,e){for(var n=0;n=0&&f.splice(e,1)}function b(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var s=function(){0;return n.nc}();s&&(t.attrs.nonce=s)}return m(e,t.attrs),v(t,e),e}function m(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function y(t,e){var n,s,a,r;if(e.transform&&t.css){if(!(r="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=r}if(e.singleton){var o=u++;n=c||(c=b(e)),s=_.bind(null,n,o,!1),a=_.bind(null,n,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",m(e,t.attrs),v(t,e),e}(e),s=R.bind(null,n,e),a=function(){g(n),n.href&&URL.revokeObjectURL(n.href)}):(n=b(e),s=x.bind(null,n),a=function(){g(n)});return s(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;s(t=e)}else a()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=h(t,e);return p(n,e),function(t){for(var s=[],a=0;a(this.authenticated?29:10)?t.complete():axios.get("/api/v2/discover/tag",{params:{hashtag:this.hashtag,page:this.page}}).then((function(n){var a=n.data;if(a.tags.length){var r,o=a.tags.filter((function(t){return!(!t||0==t.length)}));if((r=e.tags).push.apply(r,s(o)),o.length>9)return void t.complete();e.page++,t.loaded()}else t.complete()}))},followHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(e){t.following=!0}))},unfollowHashtag:function(){var t=this;axios.post("/api/local/discover/tag/subscribe",{name:this.hashtag}).then((function(e){t.following=!1}))}}},r=(n("mXeM"),n("KHd+")),o=Object(r.a)(a,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[t.loaded?n("div",{staticClass:"container"},[n("div",{staticClass:"profile-header row my-5"},[t._m(0),t._v(" "),n("div",{staticClass:"col-12 col-md-9 d-flex align-items-center"},[n("div",{staticClass:"profile-details"},[n("div",{staticClass:"username-bar pb-2"},[n("p",{staticClass:"tag-header mb-0"},[t._v("#"+t._s(t.hashtag))]),t._v(" "),n("p",{staticClass:"lead"},[n("span",{staticClass:"font-weight-bold"},[t._v(t._s(t.tags.length?t.hashtagCount:"0"))]),t._v(" posts")]),t._v(" "),n("div",{staticClass:"d-flex justify-content-between align-items-center"},[t.authenticated&&t.tags.length?n("p",{staticClass:"pt-3 mr-4"},[t.following?n("button",{staticClass:"btn btn-outline-secondary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.unfollowHashtag}},[t._v("\n\t\t\t\t\t\t\t\t\tUnfollow\n\t\t\t\t\t\t\t\t")]):n("button",{staticClass:"btn btn-primary font-weight-bold py-1 px-5",attrs:{type:"button"},on:{click:t.followHashtag}},[t._v("\n\t\t\t\t\t\t\t\t\tFollow\n\t\t\t\t\t\t\t\t")])]):t._e(),t._v(" "),n("div",{staticClass:"custom-control custom-switch"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.forceNsfw,expression:"forceNsfw"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"nsfwSwitch"},domProps:{checked:Array.isArray(t.forceNsfw)?t._i(t.forceNsfw,null)>-1:t.forceNsfw},on:{change:function(e){var n=t.forceNsfw,s=e.target,a=!!s.checked;if(Array.isArray(n)){var r=t._i(n,null);s.checked?r<0&&(t.forceNsfw=n.concat([null])):r>-1&&(t.forceNsfw=n.slice(0,r).concat(n.slice(r+1)))}else t.forceNsfw=a}}}),t._v(" "),n("label",{staticClass:"custom-control-label font-weight-bold text-muted",attrs:{for:"nsfwSwitch"}},[t._v("Show NSFW Content")])])])])])])]),t._v(" "),t.tags.length?n("div",{staticClass:"tag-timeline"},[t.top.length?n("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Top Posts")]):t._e(),t._v(" "),n("div",{staticClass:"row pb-5"},t._l(t.top,(function(e,s){return n("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[n("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[e.status.sensitive&&0==t.forceNsfw?n("div",{staticClass:"square-content",style:"background-image: url(/storage/no-preview.png)"}):n("div",{staticClass:"square-content",style:"background-image: url("+e.status.thumb+")"}),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",{staticClass:"pr-4"},[n("span",{staticClass:"far fa-heart fa-lg pr-1"}),t._v(" "+t._s(e.status.like_count)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),n("span",[n("span",{staticClass:"fas fa-retweet fa-lg pr-1"}),t._v(" "+t._s(e.status.share_count)+"\n\t\t\t\t\t\t\t\t\t")])])])])])])})),0),t._v(" "),n("p",{staticClass:"font-weight-bold text-muted mb-0"},[t._v("Most Recent")]),t._v(" "),n("div",{staticClass:"row"},[t._l(t.tags,(function(e,s){return n("div",{staticClass:"col-4 p-0 p-sm-2 p-md-3 hashtag-post-square"},[n("a",{staticClass:"card info-overlay card-md-border-0",attrs:{href:e.status.url}},[n("div",{class:[e.status.filter?"square "+e.status.filter:"square"]},[e.status.sensitive&&0==t.forceNsfw?n("div",{staticClass:"square-content",style:"background-image: url(/storage/no-preview.png)"}):n("div",{staticClass:"square-content",style:"background-image: url("+e.status.thumb+")"}),t._v(" "),n("div",{staticClass:"info-overlay-text"},[n("h5",{staticClass:"text-white m-auto font-weight-bold"},[n("span",{staticClass:"pr-4"},[n("span",{staticClass:"far fa-heart fa-lg pr-1"}),t._v(" "+t._s(e.status.like_count)+"\n\t\t\t\t\t\t\t\t\t")]),t._v(" "),n("span",[n("span",{staticClass:"fas fa-retweet fa-lg pr-1"}),t._v(" "+t._s(e.status.share_count)+"\n\t\t\t\t\t\t\t\t\t")])])])])])])})),t._v(" "),t.tags.length&&t.loaded?n("div",{staticClass:"card card-body text-center shadow-none bg-transparent border-0"},[n("infinite-loading",{on:{infinite:t.infiniteLoader}},[n("div",{staticClass:"font-weight-bold",attrs:{slot:"no-results"},slot:"no-results"}),t._v(" "),n("div",{staticClass:"font-weight-bold",attrs:{slot:"no-more"},slot:"no-more"})])],1):t._e()],2)]):n("div",[n("p",{staticClass:"text-center lead font-weight-bold"},[t._v("No public posts found.")])])]):n("div",{staticClass:"container text-center"},[t._m(1)])])}),[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"col-12 col-md-3"},[e("div",{staticClass:"profile-avatar"},[e("div",{staticClass:"bg-primary mb-3 d-flex align-items-center justify-content-center display-4 font-weight-bold text-white",staticStyle:{width:"172px",height:"172px","border-radius":"100%"}},[this._v("#")])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"mt-5 spinner-border",attrs:{role:"status"}},[e("span",{staticClass:"sr-only"},[this._v("Loading...")])])}],!1,null,"0b5bf014",null);e.default=o.exports},W8EH:function(t,e,n){var s=n("ou/g");"string"==typeof s&&(s=[[t.i,s,""]]);var a={hmr:!0,transform:void 0,insertInto:void 0};n("aET+")(s,a);s.locals&&(t.exports=s.locals)},"aET+":function(t,e,n){var s,a,r={},o=(s=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===a&&(a=s.apply(this,arguments)),a}),i=function(t,e){return e?e.querySelector(t):document.querySelector(t)},c=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var s=i.call(this,t,n);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}}(),l=null,f=0,u=[],d=n("9tPo");function p(t,e){for(var n=0;n=0&&u.splice(e,1)}function m(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var s=function(){0;return n.nc}();s&&(t.attrs.nonce=s)}return b(e,t.attrs),v(t,e),e}function b(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function w(t,e){var n,s,a,r;if(e.transform&&t.css){if(!(r="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=r}if(e.singleton){var o=f++;n=l||(l=m(e)),s=_.bind(null,n,o,!1),a=_.bind(null,n,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",b(e,t.attrs),v(t,e),e}(e),s=E.bind(null,n,e),a=function(){g(n),n.href&&URL.revokeObjectURL(n.href)}):(n=m(e),s=x.bind(null,n),a=function(){g(n)});return s(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;s(t=e)}else a()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=h(t,e);return p(n,e),function(t){for(var s=[],a=0;a