From 246d335df97718d896501517a000fb4d06e86b0f Mon Sep 17 00:00:00 2001 From: Sebastian Jambor Date: Wed, 25 Jan 2023 21:34:01 +0100 Subject: [PATCH] starting to add explorer --- .../mastodon/features/activity_log/index.js | 3 +- .../features/activitypub_explorer/index.js | 69 +++++++++++++++++++ .../ui/components/navigation_panel.js | 2 + app/javascript/mastodon/features/ui/index.js | 8 +++ .../features/ui/util/async-components.js | 4 ++ config/routes.rb | 1 + package.json | 2 +- yarn.lock | 8 +-- 8 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 app/javascript/mastodon/features/activitypub_explorer/index.js diff --git a/app/javascript/mastodon/features/activity_log/index.js b/app/javascript/mastodon/features/activity_log/index.js index c37075740..ddf383eea 100644 --- a/app/javascript/mastodon/features/activity_log/index.js +++ b/app/javascript/mastodon/features/activity_log/index.js @@ -8,8 +8,7 @@ import ColumnHeader from 'mastodon/components/column_header'; import { HotKeys } from 'react-hotkeys'; import DismissableBanner from 'mastodon/components/dismissable_banner'; -import ActivityPubVisualization from 'activitypub-visualization'; - +import { ActivityPubVisualization } from 'activitypub-visualization'; const mapStateToProps = (state) => { return { diff --git a/app/javascript/mastodon/features/activitypub_explorer/index.js b/app/javascript/mastodon/features/activitypub_explorer/index.js new file mode 100644 index 000000000..d94946d2f --- /dev/null +++ b/app/javascript/mastodon/features/activitypub_explorer/index.js @@ -0,0 +1,69 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import { FormattedMessage } from 'react-intl'; +import PropTypes from 'prop-types'; +import Column from 'mastodon/components/column'; +import ColumnHeader from 'mastodon/components/column_header'; +import { HotKeys } from 'react-hotkeys'; +import DismissableBanner from 'mastodon/components/dismissable_banner'; + +import { ActivityPubExplorer as Explorer } from 'activitypub-visualization'; + + +const mapStateToProps = (state) => { + return { + logs: state.getIn(['activity_log', 'logs']), + }; +}; + +export default @connect(mapStateToProps) +class ActivityPubExplorer extends ImmutablePureComponent { + + static propTypes = { + multiColumn: PropTypes.bool, + }; + + + handleHeaderClick = () => { + this.column.scrollTop(); + } + + setRef = c => { + this.column = c; + } + + render() { + + const { logs, multiColumn } = this.props; + + const darkMode = !(document.body && document.body.classList.contains('theme-mastodon-light')); + + return ( + + + + +

+ blog, + }} + /> +

+
+ +
Hello world
+
+ ); + } + +} + diff --git a/app/javascript/mastodon/features/ui/components/navigation_panel.js b/app/javascript/mastodon/features/ui/components/navigation_panel.js index 77adce4b6..81747004f 100644 --- a/app/javascript/mastodon/features/ui/components/navigation_panel.js +++ b/app/javascript/mastodon/features/ui/components/navigation_panel.js @@ -88,6 +88,8 @@ class NavigationPanel extends React.Component { + +
diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js index 4d7986974..81c60ff2c 100644 --- a/app/javascript/mastodon/features/ui/index.js +++ b/app/javascript/mastodon/features/ui/index.js @@ -50,6 +50,7 @@ import { PinnedStatuses, Lists, ActivityLog, + ActivityPubExplorer, Directory, Explore, FollowRecommendations, @@ -108,6 +109,7 @@ const keyMap = { goToMuted: 'g m', goToRequests: 'g r', goToActivityLog: 'g a', + goToActivityPubExplorer: 'g e', toggleHidden: 'x', toggleSensitive: 'h', openMedia: 'e', @@ -219,6 +221,7 @@ class SwitchingColumnsArea extends React.PureComponent { + @@ -494,6 +497,10 @@ class UI extends React.PureComponent { this.context.router.history.push('/activity_log'); } + handleHotkeyGoToActivityPubExplorer = () => { + this.context.router.history.push('/activitypub_explorer'); + } + handleHotkeyGoToNotifications = () => { this.context.router.history.push('/notifications'); }; @@ -552,6 +559,7 @@ class UI extends React.PureComponent { back: this.handleHotkeyBack, goToHome: this.handleHotkeyGoToHome, goToActivityLog: this.handleHotkeyGoToActivityLog, + goToActivityPubExplorer: this.handleHotkeyGoToActivityPubExplorer, goToNotifications: this.handleHotkeyGoToNotifications, goToLocal: this.handleHotkeyGoToLocal, goToFederated: this.handleHotkeyGoToFederated, diff --git a/app/javascript/mastodon/features/ui/util/async-components.js b/app/javascript/mastodon/features/ui/util/async-components.js index 22d225b1f..43d3035c7 100644 --- a/app/javascript/mastodon/features/ui/util/async-components.js +++ b/app/javascript/mastodon/features/ui/util/async-components.js @@ -42,6 +42,10 @@ export function ActivityLog () { return import(/* webpackChunkName: "features/activity_log" */'../../activity_log'); } +export function ActivityPubExplorer () { + return import(/* webpackChunkName: "features/activity_log" */'../../activitypub_explorer'); +} + export function Status () { return import(/* webpackChunkName: "features/status" */'../../status'); } diff --git a/config/routes.rb b/config/routes.rb index 50c05b65c..7b1dbbec4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,6 +25,7 @@ Rails.application.routes.draw do /publish /follow_requests /activity_log + /activitypub_explorer /blocks /domain_blocks /mutes diff --git a/package.json b/package.json index b70102c64..0c350c92d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@github/webauthn-json": "^0.5.7", "@rails/ujs": "^6.1.7", "abortcontroller-polyfill": "^1.7.5", - "activitypub-visualization": "^1.0.0", + "activitypub-visualization": "^1.1.0", "array-includes": "^3.1.6", "arrow-key-navigation": "^1.2.0", "autoprefixer": "^9.8.8", diff --git a/yarn.lock b/yarn.lock index 3721f03fe..2d99c6bed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2190,10 +2190,10 @@ acorn@^8.8.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== -activitypub-visualization@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/activitypub-visualization/-/activitypub-visualization-1.0.0.tgz#728ce9a20336bf927980748c37c8b5206cafecac" - integrity sha512-azxnf4POMTsI8J0PiOXeD70wZvxAd6KdcD2YIE+AqkW00Fgg39Jxi+OcImc8GoAiUh7dpFp6nLA+WVH4uVnIEw== +activitypub-visualization@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/activitypub-visualization/-/activitypub-visualization-1.1.0.tgz#db7875657aa3215f6d7be16795964c82c1021efe" + integrity sha512-0DrnCdmpx5551q0vZiQYHu3ZsVVFP0JJKLHQpbLmgetVJxGjRoZC7iwjh+tvyYixBhUneIAhVJ2VH0bugiAwFA== agent-base@6: version "6.0.2"