I want to use the h-card microformats on my new website.
How do I add social media profiles like twitter, facebook, etc to my h-card in a correct way?
For phone numbers it is possible to add a type attribute. Like 'cell', 'home', or whatever you want.
Is it OK when I do this with social media profiles too? Like:
<span class="u-url">
<span class="type">Twitter</span>:
<span class="value">http://twitter.com/blabla</span>
</span>
According to this page of the documentation this should be possible. But all the tutorials I've found about h-card or hcard just add all the social media profiles without a type attribute. So I'm not sure what's the right way to do it.
There is a note on the microformats2 site at the microformats wiki:
Note: use of 'value' within 'tel' should be automatically handled by
the support of the value-class-pattern. And for now, the 'type'
subproperty of 'tel' is dropped/ignored. If there is demonstrable
documented need for additional tel types (e.g. fax), we can introduce
new flat properties as needed (e.g. p-gel-fax).
That means that the value-class-pattern is not yet supported by the mf2 spec, but you can try the vendor prefixes and use for example u-x-twitter u-url instead of u-url.
This for example:
<div class="h-card">Twitter</div>
would be interpreted like:
{
"items": [
{
"type": [
"h-card"
],
"properties": {
"x-twitter": [
"http:\/\/twitter.com\/blabla"
],
"url": [
"http:\/\/twitter.com\/blabla"
],
"name": [
"Twitter"
]
}
}
],
"rels": {}
}
BTW: You can try/validate your code here: http://pin13.net
Related
<Form.Group controlId="phoneName">
<Form.Label>Phone Names</Form.Label>
<Form.Control
as="select"
name="phoneName"
value={values.phoneName}
onChange={handleChange}
isInvalid={!!errors.phoneName && !!touched.phoneName}
>
{phones.map((item, index) => {
return (
<div key={index}>
{item.phoneName.map((phone, index) => {
return <option key={index}>{phone.name}</option>;
})}{" "}
</div>
);
})}
</Form.Control>
<Form.Control.Feedback type="invalid">
{" "}
{errors.phoneName}{" "}
</Form.Control.Feedback>
</Form.Group>;
The output prints then then tags, and dropdown is empty but can see result in inspect-->elements-->and in the html i selected the dropdown and saw the result, the values are coming from JSON which is in another branch of GitHub so i use API call to get data and it works fine,
so i use a dropdown first to get the item phone and after that i want to select from the dropdown called phoneName to get options like nokia, samsung etc. but only the tag thing doesn't print correct values in the form control
[
{
gadgets: "phone",
phoneName: [
{ name: "nokia", phoneColor: "blue", memory: "enough" },
{ name: "samsung", phoneColor: "black", memory: "little" },
],
},
{
gadgets: "ipad",
phoneName: [
{ name: "apple", phoneColor: "white", memory: "high" },
{ name: "samsung-g", phoneColor: "black", memory: "low" },
],
},
];
I am unsure as to what library you're using for your form and there's no clear example of what you're trying to achieve but the following might send you in the right direction.
Firstly, you're trying to render a div inside a select list. Select lists generally take options. Once again I'm not sure of the lib you're using so can't make an accurate assumption
Secondly you had an error in your code which I have fixed through editing your post. On line 2 you had typed <Form.Label>Phone Names</<Form.Label>. The closing tag is incorrect
My personal opinion is that your data is not labeled in the most optimized way. I would change phoneName to gadgetList since the array holds all the gadgets associated with the gadget property
For the results I think you're trying to achieve, you could try the following:
{data.map((item,index) => {
return (
<div key={item + index}>
<h4>{item.gadgets}</h4>
<select>
{item.phoneName.map((gadget) => (
<option>{gadget.name}</option>
))}
</select>
</div>
);
})}
This would essentially map out 2 divs with 2 select lists. The select options would be the phone names.
An example can be seen here : https://codesandbox.io/s/silly-maxwell-tylpwd?file=/src/App.js
Hopefully this can help you. If not, please put your code into a sandbox so we can help assist you better in solving the problem :)
I am currently working on a laravel application where users can add content like articles and those article are searchable via a search engine. I would like to implement a modern full text search solution.
But the fact is it is possible for a user to put an article as private making it readable only by his followers or friends.
Implementing in simple SQL would be simple using a simple where clause on a pivot table relationship, but this is all but performant on large databases.
I made research's and devs on elastic search and other search engines but the limitation is that all the dataset is searchable and I cannot customize the filters according to a user defined relationship.
Should I create one index per user instead of having a global index ? This seems to have a huge impact also
I would really appreciate any of your thought about this, thanks in advance.
Try changing the perspective when looking at the problem.
Instead of thinking in terms of an article being accessible by certain groups of users, think in terms of a user and what articles she/he can access.
The search is always performed by a specific user, so it's known whom she/he follows (followed_user_ids) and is friends with (friend_ids). This information can be used at query build time.
The example query could look like this:
{
"query": {
"bool": {
"should": [
{
"term": {
"private": false
}
},
{
"bool": {
"filter": [
{
"term": {
"private": true
}
}
],
"should": [
{
"terms": {
"author_id": followed_user_ids,
}
},
{
"terms": {
"author_id": friend_ids,
}
}
],
"minimum_should_match": 1
}
}
]
}
}
}
It would find articles that:
are not private (visible to all); or
are private, but authored by friends or users followed by the current user
you can do this in Elasticsearch a few ways, that I can think of
ideally use document level security as it's the most secure approach, but don't use filtered aliases with this
add a boolean private field that you can then filter on. this is far less secure than DLS from above
if you've tried that second approach, then sharing what you did and what didn't work would help
As the title states, im trying to make a query that doesnt return the entire document, but only certain fields, but with multiple exact terms.
Im using Guzzle from laravel to contruct my query:
$response = $client->post('cvr-permanent/_search', [
'auth' => ['USERNAME', 'PASSWORD'],
'json' => [
"_source" => ["Vrvirksomhed.attributter", "Vrvirksomhed.deltagerRelation.organisationer.medlemsData.attributter"],
"query" => [
"bool"=> [
"must"=> [
[
"term"=> [
"Vrvirksomhed.cvrNummer" => $vat
]
]],
"must_not"=> [ ],
"should"=> [ ]
]
],
"from"=> 0,
"size"=> 10,
"sort"=> [ ]
]
]);
I want the data from the Vrvirksomhed.cvrNummer and the data i want is where Vrvirksomhed.attributter.type => "KAPITAL" and Vrvirksomhed.deltagerRelation.deltager.navne and where Vrvirksomhed.deltagerRelation.organisation.attributter.type = "EJERANDEL_PROCENT"
Im very confused about how to make this query work because it is multiple terms but not really. Also very new to elasticsearch.
I tried the "terms" but couldnt really get it to work.
The query i have made above, return way too much data i dont need, and not all the data i DO need.
Hope you can help
**EDIT
Something like this maybe, but translated to elasticsearch
SELECT attributter.type": "KAPITAL" AND deltagerRelation.deltager.navne AND deltagerRelation.organisation.attributter.type": "EJERANDEL_PROCENT FROM Vrvirksomhed WHERE cvrNummer = $vat
***EDIT
Hopefully more clarification:
Okay, sorry ill try to make it clearer. The object i want is a company with a certain vat number. So Vrvirksomhed.cvrNummer is that, and that has to be the term. It returns a gigantic object with so many arrays in arrays. I do not want all of this data but only some of it. The data i need from this big object, is the object in the array Vrvirksomhed.attributter that has the type : "KAPITAL field, and not all of the attributter. Then i want Vrvirksomhed.deltagerRelation.deltager.navne which i can get by just putting it in the _source because i want all of these objects. But then i want Vrvirksomhed. deltagerRelation.organisation.attributter that again is a bunch of objects in the array attributter but i only want the ones with the type : "EJERANDEL_PROCENT
So i can´t really add them as additional "terms" because the only real term is the "cvrNummer", everything else is just filtering the response. I tried with filters etc, but to no avail
Heres a pastebin so you can see the clusterfuck i am dealing with. THis is what i have been able to sort it to so far, with putting the things in _source but without the extra "filtering" of "KAPITAL" and "EJERANDEL_PROCENT"
https://pastebin.com/b8hWWz1R
You want to get only documents which match several conditions, and you need only a subset of fields from those documents, correct?
In SQL (taking some liberties with the field names and structure), your query would be something like:
SELECT cvrNummer
FROM Vrvirksomhed
WHERE attributter_type = 'KAPITAL'
AND deltagerRelation_deltager_navne = 'you left this out in your question'
AND deltagerRelation_organisation_attributter_type = 'EJERANDEL_PROCENT'
As explained in the Elasticsearch Guide†, the equivalent to this in Elasticsearch is a query with a bool clause that contains all your conditions, and a _source parameter which says what fields you want to get back in the response. Something like the following:
{
"_source": ["cvrNummer"]
"query": {
"bool": {
"must": [
{ "term": "attributter.type": "KAPITAL" },
{ "term": "deltagerRelation.deltager.navne": "you left this out in your question" },
{ "term": "deltagerRelation.organisation.attributter.type": "EJERANDEL_PROCENT" }
]
}
}
}
† Do note that the syntax in this guide is for Elasticsearch 2.x. The current version is 7.x, and many things have changed since then!
See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html for how to construct a bool query using the new syntax;
see https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html for how to use the term-level queries, which you probably want;
also see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html and consider using filter context, since you probably don't care about the score of your query.
I am trying to generate dynamic URL's using yii2 routing, but I didnt find any proper example for what I am looking for
I have a page which has list of users. If I click on any user name it gets redirected to particular user's profile page.
The URL for profile page is like
https://www.example.com/frontend/web/users/profile?id=1&name=xyz
I want to show this URL as https://www.example.com/xyz where xyz is users name.
I have seen examples of pretty URL's but couldnt find any specific example.
How to such dynamic URL's. Please help.
You cannot fully remove static link from link. You can leave profile and remove other. Then your link will be https://www.example.com/profile/xyz
First of all add to config:
'urlManager' => [
'showScriptName' => false,
'enablePrettyUrl' => true,
'rules' => [
'profile/<name>' => 'users/profile',
...
],
Change your action:
public function actionProfile($name) {
$user= User::findOne(['name'=>$name]);
This is my testing case for design a english-khmer document dictionary.
<?php
error_reporting(E_ALL);
$json ='{
"word": "think",
"khmer" :
[
{
"type":["Verb — past tense: thought ; past participle: thought ; present participle: thinking ; "] ,
"meaning":
[
"(INTRANSITIVE) (to believe, to judge, to form or have in the mind, to determine, to use the mind in order to come to decisions, to anticipate; to call, to mind; to imagine, to conceive, to surmise) គិត, ពិចារណា, រិះគិត, ទ្រង់ព្រះតំរិះ, ទ្រង់ព្រះចិន្ដា",
"(TECHNICAL) គិតមានចេតនាឬផែនការរំពឹង",
],
}
]
"english" :
[
{
"type":["Noun — Plural: Thinks"],
"meaning" :
[
"Act of thinking; a thought.",
],
}
{
"type": ["Verb — past tense: thought ; past participle: thought ; present participle: thinking ; "],
"meaning"
[
"(TRANSITIVE) To seem or appear; -- used chiefly in the expressions methinketh or methinks, and methought.",
"(TRANSITIVE) To employ any of the intellectual powers except that of simple perception through the senses; to exercise the higher intellectual faculties.",
],
}
],
"other" :{
"meaning": [
"To presume, to venture",
"To conceive, to imagine",
],
"synonyms":[],
"antonyms":[],
"phrasalVerbs" :
[
"Think about",
"Think of",
],
"relatedPhrases" :
[
"think again",
"think ahead",
],
},
}';
$data = json_decode($json);
echo "<pre>";
print_r($data);
echo "</pre>";
?>
When I try to run this script I did not get the output like json Object.
Anyone Could help me about what is the problem with my Json String? or Json Design here ?
thanks
You have a lot of errors in your JSON, I'd use a site like http://jsonformatter.curiousconcept.com/ to help you track down and fix them ...
You can see an example of some of the errors in your JSON below, but you'll need to visit the site and paste your JSON in to validate the whole thing.