| 1 |
<?php |
| 2 |
/** |
| 3 |
* ActivityPub Post JSON template. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
$post = \get_post(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 9 |
$transformer = \Activitypub\Transformer\Factory::get_transformer( $post ); |
| 10 |
|
| 11 |
if ( \is_wp_error( $transformer ) ) { |
| 12 |
\wp_die( |
| 13 |
esc_html( $transformer->get_error_message() ), |
| 14 |
404 |
| 15 |
); |
| 16 |
} |
| 17 |
|
| 18 |
$object = $transformer->to_object(); |
| 19 |
$user = $transformer->get_actor_object(); |
| 20 |
|
| 21 |
?> |
| 22 |
<DOCTYPE html> |
| 23 |
<html> |
| 24 |
<head> |
| 25 |
<meta charset="utf-8"> |
| 26 |
<title><?php echo esc_html( $object->get_name() ); ?></title> |
| 27 |
<style> |
| 28 |
body { |
| 29 |
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; |
| 30 |
font-size: 1em; |
| 31 |
line-height: 1.5; |
| 32 |
margin: 0; |
| 33 |
padding: 0; |
| 34 |
} |
| 35 |
.columns { |
| 36 |
display: flex; |
| 37 |
flex-direction: row; |
| 38 |
justify-content: space-between; |
| 39 |
margin: 0 auto; |
| 40 |
max-width: 1200px; |
| 41 |
} |
| 42 |
.sidebar { |
| 43 |
flex: 1; |
| 44 |
padding: 1em; |
| 45 |
max-width: 285px; |
| 46 |
} |
| 47 |
.sidebar input[type="search"], |
| 48 |
.sidebar textarea { |
| 49 |
background-color: #f6f6f6; |
| 50 |
border: 1px solid #ccc; |
| 51 |
border-radius: 4px; |
| 52 |
box-sizing: border-box; |
| 53 |
color: #333; |
| 54 |
display: block; |
| 55 |
font-size: 1em; |
| 56 |
margin-bottom: 1em; |
| 57 |
padding: 0.5em; |
| 58 |
width: 100%; |
| 59 |
} |
| 60 |
.sidebar > div, |
| 61 |
main address { |
| 62 |
align-items: center; |
| 63 |
display: flex; |
| 64 |
margin-bottom: 1em; |
| 65 |
font-style: normal; |
| 66 |
} |
| 67 |
main address .name, |
| 68 |
main address .webfinger { |
| 69 |
color: #000; |
| 70 |
} |
| 71 |
.name { |
| 72 |
color: #ccc; |
| 73 |
font-weight: bold; |
| 74 |
display: block; |
| 75 |
} |
| 76 |
.webfinger { |
| 77 |
color: #ccc; |
| 78 |
font-size: 0.8em; |
| 79 |
font-weight: bold; |
| 80 |
display: block; |
| 81 |
margin-top: 0.5em; |
| 82 |
} |
| 83 |
address img, .sidebar .fake-image { |
| 84 |
border-radius: 8px; |
| 85 |
margin-right: 1em; |
| 86 |
width: 48px; |
| 87 |
height: 48px; |
| 88 |
background-color: #333; |
| 89 |
} |
| 90 |
main { |
| 91 |
flex: 1; |
| 92 |
border: 1px solid #ccc; |
| 93 |
border-radius: 4px; |
| 94 |
background-color: #fff; |
| 95 |
margin: 1em; |
| 96 |
max-width: 600px; |
| 97 |
} |
| 98 |
main p { |
| 99 |
margin-bottom: 1em; |
| 100 |
} |
| 101 |
.sidebar h1 { |
| 102 |
font-size: 1.5em; |
| 103 |
margin-bottom: 1em; |
| 104 |
margin-top: 0; |
| 105 |
padding: 5px 10px; |
| 106 |
border-radius: 4px; |
| 107 |
background-color: #6364ff; |
| 108 |
color: #fff; |
| 109 |
display: inline-block; |
| 110 |
} |
| 111 |
hr { |
| 112 |
background: transparent; |
| 113 |
border: 0; |
| 114 |
border-top: 1px solid #ccc; |
| 115 |
flex: 0 0 auto; |
| 116 |
margin: 10px 0; |
| 117 |
} |
| 118 |
.sidebar ul { |
| 119 |
list-style-type: none; |
| 120 |
padding: 0; |
| 121 |
} |
| 122 |
.sidebar ul li { |
| 123 |
padding: 5px; |
| 124 |
color: #ccc; |
| 125 |
} |
| 126 |
main article { |
| 127 |
padding: 1em; |
| 128 |
} |
| 129 |
main .content { |
| 130 |
margin: 1em 0; |
| 131 |
font-size: 1.2em; |
| 132 |
} |
| 133 |
main .content h2 { |
| 134 |
font-size: 1.2em; |
| 135 |
} |
| 136 |
main .attachments { |
| 137 |
border-radius: 8px; |
| 138 |
box-sizing: border-box; |
| 139 |
display: grid; |
| 140 |
gap: 2px; |
| 141 |
grid-template-columns: 1fr 1fr; |
| 142 |
grid-template-rows: auto; |
| 143 |
margin: 20px 0; |
| 144 |
min-height: 64px; |
| 145 |
overflow: hidden; |
| 146 |
position: relative; |
| 147 |
width: 100%; |
| 148 |
} |
| 149 |
main .attachments img { |
| 150 |
max-width: 100%; |
| 151 |
height: 100%; |
| 152 |
margin: 1em 0; |
| 153 |
display: inline-block; |
| 154 |
object-fit: cover; |
| 155 |
overflow: hidden; |
| 156 |
} |
| 157 |
main .tags a { |
| 158 |
background-color: #f6f6f6; |
| 159 |
border-radius: 4px; |
| 160 |
color: #333; |
| 161 |
display: inline-block; |
| 162 |
margin-right: 0.5em; |
| 163 |
padding: 0.5em; |
| 164 |
text-decoration: none; |
| 165 |
} |
| 166 |
main .tags a:hover { |
| 167 |
background-color: #e6e6e6; |
| 168 |
text-decoration: underline; |
| 169 |
} |
| 170 |
main .column-header { |
| 171 |
font-size: 1.5em; |
| 172 |
margin: 0; |
| 173 |
padding: 5px 10px; |
| 174 |
border-bottom: 1px solid #ccc; |
| 175 |
vertical-align: middle; |
| 176 |
} |
| 177 |
</style> |
| 178 |
</head> |
| 179 |
<body> |
| 180 |
<div class="columns"> |
| 181 |
<aside class="sidebar"> |
| 182 |
<input type="search" disabled="disabled" placeholder="<?php esc_html_e( 'Search', 'activitypub' ); ?>" /> |
| 183 |
<div> |
| 184 |
<div class="fake-image"></div> |
| 185 |
<div> |
| 186 |
<div class="name"> |
| 187 |
████ ██████ |
| 188 |
</div> |
| 189 |
<div class="webfinger"> |
| 190 |
@█████@██████ |
| 191 |
</div> |
| 192 |
</div> |
| 193 |
</div> |
| 194 |
<textarea rows="10" cols="50" disabled="disabled" placeholder="<?php esc_html_e( 'What\'s up', 'activitypub' ); ?>"></textarea> |
| 195 |
</aside> |
| 196 |
<main> |
| 197 |
<h1 class="column-header"> |
| 198 |
Home |
| 199 |
</h1> |
| 200 |
<article> |
| 201 |
<address> |
| 202 |
<img src="<?php echo esc_url( $user->get_icon()['url'] ); ?>" alt="<?php echo esc_attr( $user->get_name() ); ?>" /> |
| 203 |
<div> |
| 204 |
<div class="name"> |
| 205 |
<?php echo esc_html( $user->get_name() ); ?> |
| 206 |
</div> |
| 207 |
<div class="webfinger"> |
| 208 |
<?php echo esc_html( '@' . $user->get_webfinger() ); ?> |
| 209 |
</div> |
| 210 |
</div> |
| 211 |
</address> |
| 212 |
<div class="content"> |
| 213 |
<?php if ( 'Article' === $object->get_type() && $object->get_name() ) : ?> |
| 214 |
<h2><?php echo esc_html( $object->get_name() ); ?></h2> |
| 215 |
<?php endif; ?> |
| 216 |
<?php echo wp_kses( 'Article' === $object->get_type() ? $object->get_summary() : $object->get_content(), ACTIVITYPUB_MASTODON_HTML_SANITIZER ); ?> |
| 217 |
</div> |
| 218 |
<?php if ( $object->get_attachment() ) : ?> |
| 219 |
<div class="attachments"> |
| 220 |
<?php foreach ( $object->get_attachment() as $attachment ) : ?> |
| 221 |
<?php if ( 'Image' === $attachment['type'] ) : ?> |
| 222 |
<img src="<?php echo esc_url( $attachment['url'] ); ?>" alt="<?php echo esc_attr( $attachment['name'] ?? '' ); ?>" /> |
| 223 |
<?php endif; ?> |
| 224 |
<?php endforeach; ?> |
| 225 |
</div> |
| 226 |
<?php endif; ?> |
| 227 |
<?php if ( $object->get_tag() ) : ?> |
| 228 |
<div class="tags"> |
| 229 |
<?php foreach ( $object->get_tag() as $hashtag ) : ?> |
| 230 |
<?php if ( 'Hashtag' === $hashtag['type'] ) : ?> |
| 231 |
<a href="<?php echo esc_url( $hashtag['href'] ); ?>"><?php echo esc_html( $hashtag['name'] ); ?></a> |
| 232 |
<?php endif; ?> |
| 233 |
<?php endforeach; ?> |
| 234 |
</div> |
| 235 |
<?php endif; ?> |
| 236 |
</article> |
| 237 |
</main> |
| 238 |
<aside class="sidebar"> |
| 239 |
<h1>⁂ Fediverse</h1> |
| 240 |
<ul> |
| 241 |
<li>████████</li> |
| 242 |
<li>███████████</li> |
| 243 |
<li>██████████</li> |
| 244 |
<li>█████████</li> |
| 245 |
<li>███████</li> |
| 246 |
<li>████████</li> |
| 247 |
<li>████████████</li> |
| 248 |
<li>████████████</li> |
| 249 |
<li>██████████</li> |
| 250 |
<li>████████████</li> |
| 251 |
</ul> |
| 252 |
<hr /> |
| 253 |
<ul> |
| 254 |
<li>███████████</li> |
| 255 |
<li>██████████████</li> |
| 256 |
<li>█████████</li> |
| 257 |
</ul> |
| 258 |
<hr /> |
| 259 |
<ul> |
| 260 |
<li>██████████</li> |
| 261 |
</ul> |
| 262 |
</aside> |
| 263 |
</div> |
| 264 |
</body> |
| 265 |
</html> |
| 266 |
|