From e824f5ebf70131997e3177638a323d210be8a14a Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 3 Oct 2015 16:51:29 +0930 Subject: [PATCH 1/2] Update for composer branch --- extensions/tags/bootstrap.php | 18 ++++++++-- extensions/tags/composer.json | 25 +++++++++++-- extensions/tags/flarum.json | 25 ------------- ...4_000000_create_discussions_tags_table.php | 2 +- .../2015_02_24_000000_create_tags_table.php | 2 +- ...5_02_24_000000_create_users_tags_table.php | 2 +- ...2015_02_24_000000_set_default_settings.php | 2 +- extensions/tags/src/Extension.php | 35 ------------------- 8 files changed, 42 insertions(+), 69 deletions(-) delete mode 100644 extensions/tags/flarum.json delete mode 100644 extensions/tags/src/Extension.php diff --git a/extensions/tags/bootstrap.php b/extensions/tags/bootstrap.php index 36cbb94e5..4e5fadac0 100644 --- a/extensions/tags/bootstrap.php +++ b/extensions/tags/bootstrap.php @@ -9,6 +9,20 @@ * file that was distributed with this source code. */ -require __DIR__.'/vendor/autoload.php'; +use Flarum\Core\Application; -return 'Flarum\Tags\Extension'; +return function (Application $app) { + Flarum\Tags\Tag::setValidator($app->make('validator')); + + $events = $app->make('events'); + + $events->subscribe('Flarum\Tags\Listeners\AddClientAssets'); + $events->subscribe('Flarum\Tags\Listeners\AddModelRelationship'); + $events->subscribe('Flarum\Tags\Listeners\ConfigureDiscussionPermissions'); + $events->subscribe('Flarum\Tags\Listeners\ConfigureTagPermissions'); + $events->subscribe('Flarum\Tags\Listeners\AddApiAttributes'); + $events->subscribe('Flarum\Tags\Listeners\PersistData'); + $events->subscribe('Flarum\Tags\Listeners\LogDiscussionTagged'); + $events->subscribe('Flarum\Tags\Listeners\UpdateTagMetadata'); + $events->subscribe('Flarum\Tags\Listeners\AddTagGambit'); +}; diff --git a/extensions/tags/composer.json b/extensions/tags/composer.json index cb1c4db8c..221dc7fc4 100644 --- a/extensions/tags/composer.json +++ b/extensions/tags/composer.json @@ -1,10 +1,29 @@ { + "name": "flarum/tags", + "type": "flarum-extension", + "description": "Organise discussions into a heirarchy of tags and categories.", "autoload": { "psr-4": { "Flarum\\Tags\\": "src/" } }, - "scripts": { - "style": "phpcs --standard=PSR2 -np src" - } + "require": { + "composer/installers": "dev-master" + }, + "extra": { + "flarum-extension": { + "title": "Tags", + "icon": { + "name": "tags", + "backgroundColor": "#F28326", + "color": "#fff" + } + } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/tobscure/installers" + } + ] } diff --git a/extensions/tags/flarum.json b/extensions/tags/flarum.json deleted file mode 100644 index 56fe6f120..000000000 --- a/extensions/tags/flarum.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "tags", - "title": "Tags", - "description": "Organise discussions into a heirarchy of tags and categories.", - "keywords": ["discussions"], - "version": "0.1.0-beta.2", - "author": { - "name": "Toby Zerner", - "email": "toby@flarum.org", - "homepage": "http://tobyzerner.com" - }, - "license": "MIT", - "require": { - "flarum": ">=0.1.0-beta.2" - }, - "support": { - "source": "https://github.com/flarum/tags", - "issues": "https://github.com/flarum/core/issues" - }, - "icon": { - "name": "tags", - "backgroundColor": "#F28326", - "color": "#fff" - } -} diff --git a/extensions/tags/migrations/2015_02_24_000000_create_discussions_tags_table.php b/extensions/tags/migrations/2015_02_24_000000_create_discussions_tags_table.php index 6b6669a04..1b7f6f16a 100644 --- a/extensions/tags/migrations/2015_02_24_000000_create_discussions_tags_table.php +++ b/extensions/tags/migrations/2015_02_24_000000_create_discussions_tags_table.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Migrations\Tags; +namespace Flarum\Tags\Migrations; use Illuminate\Database\Schema\Blueprint; use Flarum\Migrations\Migration; diff --git a/extensions/tags/migrations/2015_02_24_000000_create_tags_table.php b/extensions/tags/migrations/2015_02_24_000000_create_tags_table.php index efcbd6c1c..a44b7482c 100644 --- a/extensions/tags/migrations/2015_02_24_000000_create_tags_table.php +++ b/extensions/tags/migrations/2015_02_24_000000_create_tags_table.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Migrations\Tags; +namespace Flarum\Tags\Migrations; use Illuminate\Database\Schema\Blueprint; use Flarum\Migrations\Migration; diff --git a/extensions/tags/migrations/2015_02_24_000000_create_users_tags_table.php b/extensions/tags/migrations/2015_02_24_000000_create_users_tags_table.php index b6159317c..34182f186 100644 --- a/extensions/tags/migrations/2015_02_24_000000_create_users_tags_table.php +++ b/extensions/tags/migrations/2015_02_24_000000_create_users_tags_table.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Migrations\Tags; +namespace Flarum\Tags\Migrations; use Illuminate\Database\Schema\Blueprint; use Flarum\Migrations\Migration; diff --git a/extensions/tags/migrations/2015_02_24_000000_set_default_settings.php b/extensions/tags/migrations/2015_02_24_000000_set_default_settings.php index 9ee45b1cd..6737d8252 100644 --- a/extensions/tags/migrations/2015_02_24_000000_set_default_settings.php +++ b/extensions/tags/migrations/2015_02_24_000000_set_default_settings.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Flarum\Migrations\Tags; +namespace Flarum\Tags\Migrations; use Flarum\Migrations\Migration; diff --git a/extensions/tags/src/Extension.php b/extensions/tags/src/Extension.php deleted file mode 100644 index 38217a1ef..000000000 --- a/extensions/tags/src/Extension.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Tags; - -use Flarum\Support\Extension as BaseExtension; -use Illuminate\Events\Dispatcher; - -class Extension extends BaseExtension -{ - public function listen(Dispatcher $events) - { - $events->subscribe('Flarum\Tags\Listeners\AddClientAssets'); - $events->subscribe('Flarum\Tags\Listeners\AddModelRelationship'); - $events->subscribe('Flarum\Tags\Listeners\ConfigureDiscussionPermissions'); - $events->subscribe('Flarum\Tags\Listeners\ConfigureTagPermissions'); - $events->subscribe('Flarum\Tags\Listeners\AddApiAttributes'); - $events->subscribe('Flarum\Tags\Listeners\PersistData'); - $events->subscribe('Flarum\Tags\Listeners\LogDiscussionTagged'); - $events->subscribe('Flarum\Tags\Listeners\UpdateTagMetadata'); - $events->subscribe('Flarum\Tags\Listeners\AddTagGambit'); - } - - public function boot() - { - Tag::setValidator($this->app->make('validator')); - } -} From 0f57f276853d0a3ba8d2a1a9131fed82183ce6e8 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 3 Oct 2015 16:51:49 +0930 Subject: [PATCH 2/2] Add compiled scripts --- extensions/tags/js/.gitignore | 1 - extensions/tags/js/admin/dist/extension.js | 1 + extensions/tags/js/forum/dist/extension.js | 1 + extensions/tags/scripts/compile.sh | 27 ++++++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 extensions/tags/js/admin/dist/extension.js create mode 100644 extensions/tags/js/forum/dist/extension.js create mode 100755 extensions/tags/scripts/compile.sh diff --git a/extensions/tags/js/.gitignore b/extensions/tags/js/.gitignore index 372e20a51..7bf6eb18f 100644 --- a/extensions/tags/js/.gitignore +++ b/extensions/tags/js/.gitignore @@ -1,3 +1,2 @@ bower_components node_modules -dist diff --git a/extensions/tags/js/admin/dist/extension.js b/extensions/tags/js/admin/dist/extension.js new file mode 100644 index 000000000..a7e90d542 --- /dev/null +++ b/extensions/tags/js/admin/dist/extension.js @@ -0,0 +1 @@ +!function(t,e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):t.sortable=e(t.jQuery)}(this,function(t){"use strict";var e,n,a=t(),r=[],o=function(t){t.off("dragstart.h5s"),t.off("dragend.h5s"),t.off("selectstart.h5s"),t.off("dragover.h5s"),t.off("dragenter.h5s"),t.off("drop.h5s")},i=function(t){t.off("dragover.h5s"),t.off("dragenter.h5s"),t.off("drop.h5s")},s=function(t,e){t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text",""),t.dataTransfer.setDragImage&&t.dataTransfer.setDragImage(e.item,e.x,e.y)},u=function(t,e){return e.x||(e.x=parseInt(t.pageX-e.draggedItem.offset().left)),e.y||(e.y=parseInt(t.pageY-e.draggedItem.offset().top)),e},l=function(t){return{item:t[0],draggedItem:t}},c=function(t,e){var n=l(e);n=u(t,n),s(t,n)},d=function(t,e){return"undefined"==typeof t?e:t},f=function(t){t.removeData("opts"),t.removeData("connectWith"),t.removeData("items"),t.removeAttr("aria-dropeffect")},m=function(t){t.removeAttr("aria-grabbed"),t.removeAttr("draggable"),t.removeAttr("role")},p=function(t,e){return t[0]===e[0]?!0:void 0!==t.data("connectWith")?t.data("connectWith")===e.data("connectWith"):!1},g=function(t){var e=t.data("opts")||{},n=t.children(e.items),a=e.handle?n.find(e.handle):n;i(t),f(t),a.off("mousedown.h5s"),o(n),m(n)},h=function(e){var n=e.data("opts"),a=e.children(n.items),r=n.handle?a.find(n.handle):a;e.attr("aria-dropeffect","move"),r.attr("draggable","true"),"function"!=typeof document.createElement("span").dragDrop||n.disableIEFix||r.on("mousedown.h5s",function(){-1!==a.index(this)?this.dragDrop():t(this).parents(n.items)[0].dragDrop()})},v=function(t){var e=t.data("opts"),n=t.children(e.items),a=e.handle?n.find(e.handle):n;t.attr("aria-dropeffect","none"),a.attr("draggable",!1),a.off("mousedown.h5s")},b=function(t){var e=t.data("opts"),n=t.children(e.items),a=e.handle?n.find(e.handle):n;o(n),a.off("mousedown.h5s"),i(t)},y=function(o,i){var u=t(o),l=String(i);return i=t.extend({connectWith:!1,placeholder:null,dragImage:null,disableIEFix:!1,placeholderClass:"sortable-placeholder",draggingClass:"sortable-dragging"},i),u.each(function(){var o=t(this);if(/enable|disable|destroy/.test(l))return void y[l](o);i=d(o.data("opts"),i),o.data("opts",i),b(o);var u,f,m,g=o.children(i.items),v=null===i.placeholder?t("<"+(/^ul|ol$/i.test(this.tagName)?"li":"div")+' class="'+i.placeholderClass+'"/>'):t(i.placeholder).addClass(i.placeholderClass);if(!o.attr("data-sortable-id")){var T=r.length;r[T]=o,o.attr("data-sortable-id",T),g.attr("data-item-sortable-id",T)}o.data("items",i.items),a=a.add(v),i.connectWith&&o.data("connectWith",i.connectWith),h(o),g.attr("role","option"),g.attr("aria-grabbed","false"),g.on("dragstart.h5s",function(a){a.stopImmediatePropagation(),i.dragImage?(s(a.originalEvent,{item:i.dragImage,x:0,y:0}),console.log("WARNING: dragImage option is deprecated and will be removed in the future!")):c(a.originalEvent,t(this),i.dragImage),e=t(this),e.addClass(i.draggingClass),e.attr("aria-grabbed","true"),u=e.index(),n=e.height(),f=t(this).parent(),e.parent().triggerHandler("sortstart",{item:e,startparent:f})}),g.on("dragend.h5s",function(){e&&(e.removeClass(i.draggingClass),e.attr("aria-grabbed","false"),e.show(),a.detach(),m=t(this).parent(),e.parent().triggerHandler("sortstop",{item:e,startparent:f}),(u!==e.index()||f.get(0)!==m.get(0))&&e.parent().triggerHandler("sortupdate",{item:e,index:m.children(m.data("items")).index(e),oldindex:g.index(e),elementIndex:e.index(),oldElementIndex:u,startparent:f,endparent:m}),e=null,n=null)}),t(this).add([v]).on("drop.h5s",function(n){return p(o,t(e).parent())?(n.stopPropagation(),a.filter(":visible").after(e),e.trigger("dragend.h5s"),!1):void 0}),g.add([this,v]).on("dragover.h5s dragenter.h5s",function(r){if(p(o,t(e).parent())){if(r.preventDefault(),r.originalEvent.dataTransfer.dropEffect="move",g.is(this)){var s=t(this).height();if(i.forcePlaceholderSize&&v.height(n),s>n){var u=s-n,l=t(this).offset().top;if(v.index()t(this).index()&&r.originalEvent.pageY>l+s-u)return!1}e.hide(),v.index()r;r++)n[r]=arguments[r];l(Object.getPrototypeOf(a.prototype),"constructor",this).apply(this,n),this.tag=this.props.tag||app.store.createRecord("tags"),this.name=m.prop(this.tag.name()||""),this.slug=m.prop(this.tag.slug()||""),this.description=m.prop(this.tag.description()||""),this.color=m.prop(this.tag.color()||""),this.isHidden=m.prop(this.tag.isHidden()||!1)}return n(a,t),u(a,[{key:"className",value:function(){return"EditTagModal Modal--small"}},{key:"title",value:function(){return this.name()?i({name:this.name,color:this.color}):"Create Tag"}},{key:"content",value:function(){var t=this;return m("div",{className:"Modal-body"},m("div",{className:"Form"},m("div",{className:"Form-group"},m("label",null,"Name"),m("input",{className:"FormControl",placeholder:"Name",value:this.name(),oninput:function(e){t.name(e.target.value),t.slug(o(e.target.value))}})),m("div",{className:"Form-group"},m("label",null,"Slug"),m("input",{className:"FormControl",value:this.slug(),oninput:m.withAttr("value",this.slug)})),m("div",{className:"Form-group"},m("label",null,"Description"),m("textarea",{className:"FormControl",value:this.description(),oninput:m.withAttr("value",this.description)})),m("div",{className:"Form-group"},m("label",null,"Color"),m("input",{className:"FormControl",placeholder:"#aaaaaa",value:this.color(),oninput:m.withAttr("value",this.color)})),m("div",{className:"Form-group"},m("div",null,m("label",{className:"checkbox"},m("input",{type:"checkbox",value:"1",checked:this.isHidden(),onchange:m.withAttr("checked",this.isHidden)}),"Hide from All Discussions"))),m("div",{className:"Form-group"},r.component({type:"submit",className:"Button Button--primary EditTagModal-save",loading:this.loading,children:"Save Changes"}),this.tag.exists?m("button",{type:"button",className:"Button EditTagModal-delete",onclick:this["delete"].bind(this)},"Delete Tag"):"")))}},{key:"onsubmit",value:function(t){var e=this;t.preventDefault(),this.loading=!0,this.tag.save({name:this.name(),slug:this.slug(),description:this.description(),color:this.color(),isHidden:this.isHidden()}).then(function(){return e.hide()},function(){e.loading=!1,m.redraw()})}},{key:"delete",value:function(){confirm("Are you sure you want to delete this tag? The tag's discussions will NOT be deleted.")&&(this.tag["delete"]().then(function(){return m.redraw()}),this.hide())}}]),a}(a),t("default",s)}}}),System.register("flarum/tags/components/TagSettingsModal",["flarum/components/SettingsModal"],function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a,r,o=function(){function t(t,e){for(var n=0;n li").map(function(){return{id:$(this).data("id"),children:$(this).find("li").map(function(){return $(this).data("id")}).get()}}).get();a.forEach(function(t,e){var n=app.store.getById("tags",t.id);n.pushData({attributes:{position:e,isChild:!1},relationships:{parent:null}}),t.children.forEach(function(t,e){app.store.getById("tags",t).pushData({attributes:{position:e,isChild:!0},relationships:{parent:n}})})}),app.request({url:app.forum.attribute("apiUrl")+"/tags/order",method:"POST",data:{order:a}}),m.redraw.strategy("all"),m.redraw()})}}]),r}(r),t("default",c)}}}); \ No newline at end of file diff --git a/extensions/tags/js/forum/dist/extension.js b/extensions/tags/js/forum/dist/extension.js new file mode 100644 index 000000000..39bde0a9b --- /dev/null +++ b/extensions/tags/js/forum/dist/extension.js @@ -0,0 +1 @@ +System.register("flarum/tags/helpers/tagIcon",[],function(t){"use strict";function e(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return e.className="icon TagIcon "+(e.className||""),t?(e.style=e.style||{},e.style.backgroundColor=t.color()):e.className+=" untagged",m("span",e)}return t("default",e),{setters:[],execute:function(){}}}),System.register("flarum/tags/helpers/tagLabel",["flarum/utils/extract"],function(t){"use strict";function e(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];e.style=e.style||{},e.className="TagLabel "+(e.className||"");var a=n(e,"link");if(t){var r=t.color();r&&(e.style.backgroundColor=e.style.color=r,e.className+=" colored"),a&&(e.title=t.description()||"",e.href=app.route("tag",{tags:t.slug()}),e.config=m.route)}else e.className+=" untagged";return m(a?"a":"span",e,m("span",{className:"TagLabel-text"},t?t.name():app.trans("tags.deleted")))}var n;return t("default",e),{setters:[function(t){n=t["default"]}],execute:function(){}}}),System.register("flarum/tags/helpers/tagsLabel",["flarum/utils/extract","flarum/tags/helpers/tagLabel","flarum/tags/utils/sortTags"],function(t){"use strict";function e(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=[],s=n(e,"link");return e.className="TagsLabel "+(e.className||""),t?r(t).forEach(function(e){(e||1===t.length)&&o.push(a(e,{link:s}))}):o.push(a()),m("span",e,o)}var n,a,r;return t("default",e),{setters:[function(t){n=t["default"]},function(t){a=t["default"]},function(t){r=t["default"]}],execute:function(){}}}),System.register("flarum/tags/models/Tag",["flarum/Model","flarum/utils/mixin","flarum/utils/computed"],function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a,r,o,s,i=function(t,e,n){for(var a=!0;a;){var r=t,o=e,s=n;i=c=u=void 0,a=!1,null===r&&(r=Function.prototype);var i=Object.getOwnPropertyDescriptor(r,o);if(void 0!==i){if("value"in i)return i.value;var u=i.get;return void 0===u?void 0:u.call(s)}var c=Object.getPrototypeOf(r);if(null===c)return void 0;t=c,e=o,n=s,a=!0}};return{setters:[function(t){a=t["default"]},function(t){r=t["default"]},function(t){o=t["default"]}],execute:function(){s=function(t){function a(){e(this,a),i(Object.getPrototypeOf(a.prototype),"constructor",this).apply(this,arguments)}return n(a,t),a}(r(a,{name:a.attribute("name"),slug:a.attribute("slug"),description:a.attribute("description"),color:a.attribute("color"),backgroundUrl:a.attribute("backgroundUrl"),backgroundMode:a.attribute("backgroundMode"),position:a.attribute("position"),parent:a.hasOne("parent"),defaultSort:a.attribute("defaultSort"),isChild:a.attribute("isChild"),isHidden:a.attribute("isHidden"),discussionsCount:a.attribute("discussionsCount"),lastTime:a.attribute("lastTime",a.transformDate),lastDiscussion:a.hasOne("lastDiscussion"),isRestricted:a.attribute("isRestricted"),canStartDiscussion:a.attribute("canStartDiscussion"),isPrimary:o("position","parent",function(t,e){return null!==t&&e===!1})})),t("default",s)}}}),System.register("flarum/tags/utils/sortTags",[],function(t){"use strict";function e(t){return t.slice(0).sort(function(t,e){var n=t.position(),a=e.position(),r=t.parent(),o=e.parent();return null===n&&null===a?e.discussionsCount()-t.discussionsCount():null===a?-1:null===n?1:r===o?n-a:r?r===e?1:r.position()-a:o?o===t?-1:n-o.position():0})}return t("default",e),{setters:[],execute:function(){}}}),System.register("flarum/tags/addTagComposer",["flarum/extend","flarum/components/IndexPage","flarum/components/DiscussionComposer","flarum/tags/components/TagDiscussionModal","flarum/tags/helpers/tagsLabel"],function(t){"use strict";var e,n,a,r,o,s;return{setters:[function(t){e=t.extend,n=t.override},function(t){a=t["default"]},function(t){r=t["default"]},function(t){o=t["default"]},function(t){s=t["default"]}],execute:function(){t("default",function(){e(a.prototype,"composeNewDiscussion",function(t){var e=app.store.getBy("tags","slug",this.params().tags);e&&t.then(function(t){return t.tags=[e]})}),r.prototype.tags=[],r.prototype.chooseTags=function(){var t=this;app.modal.show(new o({selectedTags:this.tags.slice(0),onsubmit:function(e){t.tags=e,t.$("textarea").focus()}}))},e(r.prototype,"headerItems",function(t){t.add("tags",m("a",{className:"DiscussionComposer-changeTags",onclick:this.chooseTags.bind(this)},this.tags.length?s(this.tags):m("span",{className:"TagLabel untagged"},app.trans("tags.tag_new_discussion_link"))),10)}),n(r.prototype,"onsubmit",function(t){var e=this;this.tags.length?t():app.modal.show(new o({selectedTags:[],onsubmit:function(n){e.tags=n,t()}}))}),e(r.prototype,"data",function(t){t.relationships=t.relationships||{},t.relationships.tags=this.tags})})}}}),System.register("flarum/tags/addTagControl",["flarum/extend","flarum/utils/DiscussionControls","flarum/components/Button","flarum/tags/components/TagDiscussionModal"],function(t){"use strict";var e,n,a,r;return{setters:[function(t){e=t.extend},function(t){n=t["default"]},function(t){a=t["default"]},function(t){r=t["default"]}],execute:function(){t("default",function(){e(n,"moderationControls",function(t,e){e.canTag()&&t.add("tags",a.component({children:app.trans("tags.edit_discussion_tags_link"),icon:"tag",onclick:function(){return app.modal.show(new r({discussion:e}))}}))})})}}}),System.register("flarum/tags/addTagFilter",["flarum/extend","flarum/components/IndexPage","flarum/components/DiscussionList","flarum/tags/components/TagHero"],function(t){"use strict";var e,n,a,r,o;return{setters:[function(t){e=t.extend,n=t.override},function(t){a=t["default"]},function(t){r=t["default"]},function(t){o=t["default"]}],execute:function(){t("default",function(){a.prototype.currentTag=function(){var t=this.params().tags;return t?app.store.getBy("tags","slug",t):void 0},n(a.prototype,"hero",function(t){var e=this.currentTag();return e?o.component({tag:e}):t()}),e(a.prototype,"sidebarItems",function(t){var e=this.currentTag();if(e){var n=e.color();n&&(t.newDiscussion.content.props.style={backgroundColor:n})}}),e(a.prototype,"params",function(t){t.tags=m.route.param("tags")}),e(r.prototype,"requestParams",function(t){t.include.push("tags"),this.props.params.tags&&(t.filter.q=(t.filter.q||"")+" tag:"+this.props.params.tags)})})}}}),System.register("flarum/tags/addTagLabels",["flarum/extend","flarum/components/DiscussionListItem","flarum/components/DiscussionPage","flarum/components/DiscussionHero","flarum/tags/helpers/tagsLabel","flarum/tags/utils/sortTags"],function(t){"use strict";var e,n,a,r,o,s;return{setters:[function(t){e=t.extend},function(t){n=t["default"]},function(t){a=t["default"]},function(t){r=t["default"]},function(t){o=t["default"]},function(t){s=t["default"]}],execute:function(){t("default",function(){e(n.prototype,"infoItems",function(t){var e=this.props.discussion.tags();e&&e.length&&t.add("tags",o(e),10)}),e(a.prototype,"params",function(t){t.include.push("tags")}),e(r.prototype,"view",function(t){var e=s(this.props.discussion.tags());if(e&&e.length){var n=e[0].color();n&&(t.attrs.style={backgroundColor:n},t.attrs.className+=" DiscussionHero--colored")}}),e(r.prototype,"items",function(t){var e=this.props.discussion.tags();e&&e.length&&t.add("tags",o(e,{link:!0}),5)})})}}}),System.register("flarum/tags/addTagList",["flarum/extend","flarum/components/IndexPage","flarum/components/Separator","flarum/components/LinkButton","flarum/tags/components/TagLinkButton","flarum/tags/components/TagsPage","flarum/tags/utils/sortTags"],function(t){"use strict";var e,n,a,r,o,s,i;return{setters:[function(t){e=t.extend},function(t){n=t["default"]},function(t){a=t["default"]},function(t){r=t["default"]},function(t){o=t["default"]},function(t){s=t["default"]},function(t){i=t["default"]}],execute:function(){t("default",function(){e(n.prototype,"navItems",function(t){if(t.add("tags",r.component({icon:"th-large",children:app.trans("tags.tags"),href:app.route("tags")}),-10),!(app.current instanceof s)){t.add("separator",a.component(),-10);var e=this.stickyParams(),n=app.store.all("tags"),u=this.currentTag(),c=function(n){var a=u===n;!a&&u&&(a=u.parent()===n),t.add("tag"+n.id(),o.component({tag:n,params:e,active:a}),-10)};i(n).filter(function(t){return null!==t.position()&&(!t.isChild()||u&&(t.parent()===u||t.parent()===u.parent()))}).forEach(c);var l=n.filter(function(t){return null===t.position()}).sort(function(t,e){return e.discussionsCount()-t.discussionsCount()});l.splice(0,3).forEach(c),l.length&&t.add("moreTags",r.component({children:app.trans("tags.more"),href:app.route("tags")}),-10)}})})}}}),System.register("flarum/tags/main",["flarum/Model","flarum/models/Discussion","flarum/components/IndexPage","flarum/tags/models/Tag","flarum/tags/components/TagsPage","flarum/tags/components/DiscussionTaggedPost","flarum/tags/addTagList","flarum/tags/addTagFilter","flarum/tags/addTagLabels","flarum/tags/addTagControl","flarum/tags/addTagComposer"],function(t){"use strict";var e,n,a,r,o,s,i,u,c,l,f;return{setters:[function(t){e=t["default"]},function(t){n=t["default"]},function(t){a=t["default"]},function(t){r=t["default"]},function(t){o=t["default"]},function(t){s=t["default"]},function(t){i=t["default"]},function(t){u=t["default"]},function(t){c=t["default"]},function(t){l=t["default"]},function(t){f=t["default"]}],execute:function(){app.initializers.add("tags",function(t){t.routes.tags={path:"/tags",component:o.component()},t.routes.tag={path:"/t/:tags",component:a.component()},t.route.tag=function(e){return t.route("tag",{tags:e.slug()})},t.postComponents.discussionTagged=s,t.store.models.tags=r,n.prototype.tags=e.hasMany("tags"),n.prototype.canTag=e.attribute("canTag"),i(),u(),c(),l(),f()})}}}),System.register("flarum/tags/components/DiscussionTaggedPost",["flarum/components/EventPost","flarum/helpers/punctuate","flarum/tags/helpers/tagsLabel"],function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a,r,o,s,i=function(){function t(t,e){for(var n=0;nr;r++)n[r]=arguments[r];g(Object.getPrototypeOf(a.prototype),"constructor",this).apply(this,n),this.tags=f(app.store.all("tags").filter(function(t){return t.canStartDiscussion()})),this.selected=[],this.filter=m.prop(""),this.index=this.tags[0].id(),this.focused=!1,this.props.selectedTags?this.props.selectedTags.map(this.addTag.bind(this)):this.props.discussion&&this.props.discussion.tags().map(this.addTag.bind(this)),this.minPrimary=app.forum.attribute("minPrimaryTags"),this.maxPrimary=app.forum.attribute("maxPrimaryTags"),this.minSecondary=app.forum.attribute("minSecondaryTags"),this.maxSecondary=app.forum.attribute("maxSecondaryTags")}return n(a,t),d(a,[{key:"primaryCount",value:function(){return this.selected.filter(function(t){return t.isPrimary()}).length}},{key:"secondaryCount",value:function(){return this.selected.filter(function(t){return!t.isPrimary()}).length}},{key:"addTag",value:function(t){if(t.canStartDiscussion()){var e=t.parent();if(e){var n=this.selected.indexOf(e);-1===n&&this.selected.push(e)}this.selected.push(t)}}},{key:"removeTag",value:function(t){var e=this.selected.indexOf(t);-1!==e&&(this.selected.splice(e,1),this.selected.filter(function(e){return e.parent()===t}).forEach(this.removeTag.bind(this)))}},{key:"className",value:function(){return"TagDiscussionModal"}},{key:"title",value:function(){return this.props.discussion?app.trans("tags.edit_discussion_tags_title",{title:m("em",null,this.props.discussion.title())}):app.trans("tags.tag_new_discussion_title")}},{key:"getInstruction",value:function(t,e){return t=app.forum.attribute("maxPrimaryTags")&&(e=e.filter(function(e){return!e.isPrimary()||-1!==t.selected.indexOf(e)})),r>=app.forum.attribute("maxSecondaryTags")&&(e=e.filter(function(e){return e.isPrimary()||-1!==t.selected.indexOf(e)})),n&&(e=e.filter(function(t){return t.name().substr(0,n.length).toLowerCase()===n})),-1===e.indexOf(this.index)&&(this.index=e[0]),[m("div",{className:"Modal-body"},m("div",{className:"TagDiscussionModal-form"},m("div",{className:"TagDiscussionModal-form-input"},m("div",{className:"TagsInput FormControl "+(this.focused?"focus":"")},m("span",{className:"TagsInput-selected"},this.selected.map(function(e){return m("span",{className:"TagsInput-tag",onclick:function(){t.removeTag(e),t.onready()}},c(e))})),m("input",{className:"FormControl",placeholder:u(this.getInstruction(a,r)),value:this.filter(),oninput:m.withAttr("value",this.filter),onkeydown:this.onkeydown.bind(this),onfocus:function(){return t.focused=!0},onblur:function(){return t.focused=!1}}))),m("div",{className:"TagDiscussionModal-form-submit App-primaryControl"},o.component({type:"submit",className:"Button Button--primary",disabled:a li")}},{key:"getCurrentNumericIndex",value:function(){return this.selectableItems().index(this.getItem(this.index))}},{key:"getItem",value:function(t){return this.selectableItems().filter('[data-index="'+t.id()+'"]')}},{key:"setIndex",value:function(t,e){var n=this.selectableItems(),a=n.parent();0>t?t=n.length-1:t>=n.length&&(t=0);var r=n.eq(t);if(this.index=app.store.getById("tags",r.attr("data-index")),m.redraw(),e){var o=a.scrollTop(),s=a.offset().top,i=s+a.outerHeight(),u=r.offset().top,c=u+r.outerHeight(),l=void 0;s>u?l=o-s+u-parseInt(a.css("padding-top"),10):c>i&&(l=o-i+c+parseInt(a.css("padding-bottom"),10)),"undefined"!=typeof l&&a.stop(!0).animate({scrollTop:l},100)}}},{key:"onsubmit",value:function(t){t.preventDefault();var e=this.props.discussion,n=this.selected;e&&e.save({relationships:{tags:n}}).then(function(){app.current instanceof r&&app.current.stream.update(),m.redraw()}),this.props.onsubmit&&this.props.onsubmit(n),app.modal.close(),m.redraw.strategy("none")}}]),a}(a),t("default",p)}}}),System.register("flarum/tags/components/TagHero",["flarum/Component"],function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a,r,o=function(){function t(t,e){for(var n=0;nr;r++)n[r]=arguments[r];f(Object.getPrototypeOf(a.prototype),"constructor",this).apply(this,n),this.tags=u(app.store.all("tags").filter(function(t){return!t.parent()})),app.current=this,app.history.push("tags"),app.drawer.hide(),app.modal.close()}return n(a,t),l(a,[{key:"view",value:function(){var t=this.tags.filter(function(t){return null!==t.position()}),e=this.tags.filter(function(t){return null===t.position()});return m("div",{className:"TagsPage"},r.prototype.hero(),m("div",{className:"container"},m("nav",{className:"TagsPage-nav IndexPage-nav sideNav",config:r.prototype.affixSidebar},m("ul",null,o(r.prototype.sidebarItems().toArray()))),m("div",{className:"TagsPage-content sideNavOffset"},m("ul",{className:"TagTiles"},t.map(function(t){var e=t.lastDiscussion(),n=app.store.all("tags").filter(function(e){return e.parent()===t});return m("li",{className:"TagTile "+(t.color()?"colored":""),style:{backgroundColor:t.color()}},m("a",{className:"TagTile-info",href:app.route.tag(t),config:m.route},m("h3",{className:"TagTile-name"},t.name()),m("p",{className:"TagTile-description"},t.description()),n?m("div",{className:"TagTile-children"},n.map(function(t){return m("a",{href:app.route.tag(t),config:function(t,e){e||($(t).on("click",function(t){return t.stopPropagation()}),m.route.apply(this,arguments))}},t.name())})):""),e?m("a",{className:"TagTile-lastDiscussion",href:app.route.discussion(e,e.lastPostNumber()),config:m.route},m("span",{className:"TagTile-lastDiscussion-title"},e.title()),s(e.lastTime())):m("span",{className:"TagTile-lastDiscussion"}))})),e.length?m("div",{className:"TagCloud"},e.map(function(t){t.color();return[i(t,{link:!0})," "]})):"")))}}]),a}(a),t("default",c)}}}); \ No newline at end of file diff --git a/extensions/tags/scripts/compile.sh b/extensions/tags/scripts/compile.sh new file mode 100755 index 000000000..b0d8e8bd3 --- /dev/null +++ b/extensions/tags/scripts/compile.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# This script compiles the extension so that it can be used in a Flarum +# installation. It should be run from the root directory of the extension. + +base=$PWD + +cd "${base}/js" + +if [ -f bower.json ]; then + bower install +fi + +for app in forum admin; do + cd "${base}/js" + + if [ -d $app ]; then + cd $app + + if [ -f bower.json ]; then + bower install + fi + + npm install + gulp --production + fi +done