Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NiceDB button to profile page #32

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ gem 'health_check', git: 'https://github.com/ianheggie/health_check', ref: '0b79
gem 'htmlentities', '~> 4.3'
gem 'http', '~> 4.4'
gem 'http_accept_language', '~> 2.1'
gem 'http_parser.rb', '~> 0.6', git: 'https://github.com/tmm1/http_parser.rb', ref: '54b17ba8c7d8d20a16dfc65d1775241833219cf2', submodules: true
gem 'http_parser.rb', '~> 0.8', git: 'https://github.com/tmm1/http_parser.rb', ref: '90abe77b061c8b9b76204f53d4c223a2db0c858b', submodules: true
gem 'httplog', '~> 1.4.2'
gem 'idn-ruby', require: 'idn'
gem 'kaminari', '~> 1.2'
Expand Down
12 changes: 7 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ GIT

GIT
remote: https://github.com/tmm1/http_parser.rb
revision: 54b17ba8c7d8d20a16dfc65d1775241833219cf2
ref: 54b17ba8c7d8d20a16dfc65d1775241833219cf2
revision: 90abe77b061c8b9b76204f53d4c223a2db0c858b
ref: 90abe77b061c8b9b76204f53d4c223a2db0c858b
submodules: true
specs:
http_parser.rb (0.6.1)
http_parser.rb (0.8.0)

GIT
remote: https://github.com/witgo/nilsimsa
Expand Down Expand Up @@ -360,7 +360,9 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0425)
mimemagic (0.3.5)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
Expand Down Expand Up @@ -717,7 +719,7 @@ DEPENDENCIES
htmlentities (~> 4.3)
http (~> 4.4)
http_accept_language (~> 2.1)
http_parser.rb (~> 0.6)!
http_parser.rb (~> 0.8)!
httplog (~> 1.4.2)
i18n-tasks (~> 0.9)
idn-ruby
Expand Down
15 changes: 15 additions & 0 deletions app/javascript/mastodon/features/account/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const messages = defineMessages({
unendorse: { id: 'account.unendorse', defaultMessage: 'Don\'t feature on profile' },
add_or_remove_from_list: { id: 'account.add_or_remove_from_list', defaultMessage: 'Add or Remove from lists' },
admin_account: { id: 'status.admin_account', defaultMessage: 'Open moderation interface for @{name}' },
nicedb: { id: 'account.nicedb', defaultMessage: 'NiceDB' },
});

const dateFormatOptions = {
Expand Down Expand Up @@ -72,6 +73,12 @@ class Header extends ImmutablePureComponent {
window.open('/settings/profile', '_blank');
}

openNiceDB = () => {
const { account, domain } = this.props;
const acct = account.get('acct').indexOf('@') === -1 && domain ? `${account.get('acct')}@${domain}` : account.get('acct');
window.open(`https://nicedb.org/users/${acct}/`, '_blank');
}

isStatusesPageActive = (match, location) => {
if (!match) {
return false;
Expand Down Expand Up @@ -130,6 +137,7 @@ class Header extends ImmutablePureComponent {

let info = [];
let actionBtn = '';
let NiceDBBtn = '';
let lockedIcon = '';
let menu = [];

Expand Down Expand Up @@ -163,6 +171,12 @@ class Header extends ImmutablePureComponent {
actionBtn = '';
}

if (account.get('acct') === account.get('username')) {
NiceDBBtn = <Button className='logo-button' text={intl.formatMessage(messages.nicedb)} onClick={this.openNiceDB} />;
} else {
NiceDBBtn = '';
}

if (account.get('locked')) {
lockedIcon = <Icon id='lock' title={intl.formatMessage(messages.account_locked)} />;
}
Expand Down Expand Up @@ -272,6 +286,7 @@ class Header extends ImmutablePureComponent {

<div className='account__header__tabs__buttons'>
{actionBtn}
{NiceDBBtn}

<DropdownMenuContainer items={menu} icon='ellipsis-v' size={24} direction='right' />
</div>
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"account.mute_notifications": "Mute notifications from @{name}",
"account.muted": "Muted",
"account.never_active": "Never",
"account.nicedb": "NiceDB",
"account.posts": "Toots",
"account.posts_with_replies": "Toots and replies",
"account.report": "Report @{name}",
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6400,7 +6400,7 @@ noscript {
}

.button {
margin: 0 8px;
margin: 0 8px 0 0;
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/views/accounts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
.spacer
.public-account-header__tabs__tabs__buttons
= account_action_button(account)
= link_to "NiceDB", "https://nicedb.org/users/#{acct(account).gsub(/^@/, '')}/", class: 'button logo-button'

.public-account-header__extra
= render 'accounts/bio', account: account
Expand All @@ -56,4 +57,4 @@
= fa_icon('lock') if account.locked?
.public-account-header__tabs__tabs
.public-account-header__tabs__tabs__buttons
= account_action_button(account)
= account_action_button(account)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@tootsuite/mastodon",
"license": "AGPL-3.0-or-later",
"engines": {
"node": ">=10.13 <13"
"node": ">=10.13"
},
"scripts": {
"postversion": "git push --tags",
Expand Down