-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from v17development/dev
Update v0.1.3
- Loading branch information
Showing
17 changed files
with
400 additions
and
182 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { compat } from '@flarum/core/forum'; | ||
import BlogAuthor from './components/BlogItemSidebar/BlogAuthor'; | ||
import BlogItemSidebar from './components/BlogItemSidebar/BlogItemSidebar'; | ||
|
||
export default () => { | ||
Object.assign(compat, { | ||
"v17development/blog/components/BlogItemSidebar": BlogItemSidebar, | ||
"v17development/blog/components/BlogAuthor": BlogAuthor | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Component from 'flarum/Component'; | ||
import ItemList from 'flarum/utils/ItemList'; | ||
import listItems from 'flarum/helpers/listItems'; | ||
import avatar from 'flarum/helpers/avatar'; | ||
|
||
export default class BlogAuthor extends Component { | ||
view() { | ||
return ( | ||
<div className={"FlarumBlog-Article-Author"}> | ||
<div className={`FlarumBlog-Article-Author-background ${this.props.loading ? 'FlarumBlog-Author-Ghost' : ''}`} style={{ backgroundColor: this.props.article && this.props.article.user() ? this.props.article && this.props.article.user().color() : null }} /> | ||
|
||
<div className={"FlarumBlog-Article-Author-Avatar"}>{this.props.article && this.props.article.user() ? avatar(this.props.article.user()) : <span className={"Avatar FlarumBlog-Author-Ghost"} />}</div> | ||
|
||
{this.props.article && this.props.article.user() && ( | ||
<div className={"FlarumBlog-Article-Author-Info"}> | ||
<span className={"FlarumBlog-Article-Author-Name"}>{this.props.article.user().displayName()}</span> | ||
<p className={"FlarumBlog-Article-Author-Bio"}>{this.props.article.user().bio && this.props.article.user().bio()}</p> | ||
|
||
<ul className={"FlarumBlog-Article-Author-Extended"}> | ||
{listItems(this.items().toArray())} | ||
</ul> | ||
</div> | ||
)} | ||
|
||
{this.props.loading && ( | ||
<div> | ||
<span className={"FlarumBlog-Article-Author-Name FlarumBlog-Author-Ghost"}> </span> | ||
<p className={"FlarumBlog-Article-Author-Bio FlarumBlog-Author-Ghost"}> </p> | ||
<p className={"FlarumBlog-Article-Author-Bio FlarumBlog-Author-Ghost"}> </p> | ||
<p className={"FlarumBlog-Article-Author-Bio FlarumBlog-Author-Ghost"}> </p> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
items() { | ||
return new ItemList(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
js/src/forum/components/BlogItemSidebar/BlogItemSidebar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Component from 'flarum/Component'; | ||
import ItemList from 'flarum/utils/ItemList'; | ||
import listItems from 'flarum/helpers/listItems'; | ||
import BlogAuthor from './BlogAuthor'; | ||
import BlogCategories from '../BlogCategories'; | ||
|
||
export default class BlogItemSidebar extends Component { | ||
view() { | ||
return ( | ||
<div className={"FlarumBlog-Article-Sidebar"}> | ||
<ul> | ||
{listItems(this.items().toArray())} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
||
items() { | ||
const itemlist = new ItemList(); | ||
|
||
itemlist.add("author", BlogAuthor.component(this.props), 0); | ||
|
||
itemlist.add("categories", BlogCategories.component(this.props), 0); | ||
|
||
return itemlist; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import ComposerBody from 'flarum/components/ComposerBody'; | ||
import Button from 'flarum/components/Button'; | ||
import {extend} from 'flarum/extend'; | ||
|
||
export default class ArticleComposer extends ComposerBody { | ||
init() { | ||
super.init(); | ||
|
||
this.previewContent = false; | ||
} | ||
|
||
// Render | ||
render() { | ||
const hasContent = (this.content() && this.content() !== ""); | ||
|
||
return ( | ||
<div className={"Flarum-Support-ArticleComposer"}> | ||
<div className={"Flarum-Support-ArticleComposer-tabs"}> | ||
<Button className={!this.previewContent && "AricleComposerButtonSelected"} onclick={() => this.previewContent = false}>{app.translator.trans('v17development-flarum-support.forum.composer.write')}</Button> | ||
<Button className={this.previewContent && "AricleComposerButtonSelected"} onclick={() => this.previewContent = true}>{app.translator.trans('v17development-flarum-support.forum.composer.view')}</Button> | ||
</div> | ||
|
||
<div className={"Composer Flarum-Support-ComposeArticle-body"}> | ||
{this.previewContent ? ( | ||
<div className={"Flarum-Support-ArticleComposer-preview"} config={hasContent && this.configPreview.bind(this)}> | ||
{!hasContent && ( | ||
app.translator.trans('v17development-flarum-support.forum.composer.nothing_to_preview') | ||
)} | ||
</div> | ||
) : this.view()} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
// Initialize preview content | ||
configPreview(element) { | ||
s9e.TextFormatter.preview(this.content() || '', element); | ||
} | ||
|
||
// Submit trigger | ||
onsubmit() { | ||
if(this.props.onsubmit) { | ||
this.props.onsubmit(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export default function () { | ||
// Save the original function before we override it | ||
const original_discussion_route = app.route.discussion; | ||
|
||
/** | ||
* Generate a URL to a discussion OR a Blog Article. | ||
* | ||
* CORE_CODE_OVERRIDE: This overrides the standard function from flarum/core. | ||
* The code is inspired from js/src/forum/routes.js and now handles different types of discussions. | ||
* It will try to keep the original function executed if the discussion being | ||
* processed isn't a blog article. | ||
* | ||
* @param {Discussion} discussion | ||
* @param {Integer} [near] | ||
* @return {String} | ||
*/ | ||
app.route.discussion = (discussion, near) => { | ||
const discussionRedirectEnabled = | ||
app.forum.attribute('blogRedirectsEnabled') === 'both' || | ||
app.forum.attribute('blogRedirectsEnabled') === 'discussions_only'; | ||
let shouldRedirect = false; | ||
if (discussionRedirectEnabled && discussion.tags().length > 0) { | ||
const blogTags = app.forum.attribute('blogTags'); | ||
|
||
const foundTags = discussion.tags().filter((tag) => { | ||
return ( | ||
blogTags.indexOf(tag.id()) >= 0 || | ||
(tag.parent() && blogTags.indexOf(tag.parent().id()) >= 0) | ||
); | ||
}); | ||
|
||
if (foundTags.length > 0) { | ||
shouldRedirect = true; | ||
} | ||
} | ||
if (shouldRedirect) { | ||
const slug = discussion.slug(); | ||
return app.route('blogArticle', { | ||
id: discussion.id() + (slug.trim() ? '-' + slug : ''), | ||
}); | ||
} else { | ||
return original_discussion_route(discussion, near); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.