Commit 27b9605d authored by kaniini's avatar kaniini

Merge branch 'rich_media_titles_two' into 'develop'

Rich media titles two

See merge request !1325
parents 8b7860f1 0e415921
Pipeline #13730 passed with stages
in 44 minutes and 13 seconds
defmodule Pleroma.Web.RichMedia.Parsers.MetaTagsParser do
def parse(html, data, prefix, error_message, key_name, value_name \\ "content") do
with elements = [_ | _] <- get_elements(html, key_name, prefix),
meta_data =
Enum.reduce(elements, data, fn el, acc ->
attributes = normalize_attributes(el, prefix, key_name, value_name)
meta_data =
html
|> get_elements(key_name, prefix)
|> Enum.reduce(data, fn el, acc ->
attributes = normalize_attributes(el, prefix, key_name, value_name)
Map.merge(acc, attributes)
end) do
{:ok, meta_data}
Map.merge(acc, attributes)
end)
|> maybe_put_title(html)
if Enum.empty?(meta_data) do
{:error, error_message}
else
_e -> {:error, error_message}
{:ok, meta_data}
end
end
......@@ -27,4 +31,19 @@ defp normalize_attributes(html_node, prefix, key_name, value_name) do
%{String.to_atom(data[key_name]) => data[value_name]}
end
defp maybe_put_title(%{title: _} = meta, _), do: meta
defp maybe_put_title(meta, html) when meta != %{} do
case get_page_title(html) do
"" -> meta
title -> Map.put_new(meta, :title, title)
end
end
defp maybe_put_title(meta, _), do: meta
defp get_page_title(html) do
Floki.find(html, "title") |> Floki.text()
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
<meta charset="UTF-8">
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-57x57.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-114x114.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-72x72.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-144x144.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-60x60.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-120x120.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-76x76.png?nc=1" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://img.mfcimg.com/images/favicons/apple-touch-icon-152x152.png?nc=1" />
<link rel="icon" type="image/png" href="https://img.mfcimg.com/images/favicons/favicon-196x196.png?nc=1" sizes="196x196" />
<link rel="icon" type="image/png" href="https://img.mfcimg.com/images/favicons/favicon-96x96.png?nc=1" sizes="96x96" />
<link rel="icon" type="image/png" href="https://img.mfcimg.com/images/favicons/favicon-32x32.png?nc=1" sizes="32x32" />
<link rel="icon" type="image/png" href="https://img.mfcimg.com/images/favicons/favicon-16x16.png?nc=1" sizes="16x16" />
<link rel="icon" type="image/png" href="https://img.mfcimg.com/images/favicons/favicon-128.png?nc=1" sizes="128x128" />
<meta name="application-name" content="MyFreeCams.com Profiles" />
<meta name="msapplication-TileColor" content="#008000" />
<meta name="msapplication-TileImage" content="https://img.mfcimg.com/images/favicons/mstile-144x144.png?nc=1" />
<meta name="msapplication-square70x70logo" content="https://img.mfcimg.com/images/favicons/mstile-70x70.png?nc=1" />
<meta name="msapplication-square150x150logo" content="https://img.mfcimg.com/images/favicons/mstile-150x150.png?nc=1" />
<meta name="msapplication-wide310x150logo" content="https://img.mfcimg.com/images/favicons/mstile-310x150.png?nc=1" />
<meta name="msapplication-square310x310logo" content="https://img.mfcimg.com/images/favicons/mstile-310x310.png?nc=1" />
<script src="https://img.mfcimg.com/profiles/jquery/jquery-1.9.1.min.js"></script>
<script src="https://img.mfcimg.com/profiles/jquery/jquery-ui-1.9.2.min.js"></script>
<script src="https://img.mfcimg.com/profiles/jquery/jquery.ui.touch-punch.min.js"></script> <script>
var g_hPlatform = { "id": 1, "domain": "myfreecams.com", "name": "MyFreeCams", "code": "mfc", "image_url": "https://img.mfcimg.com/" };
try { document.domain = 'myfreecams.com'; } catch (e) {}
var MfcAssets = {
images: "/bundles/mfcprofile/vendor/img/",
urls: {
www: "https://www.myfreecams.com/",
new_comments: "/BlueAngelLove/comments/since/0"
}
};
var MfcPageVars = {
userId: 0,
accessLevel: 0,
token: "xIqyjzUBSrt6Rbl_su7UOrDxNZJlZNc4nsWh6eXxDkg",
profileState: {"number":127,"string":"Offline"},
serverTime: {"unixTime":1561209909,"time":"6:25am PDT","dst":1},
profileUsername: "BlueAngelLove",
admirers: 4719,
username: "",
userPhotoUrl: "",
vToken: "4c4ea23b221f89b73c964b7f99a50f78",
avatarRev: 0,
avgRating: {"rating_count":7060,"rating_average":"4.8681"},
rating: 0
};
function MfcProfilePage( jQuery )
{
var _self = this;
_self.$ = jQuery;
_self.token = ( typeof(MfcPageVars) !== 'undefined' && MfcPageVars.token ) ? MfcPageVars.token : _self.$('meta[name=token]').attr('content');
_self.beforeDomReady();
_self.$(function(){ _self.afterDomReady(); });
};
MfcProfilePage.prototype.beforeDomReady = function()
{
var _self = this;
var $ = _self.$;
if ( _self.token )
{
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if ( settings.type === 'GET' || settings.crossDomain )
return;
if ( $.type(settings.data) === 'object' && $.type(settings.data.append) === 'function' )
{
settings.data.append('_token', _self.token);
}
else if ( $.type(settings.data) === 'string' && settings.data.indexOf('_token=') === -1 )
{
if ( settings.data.length === 0 )
{
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
} else {
settings.data += '&';
}
settings.data += encodeURIComponent('_token') + '=' + encodeURIComponent(_self.token);
}
}
});
$(document).on('submit', 'form', function(e)
{
if ( ! $(this).find('#_token').length && ! $(this).data('mfc-no-token') )
$(this).append($('<input type="hidden" name="_token" id="_token" value="' + _self.token + '">'));
});
}
};
MfcProfilePage.prototype.afterDomReady = function()
{
var _self = this;
var $ = this.$;
var page = $('body').data('mfc-page');
if ( $.isFunction(_self[page]) )
_self[page]();
};
new MfcProfilePage(jQuery);
</script>
<link href="https://img.mfcimg.com/profiles/prod/22793316144741120/css/profiles.css?nc=22793316144741120" type="text/css" rel="stylesheet">
<title>BlueAngelLove's Homepage on MyFreeCams.com</title>
<meta name="description" content="BlueAngelLove's webcam homepage on MyFreeCams.com - your #1 adult webcam community">
<meta name="keywords" content="webcams,models,adult,community,nude,chat,video">
<style type="text/css">
body.mfc_display_inline_mode #header_bar, body.mfc_display_inline_mode #footer_bar {
visibility: hidden;
}
body.mfc_profile_standard.mfc_display_inline_mode {
margin-left: 0;
margin-right: 0;
padding-left: 5px;
padding-right: 5px;
}
body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me {
display: flex;
flex-flow: wrap;
}
body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me .heading {
flex: 0 0 100%;
}
body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me .container {
flex: 0 1 50%;
margin: 0;
padding: 0;
}
body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me #about_me_container, body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me #tags_container {
flex: 0 0 100%;
margin-top: 0;
margin-bottom: 0;
}
@media (max-width: 850px) {
body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me .container {
flex: 0 0 100%;
}
}
@media (min-width: 1500px) {
body.mfc_profile_standard.mfc_display_inline_mode #profile_about_me .container {
flex: 0 0 33%;
}
}
</style>
<link href="/BlueAngelLove/css?nc=204272526" rel="stylesheet" type="text/css">
<script type="text/javascript">
g_bInIframe = (function(w) {
try {
return w.self !== w.top;
} catch (e) {
return true;
}
return false;
})(window);
(function(w,d) {
'use strict';
var hrefClickFn = function (e) {
e = e || w.event;
var target = findHrefElFn(e.target || e.srcElement);
if ( target != undefined && ((target.hostname + target.pathname.replace(/(^\/?)/,'/')).toLowerCase() !== (location.hostname + location.pathname).toLowerCase()) ) {
target.setAttribute('target', '_blank');
target.setAttribute('rel', 'noopener noreferrer');
}
return true;
};
var isHrefElFn = function(el) {
var elName = (el.nodeName || el.tagName).toLowerCase();
if ( (elName === 'a' || elName === 'area') && el.href != undefined ) { return true; }
return false;
};
var findHrefElFn = function(el) {
if ( isHrefElFn(el) ) { return el; }
while (el = el.parentNode) {
if ( isHrefElFn(el) ) { return el; }
}
return undefined;
};
if ( g_bInIframe ) {
if ( d.addEventListener ) {
d.addEventListener('click', hrefClickFn);
} else {
d.attachEvent('onclick', hrefClickFn);
}
}
})(window, document);
</script>
</head>
<body class="mfc_profile_customized" data-mfc-page="userShow">
<script type="text/javascript">
(function(w,d,v) {
'use strict';
var classes = [];
var search = w.location.search || '';
var vs = (typeof v === 'object' && v.profileState) ? v.profileState.number : 127;
if ( search.match(/[?&]inline_mode=1/) ) {
classes.push('mfc_display_inline_mode');
}
if ( search.match(/[?&]online=1/) || vs != 127 ) {
classes.push('mfc_online');
}
if ( 'Model' === 'Model' && ( search.match(/[?&]broadcasting=1/) || vs < 90 ) ) {
classes.push('mfc_broadcasting');
}
if ( classes.length ) {
d.getElementsByTagName('body')[0].className += ' ' + classes.join(' ');
}
})(window, document, MfcPageVars);
</script>
<div id="fixed_background"></div>
<div id="header_bar">
<div class="header_links">
<a href="/">Profiles.MyFreeCams.com</a> |
<a href='https://www.myfreecams.com/'>MyFreeCams.com</a> |
<a href="/_/my_profile">My Profile</a> |
<a href="/_/login">Profile Settings</a>
</div>
<div class="clearfix header_time">
<div id="server_time">
<table>
<tbody>
<tr>
<td>Your Time:</td>
<td id="your_time"></td>
</tr>
<tr>
<td>MyFreeCams Time:</td>
<td id="mfc_time"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="profile">
<div class="profile_row">
<div class="profile_section" id="profile_header">
<div class="profile_section_content">
<div class="profile_section_background"></div>
<div id="avatar_holder">
<img id="profile_avatar" class="img_radius_shadow" src="https://img.mfcimg.com/photos2/320/3204009/avatar.90x90.jpg?nc=1557647675" onError="this.onerror=null; this.src='https://img.mfcimg.com/images/nophoto-f.gif';">
</div>
<div id="profile_header_container">
<div class="heading">
BlueAngelLove
</div>
<div class="container" id="status_container">
<div class="label" id="status_label">
Status:
</div>
<div class="value" id="status_value">
<span id="member_status_value" class="hidden"></span>
<span id="member_type_value">&nbsp;- Model -</span>
<span id="member_message_value" class="hidden" data-mfc-member-type="Model"><a href="#" id="show_message_dialog">Send a MyFreeCams Mail</a></span>
</div>
</div>
<div class="container" id="blurb_container">
<span class="label" id="blurb_label">
Profile Headline:
</span>
<span class="value" id="blurb_value">
Enjoy and Love
</span>
</div>
<div class="container" id="unix_last_broadcast_container">
<span class="label" id="unix_last_broadcast_label">
Last Broadcast:
</span>
<span class="value convert-time" id="unix_last_broadcast_value" data-mfc-unix-time="1561100400" data-mfc-time-format="ddd, MMM D YYYY"></span>
</div>
<div class="container" id="unix_last_updated_container">
<span class="label" id="unix_last_updated_label">
Last Updated:
</span>
<span class="value convert-time" id="unix_last_updated_value" data-mfc-unix-time="1561193088" data-mfc-time-format="llll"></span>
</div>
</div>
</div>
</div>
</div>
<div class="profile_row" id="profile_main_about_holder">
<div id="profile_main_photo">
<div class="profile_section">
<div class="profile_section_content">
<div class="profile_section_background"></div>
<div class="heading">
My Most Recent Pictures
</div>
<div class="recent_photos">
<img src="https://img.mfcimg.com/photos2/320/3204009/986-665-202-679-12065535.80x80.jpg" class="img_radius_shadow show_preview" onError="this.onerror=null; this.src='https://img.mfcimg.com/images/nophoto-f.gif';" data-mfc-preview="https://img.mfcimg.com/photos2/320/3204009/986-665-202-679-12065535.250.jpg">
</div>
</div>
</div>
</div>
<div class="profile_section" id="profile_about_me_friends">
<div class="profile_section_content">
<div class="profile_section_background"></div>
<div class="profile_subsection" id="profile_about_me">
<div class="heading">
About Me
</div>
<div class="container" id="username_container">
<span class="label" id="username_label">
Username:
</span>
<span class="value" id="username_value">
BlueAngelLove </span>
</div>
<div class="container" id="gender_container">
<span class="label" id="gender_label">
Gender:
</span>
<span class="value" id="gender_value">
Female </span>
</div>
<div class="container" id="body_type_container">
<span class="label" id="body_type_label">
Body Type:
</span>
<span class="value" id="body_type_value">
Athletic </span>
</div>
<div class="container" id="ethnicity_container">
<span class="label" id="ethnicity_label">
Ethnicity:
</span>
<span class="value" id="ethnicity_value">
Other </span>
</div>
<div class="container" id="hair_container">
<span class="label" id="hair_label">
Hair:
</span>
<span class="value" id="hair_value">
Brown </span>
</div>
<div class="container" id="eyes_container">
<span class="label" id="eyes_label">
Eyes:
</span>
<span class="value" id="eyes_value">
Blue </span>
</div>
<div class="container" id="weight_container">
<span class="label" id="weight_label">
Weight:
</span>
<span class="value" id="weight_value">
45 kilos </span>
</div>
<div class="container" id="height_container">
<span class="label" id="height_label">
Height:
</span>
<span class="value" id="height_value">
165 centimeters </span>
</div>
<div class="container" id="age_container">
<span class="label" id="age_label">
Age:
</span>
<span class="value" id="age_value">
34 </span>
</div>
<div class="container" id="city_container">
<span class="label" id="city_label">
City:
</span>
<span class="value" id="city_value">
Mountains </span>
</div>
<div class="container" id="sexual_preference_container">
<span class="label" id="sexual_preference_label">
Sexual Preference:
</span>
<span class="value" id="sexual_preference_value">
Bisexual </span>
</div>
<div class="container" id="smoke_container">
<span class="label" id="smoke_label">
Smoke:
</span>
<span class="value" id="smoke_value">
Non Smoker </span>
</div>
<div class="container" id="drink_container">
<span class="label" id="drink_label">
Drink:
</span>
<span class="value" id="drink_value">
Non Drinker </span>
</div>
<div class="container" id="drugs_container">
<span class="label" id="drugs_label">
Drugs:
</span>
<span class="value" id="drugs_value">
Never </span>
</div>
<div class="container" id="occupation_container">
<span class="label" id="occupation_label">
Occupation/Major:
</span>
<span class="value" id="occupation_value">
Guide </span>
</div>
<div class="container" id="favorite_food_container">
<span class="label" id="favorite_food_label">
Favorite Food:
</span>
<span class="value" id="favorite_food_value">
Chocolate </span>
</div>
<div class="container" id="pets_container">
<span class="label" id="pets_label">
Pets:
</span>
<span class="value" id="pets_value">
I dont like pets </span>
</div>
<div class="container" id="automobile_container">
<span class="label" id="automobile_label">
Automobile:
</span>
<span class="value" id="automobile_value">