Skip to content
Permalink
Browse files

friends.nico

  • Loading branch information...
masarakki committed Apr 16, 2017
1 parent 75910ab commit f27a9f0974b4ce2858da6149a34549372994de45
Showing with 398 additions and 23 deletions.
  1. +3 −0 Capfile
  2. +6 −0 Gemfile
  3. +28 −0 Gemfile.lock
  4. BIN app/assets/images/fluffy-elephant-friend.png
  5. +1 −0 app/assets/images/icon_niconico.svg
  6. BIN app/assets/images/mastodon-getting-started.png
  7. BIN app/assets/images/mastodon.jpg
  8. BIN app/assets/images/mastodon_small.jpg
  9. +19 −16 app/assets/javascripts/components/features/account/components/header.jsx
  10. +2 −0 app/assets/javascripts/components/features/compose/index.jsx
  11. +39 −0 app/assets/javascripts/components/features/niconico/components/account_button.jsx
  12. +51 −0 app/assets/javascripts/components/features/niconico/components/connect_account.jsx
  13. +10 −0 app/assets/javascripts/components/features/niconico/containers/connect_account_container.jsx
  14. +1 −0 app/assets/stylesheets/application.scss
  15. +137 −0 app/assets/stylesheets/nico.scss
  16. +19 −0 app/controllers/auth/omniauth_callbacks_controller.rb
  17. +13 −0 app/lib/auth_provider.rb
  18. +21 −0 app/models/user.rb
  19. +1 −1 app/views/about/_links.html.haml
  20. +9 −1 app/views/about/show.html.haml
  21. +6 −1 app/views/accounts/_header.html.haml
  22. +1 −0 app/views/api/v1/accounts/show.rabl
  23. +1 −0 app/views/auth/sessions/new.html.haml
  24. +8 −0 app/views/auth/shared/_omniauth.html.haml
  25. +1 −0 config/environments/staging.rb
  26. +4 −0 config/initializers/devise.rb
  27. +1 −1 config/initializers/rack-attack.rb
  28. +3 −0 config/navigation.rb
  29. +1 −0 config/routes.rb
  30. +1 −1 config/settings.yml
  31. +7 −0 db/migrate/20170416064902_add_omniauth_to_user.rb
  32. +4 −2 db/schema.rb
  33. BIN public/avatars/original/missing.png
@@ -10,5 +10,8 @@ require 'capistrano/yarn'
require 'capistrano/rails/assets'
require 'capistrano/faster_assets'
require 'capistrano/rails/migrations'
require 'capistrano/puma'

install_plugin Capistrano::Puma

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@@ -61,6 +61,7 @@ gem 'whatlanguage'
gem 'react-rails'
gem 'browserify-rails'
gem 'autoprefixer-rails'
gem 'omniauth'

group :development, :test do
gem 'rspec-rails'
@@ -101,3 +102,8 @@ group :production do
gem 'redis-rails'
gem 'lograge'
end

gem 'omniauth-niconico'
group :development do
gem 'capistrano3-puma'
end
@@ -99,6 +99,10 @@ GEM
sshkit (~> 1.3)
capistrano-yarn (2.0.2)
capistrano (~> 3.0)
capistrano3-puma (3.1.0)
capistrano (~> 3.7)
capistrano-bundler
puma (~> 3.4)
capybara (2.13.0)
addressable
mime-types (>= 1.16)
@@ -149,6 +153,8 @@ GEM
fabrication (2.16.1)
faker (1.7.3)
i18n (~> 0.5)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
fast_blank (1.0.0)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
@@ -171,6 +177,7 @@ GEM
hamlit (>= 1.2.0)
railties (>= 4.0.1)
hashdiff (0.3.2)
hashie (3.5.5)
highline (1.7.8)
hiredis (0.6.1)
htmlentities (4.3.4)
@@ -203,6 +210,7 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.0.3)
jwt (1.5.6)
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
@@ -243,13 +251,30 @@ GEM
mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
nio4r (2.0.0)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (2.18.5)
omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-niconico (0.0.1)
omniauth-oauth2
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
openssl (2.0.3)
orm_adapter (0.5.0)
ostatus2 (1.1.0)
@@ -477,6 +502,7 @@ DEPENDENCIES
capistrano-rails
capistrano-rbenv
capistrano-yarn
capistrano3-puma
capybara
devise
devise-two-factor
@@ -504,6 +530,8 @@ DEPENDENCIES
microformats2
nokogiri
oj
omniauth
omniauth-niconico
ostatus2 (~> 1.1)
ox
paperclip (~> 5.1)
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
BIN -50.4 KB (61%) app/assets/images/mastodon.jpg
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@ import emojify from '../../../emoji';
import escapeTextContentForBrowser from 'escape-html';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import IconButton from '../../../components/icon_button';
import AccountButton from '../../niconico/components/account_button';
import { Motion, spring } from 'react-motion';
import { connect } from 'react-redux';

