Skip to content

Commit

Permalink
add support for chinese tags
Browse files Browse the repository at this point in the history
  • Loading branch information
skenan committed Oct 14, 2017
1 parent 987c838 commit e52cb66
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/app/ResolveRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ export const routeRegex = {
UserEndPoints: /^(blog|posts|comments|recommended|transfers|curation-rewards|author-rewards|permissions|created|recent-replies|feed|password|followed|followers|settings)$/,
CategoryFilters: /^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/?$/ig,
PostNoCategory: /^\/(@[\w\.\d-]+)\/([\w\d-]+)/,
Post: /^\/([\w\d\-\/]+)\/(\@[\w\d\.-]+)\/([\w\d-]+)\/?($|\?)/,
PostJson: /^\/([\w\d\-\/]+)\/(\@[\w\d\.-]+)\/([\w\d-]+)(\.json)$/,
Post: /^\/([\u4E00-\u9FA5\w\d\-\/]+)\/(\@[\w\d\.-]+)\/([\w\d-]+)\/?($|\?)/,
PostJson: /^\/([\u4E00-\u9FA5\w\d\-\/]+)\/(\@[\w\d\.-]+)\/([\w\d-]+)(\.json)$/,
UserJson: /^\/(@[\w\.\d-]+)(\.json)$/,
UserNameJson: /^.*(?=(\.json))/,
};

export default function resolveRoute(path)
{
path = decodeURIComponent(path);
if (path === '/') {
return {page: 'PostsIndex', params: ['trending']};
}
Expand Down Expand Up @@ -93,7 +94,7 @@ export default function resolveRoute(path)
return {page: 'Post', params: match.slice(1)};
}
match = path.match(/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/?$/)
|| path.match(/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/([\w\d-]+)\/?$/);
|| path.match(/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/([\u4E00-\u9FA5\w\d-]+)\/?$/);
if (match) {
return {page: 'PostsIndex', params: match.slice(1)};
}
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/cards/CategorySelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ export function validateCategory(category, required = true) {
cats.find(c => c.split('-').length > 2) ? tt('category_selector_jsx.use_one_dash') :
cats.find(c => c.indexOf(',') >= 0) ? tt('category_selector_jsx.use_spaces_to_separate_tags') :
cats.find(c => /[A-Z]/.test(c)) ? tt('category_selector_jsx.use_only_lowercase_letters') :
cats.find(c => !/^[a-z0-9-#]+$/.test(c)) ? tt('category_selector_jsx.use_only_allowed_characters') :
cats.find(c => !/^[a-z-#]/.test(c)) ? tt('category_selector_jsx.must_start_with_a_letter') :
cats.find(c => !/[a-z0-9]$/.test(c)) ? tt('category_selector_jsx.must_end_with_a_letter_or_number') :
// Check for English and Chinese symbols
cats.find(c => !/^[a-z0-9-#\u4E00-\u9FA5]+$/.test(c)) ? tt('category_selector_jsx.use_only_allowed_characters') :
cats.find(c => !/^[a-z-#\u4E00-\u9FA5]/.test(c)) ? tt('category_selector_jsx.must_start_with_a_letter') :
cats.find(c => !/[a-z0-9\u4E00-\u9FA5]$/.test(c)) ? tt('category_selector_jsx.must_end_with_a_letter_or_number') :
null
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/redux/TransactionSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ function* preBroadcast_comment({operation, username}) {
if (!permlink) permlink = yield createPermlink(title, author, parent_author, parent_permlink)

const md = operation.json_metadata
const json_metadata = typeof md === 'string' ? md : JSON.stringify(md)
json_metadata = typeof md === 'string' ? md : JSON.stringify(md)
json_metadata = new Buffer(json_metadata, 'utf-8')
const op = {
...operation,
permlink: permlink.toLowerCase(),
Expand Down
2 changes: 1 addition & 1 deletion src/server/app_render.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function appRender(ctx) {
}
}

const { body, title, statusCode, meta } = await universalRender({location: ctx.request.url, store, offchain, ErrorPage, tarantool: Tarantool.instance()});
const { body, title, statusCode, meta } = await universalRender({location: decodeURIComponent(ctx.request.url), store, offchain, ErrorPage, tarantool: Tarantool.instance()});

// Assets name are found in `webpack-stats` file
const assets_filename = ROOT + (process.env.NODE_ENV === 'production' ? '/tmp/webpack-stats-prod.json' : '/tmp/webpack-stats-dev.json');
Expand Down

3 comments on commit e52cb66

@sneak
Copy link

@sneak sneak commented on e52cb66 Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make a Pull Request for this to steemit/condenser? :)

@skenan
Copy link
Owner Author

@skenan skenan commented on e52cb66 Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sneak I have plan to do that. However, this is only for Chines right now. Should we add the support for other languages?

@sneak
Copy link

@sneak sneak commented on e52cb66 Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arbitrary unicode should be fine. I wanted the PR for a place to discuss the change. :)

Please sign in to comment.