diff --git a/scripts/langindex.json b/scripts/langindex.json index ceb8559a8..7ee470a71 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -28,6 +28,7 @@ "addon.badges.warnexpired": "badges", "addon.block_activitymodules.pluginname": "block_activity_modules", "addon.block_badges.pluginname": "block_badges", + "addon.block_blogtags.pluginname": "block_blog_tags", "addon.block_calendarmonth.pluginname": "block_calendar_month", "addon.block_calendarupcoming.pluginname": "block_calendar_upcoming", "addon.block_comments.pluginname": "block_comments", diff --git a/src/addon/block/blogtags/blogtags.module.ts b/src/addon/block/blogtags/blogtags.module.ts new file mode 100644 index 000000000..a9ed3a090 --- /dev/null +++ b/src/addon/block/blogtags/blogtags.module.ts @@ -0,0 +1,38 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicModule } from 'ionic-angular'; +import { TranslateModule } from '@ngx-translate/core'; +import { CoreBlockDelegate } from '@core/block/providers/delegate'; +import { AddonBlockBlogTagsHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockBlogTagsHandler + ] +}) +export class AddonBlockBlogTagsModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockBlogTagsHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/blogtags/blogtags.scss b/src/addon/block/blogtags/blogtags.scss new file mode 100644 index 000000000..859b876da --- /dev/null +++ b/src/addon/block/blogtags/blogtags.scss @@ -0,0 +1,82 @@ +.addon-block-blog-tags core-block-pre-rendered { + .core-block-content { + ul.inline-list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + padding: 0 .2em; + display: inline; + } + } + .s20 { + font-size: 1.5em; + font-weight: bold; + } + + .s19 { + font-size: 1.5em; + } + + .s18 { + font-size: 1.4em; + font-weight: bold; + } + + .s17 { + font-size: 1.4em; + } + + .s16 { + font-size: 1.3em; + font-weight: bold; + } + + .s15 { + font-size: 1.3em; + } + + .s14 { + font-size: 1.2em; + font-weight: bold; + } + + .s13 { + font-size: 1.2em; + } + + .s12, + .s11 { + font-size: 1.1em; + font-weight: bold; + } + + .s10, + .s9 { + font-size: 1.1em; + } + + .s8, + .s7 { + font-size: 1em; + font-weight: bold; + } + + .s6, + .s5 { + font-size: 1em; + } + + .s4, + .s3 { + font-size: 0.9em; + font-weight: bold; + } + + .s2, + .s1 { + font-size: 0.9em; + } + } +} \ No newline at end of file diff --git a/src/addon/block/blogtags/lang/en.json b/src/addon/block/blogtags/lang/en.json new file mode 100644 index 000000000..683c3aa90 --- /dev/null +++ b/src/addon/block/blogtags/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Blog tags" +} \ No newline at end of file diff --git a/src/addon/block/blogtags/providers/block-handler.ts b/src/addon/block/blogtags/providers/block-handler.ts new file mode 100644 index 000000000..cd6ae4c46 --- /dev/null +++ b/src/addon/block/blogtags/providers/block-handler.ts @@ -0,0 +1,52 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable, Injector } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; + +import { CoreBlockHandlerData } from '@core/block/providers/delegate'; +import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; +import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; + +/** + * Block handler. + */ +@Injectable() +export class AddonBlockBlogTagsHandler extends CoreBlockBaseHandler { + name = 'AddonBlockBlogTags'; + blockName = 'blog_tags'; + + constructor(private translate: TranslateService) { + super(); + } + + /** + * Returns the data needed to render the block. + * + * @param {Injector} injector Injector. + * @param {any} block The block to render. + * @param {string} contextLevel The context where the block will be used. + * @param {number} instanceId The instance ID associated with the context level. + * @return {CoreBlockHandlerData|Promise} Data or promise resolved with the data. + */ + getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number) + : CoreBlockHandlerData | Promise { + + return { + title: this.translate.instant('addon.block_blogtags.pluginname'), + class: 'addon-block-blog-tags', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9b4d75af7..6183c41f3 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -92,6 +92,7 @@ import { AddonUserProfileFieldModule } from '@addon/userprofilefield/userprofile import { AddonFilesModule } from '@addon/files/files.module'; import { AddonBlockActivityModulesModule } from '@addon/block/activitymodules/activitymodules.module'; import { AddonBlockBadgesModule } from '@addon/block/badges/badges.module'; +import { AddonBlockBlogTagsModule } from '@addon/block/blogtags/blogtags.module'; import { AddonBlockCalendarMonthModule } from '@addon/block/calendarmonth/calendarmonth.module'; import { AddonBlockCalendarUpcomingModule } from '@addon/block/calendarupcoming/calendarupcoming.module'; import { AddonBlockCommentsModule } from '@addon/block/comments/comments.module'; @@ -227,6 +228,7 @@ export const CORE_PROVIDERS: any[] = [ AddonFilesModule, AddonBlockActivityModulesModule, AddonBlockBadgesModule, + AddonBlockBlogTagsModule, AddonBlockCalendarMonthModule, AddonBlockCalendarUpcomingModule, AddonBlockCommentsModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 390eec79f..8eba39062 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -28,6 +28,7 @@ "addon.badges.warnexpired": "(This badge has expired!)", "addon.block_activitymodules.pluginname": "Activities", "addon.block_badges.pluginname": "Latest badges", + "addon.block_blogtags.pluginname": "Blog tags", "addon.block_calendarmonth.pluginname": "Calendar", "addon.block_calendarupcoming.pluginname": " Upcoming events", "addon.block_comments.pluginname": "Comments",