diff --git a/scripts/langindex.json b/scripts/langindex.json index 95f5d1ca6..e29d5b9d7 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -55,6 +55,7 @@ "addon.block_recentlyaccessedcourses.pluginname": "block_recentlyaccessedcourses", "addon.block_recentlyaccesseditems.noitems": "block_recentlyaccesseditems", "addon.block_recentactivity.pluginname": "block_recent_activity", + "addon.block_rssclient.pluginname": "block_rss_client", "addon.block_glossaryrandom.pluginname": "block_glossary_random", "addon.block_selfcompletion.pluginname": "block_selfcompletion", "addon.block_sitemainmenu.pluginname": "block_site_main_menu", diff --git a/src/addon/block/rssclient/lang/en.json b/src/addon/block/rssclient/lang/en.json new file mode 100644 index 000000000..18282971b --- /dev/null +++ b/src/addon/block/rssclient/lang/en.json @@ -0,0 +1,3 @@ +{ + "pluginname": "Remote RSS feeds" +} \ No newline at end of file diff --git a/src/addon/block/rssclient/providers/block-handler.ts b/src/addon/block/rssclient/providers/block-handler.ts new file mode 100644 index 000000000..ce26caba4 --- /dev/null +++ b/src/addon/block/rssclient/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 AddonBlockRssClientHandler extends CoreBlockBaseHandler { + name = 'AddonBlockRssClient'; + blockName = 'rss_client'; + + 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: block.contents.title || this.translate.instant('addon.block_rssclient.pluginname'), + class: 'addon-block-rss-client', + component: CoreBlockPreRenderedComponent + }; + } +} diff --git a/src/addon/block/rssclient/rssclient.module.ts b/src/addon/block/rssclient/rssclient.module.ts new file mode 100644 index 000000000..b98c39ae5 --- /dev/null +++ b/src/addon/block/rssclient/rssclient.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 { AddonBlockRssClientHandler } from './providers/block-handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule, + TranslateModule.forChild() + ], + exports: [ + ], + providers: [ + AddonBlockRssClientHandler + ] +}) +export class AddonBlockRssClientModule { + constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockRssClientHandler) { + blockDelegate.registerHandler(blockHandler); + } +} diff --git a/src/addon/block/rssclient/rssclient.scss b/src/addon/block/rssclient/rssclient.scss new file mode 100644 index 000000000..33b37b0e7 --- /dev/null +++ b/src/addon/block/rssclient/rssclient.scss @@ -0,0 +1,19 @@ +.addon-block-rss-client core-block-pre-rendered { + .core-block-content { + .list { + list-style: none; + @include margin-horizontal(0); + -webkit-padding-start: 0; + + li { + border-top: 1px solid $gray; + padding: 5px; + padding-bottom: 8px; + } + + li:first-child { + border-top-width: 0; + } + } + } +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4c1b3f81f..6969e01bc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -111,6 +111,7 @@ import { AddonBlockTimelineModule } from '@addon/block/timeline/timeline.module' import { AddonBlockRecentlyAccessedCoursesModule } from '@addon/block/recentlyaccessedcourses/recentlyaccessedcourses.module'; import { AddonBlockRecentlyAccessedItemsModule } from '@addon/block/recentlyaccesseditems/recentlyaccesseditems.module'; import { AddonBlockRecentActivityModule } from '@addon/block/recentactivity/recentactivity.module'; +import { AddonBlockRssClientModule } from '@addon/block/rssclient/rssclient.module'; import { AddonBlockStarredCoursesModule } from '@addon/block/starredcourses/starredcourses.module'; import { AddonBlockSelfCompletionModule } from '@addon/block/selfcompletion/selfcompletion.module'; import { AddonBlockTagsModule } from '@addon/block/tags/tags.module'; @@ -250,6 +251,7 @@ export const CORE_PROVIDERS: any[] = [ AddonBlockRecentlyAccessedCoursesModule, AddonBlockRecentlyAccessedItemsModule, AddonBlockRecentActivityModule, + AddonBlockRssClientModule, AddonBlockStarredCoursesModule, AddonBlockSelfCompletionModule, AddonBlockTagsModule, diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index a70d49554..f3f750318 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -56,6 +56,7 @@ "addon.block_recentlyaccessedcourses.pluginname": "Recently accessed courses", "addon.block_recentlyaccesseditems.noitems": "No recent items", "addon.block_recentlyaccesseditems.pluginname": "Recently accessed items", + "addon.block_rssclient.pluginname": "Remote RSS feeds", "addon.block_selfcompletion.pluginname": "Self completion", "addon.block_sitemainmenu.pluginname": "Main menu", "addon.block_starredcourses.nocourses": "No starred courses",