@@ -51,21 +52,24 @@ const Avatar = React.createClass({
const { isHovered } = this.state;

return (
<Motion defaultStyle={{ radius: 90 }} style={{ radius: spring(isHovered ? 30 : 90, { stiffness: 180, damping: 12 }) }}>
{({ radius }) =>
<a
href={account.get('url')}
className='account__header__avatar'
target='_blank'
rel='noopener'
style={{ display: 'block', width: '90px', height: '90px', margin: '0 auto', marginBottom: '10px', borderRadius: `${radius}px`, overflow: 'hidden', backgroundSize: '90px 90px', backgroundImage: `url(${autoPlayGif || isHovered ? account.get('avatar') : account.get('avatar_static')})` }}
onMouseOver={this.handleMouseOver}
onMouseOut={this.handleMouseOut}
onFocus={this.handleMouseOver}
onBlur={this.handleMouseOut}
/>
}
</Motion>
<div style={{ position: 'relative' }}>
<Motion defaultStyle={{ radius: 90 }} style={{ radius: spring(isHovered ? 30 : 90, { stiffness: 180, damping: 12 }) }}>
{({ radius }) =>
<a
href={account.get('url')}
className='account__header__avatar'
target='_blank'
rel='noopener'
style={{ display: 'block', width: '90px', height: '90px', margin: '0 auto', marginBottom: '10px', borderRadius: `${radius}px`, overflow: 'hidden', backgroundSize: '90px 90px', backgroundImage: `url(${autoPlayGif || isHovered ? account.get('avatar') : account.get('avatar_static')})` }}
onMouseOver={this.handleMouseOver}
onMouseOut={this.handleMouseOut}
onFocus={this.handleMouseOver}
onBlur={this.handleMouseOut}
/>
}
</Motion>
<AccountButton account={account} />
</div>
);
}

@@ -130,7 +134,6 @@ const Header = React.createClass({
<div className='account__header' style={{ backgroundImage: `url(${account.get('header')})` }}>
<div style={{ padding: '20px 10px' }}>
<Avatar account={account} autoPlayGif={this.props.autoPlayGif} />

<span style={{ display: 'inline-block', fontSize: '20px', lineHeight: '27px', fontWeight: '500' }} className='account__header__display-name' dangerouslySetInnerHTML={displayNameHTML} />
<span className='account__header__username' style={{ fontSize: '14px', fontWeight: '400', display: 'block', marginBottom: '10px' }}>@{account.get('acct')} {lockedIcon}</span>
<div style={{ fontSize: '14px' }} className='account__header__content' dangerouslySetInnerHTML={content} />
@@ -1,6 +1,7 @@
import ComposeFormContainer from './containers/compose_form_container';
import UploadFormContainer from './containers/upload_form_container';
import NavigationContainer from './containers/navigation_container';
import ConnectAccountContainer from '../niconico/containers/connect_account_container';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import { connect } from 'react-redux';
import { mountCompose, unmountCompose } from '../../actions/compose';
@@ -67,6 +68,7 @@ const Compose = React.createClass({
<div className='drawer__pager'>
<div className='drawer__inner'>
<NavigationContainer />
<ConnectAccountContainer />
<ComposeFormContainer />
</div>

@@ -0,0 +1,39 @@
import PureRenderMixin from 'react-addons-pure-render-mixin';
import ImmutablePropTypes from 'react-immutable-proptypes';

const AccountButton = React.createClass({

propTypes: {
account: ImmutablePropTypes.map.isRequired
},

mixins: [PureRenderMixin],

render() {
const { account } = this.props;

if (!account) {
return null;
}

const nicoUrl = account.get('nico_url');

if (nicoUrl === null) {
return null;
}

return (
<div className="nico-account-button">
<a
href={nicoUrl}
target="_blank"
rel="noopener"
>
<i className="nico-account-button__icon" />
</a>
</div>
);
}
});

export default AccountButton;
@@ -0,0 +1,51 @@
import PureRenderMixin from 'react-addons-pure-render-mixin';
import ImmutablePropTypes from 'react-immutable-proptypes';

const ConnectAccount = React.createClass({

propTypes: {
account: ImmutablePropTypes.map.isRequired
},

mixins: [PureRenderMixin],

render() {
const { account } = this.props;

if (!account) {
return <div />;
}

const nico_url = account.get('nico_url');
const connectLink = nico_url !== null ?
(
<a
href={nico_url}
target="_blank"
rel="noopener"
>
<span className="nico-connect-account__label">
niconicoアカウントと連携済み
</span>
</a>
) :
(
<a
className="nico-connect-account__wrapper"
href="/auth/auth/niconico"
>
<span className="nico-connect-account__label nico-connect-account__label--disabled">
niconicoアカウントと連携する
</span>
</a>
);

return (
<div className="nico-connect-account">
{connectLink}
</div>
);
}
});

export default ConnectAccount;
@@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import ConnectAccount from '../components/connect_account';

const mapStateToProps = (state, props) => {
return {
account: state.getIn(['accounts', state.getIn(['meta', 'me'])])
};
};

export default connect(mapStateToProps)(ConnectAccount);
@@ -18,3 +18,4 @@
@import 'about';
@import 'tables';
@import 'admin';
@import 'nico';
Oops, something went wrong.

0 comments on commit f27a9f0

Please sign in to comment.
You can’t perform that action at this time.