How to setup “application/ld+json” Schema.org meta data in ASP.NET 3.5 dynamically using C# - c#-3.0

How can I dynamically create "application/ld+json" SEO Schema.org meta data in ASP.NET 3.5 using C#?
Is there any tool available for doing this?

This can be achieved by appending schema content to a stringbuilder and append to head
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<script type=\"application/ld+json\">");
sb.AppendFormat("{{");
sb.AppendFormat("\"#context\"" + ":" + "\"http://schema.org\"");
sb.AppendFormat(",");
sb.AppendFormat("\"#type\"" + ":" + "\"Article\"");
sb.AppendFormat(",");
sb.AppendFormat("\"headline\"" + ":" + "\"" + "Test article" + "\"");
sb.AppendFormat("}}");
sb.AppendFormat("</script>");
Page.Header.Controls.Add(new LiteralControl(sb.ToString()));

Related

Select HtmlToPdf - Html page saved in development and not saved but shown in production

I've got a problem with saving and NOT displaying a page that I want converted to pdf. The code I use works fine from within Visual Studio but not from IIS. On the development machine it converts the HTML page, saves the pdf and then redirects. On a 'production' machine with IIS it shows the html page (FactuurPDF) but stops there.
What I want is the behaviour on the development machine.
This is my code:
// other stuff
HtmlToPdf converter = new HtmlToPdf();
var TxtUrl = "";
TxtUrl = "https://localhost:44368/Facturen/FactuurPDF" + "?id=" + id + "&fact=" + fact;
PdfDocument doc = converter.ConvertUrl(TxtUrl);
var dat = DateTime.Today.ToString("yyyy-MM-dd");
doc.Save(#Path.Combine(_env.WebRootPath, "Verzondenfacturen/Fact_" + id + "_" + dat + ".pdf"));
doc.Close();
//other stuff (email pdf and update database)
return LocalRedirect("/Facturen/Index");
I hope anybody has a clue.
Setting the converter.Options.MaxPageLoadTime = 10 solved the problem.

Wix: Populate repeater with external API call

I'm referring to the following video How to Create A Web App With External API Access using Wix Code & wanted to know how I would populate a repeater rather than populating a paragraph tag as shown in the youtube video mentioned above.
Basically here is the pseudocode of what I would like to achieve:
If search box is equal to null or empty
Display all crypto currencie(s)
else
Display single crypto currency
Putting the info in a repeater isn't too different than what the example already shows. Actually, when the search box is empty, the API returns an array that just needs a little playing with to get it to work with a repeater.
So, assuming you added a repeater with the ID repeater1 that contains a text element with the id result, you can make the following minor changes to the page code. You don't need to touch the backend code at all.
First, in the button1_click event handler we'll remove the code that populates the text element with the data returned from the API. Instead, we'll add an _id property to each currency object (required for the repeater) and then feed that data to the repeater.
export function button1_click(event) {
getCryptoCurrencyInfo($w("#currencyInput").value)
.then(currencyInfo => {
// add an _id property to each currency object
currencyInfo.forEach(item => item._id = item.id);
// feed the data to the repeater
$w('#repeater1').data = currencyInfo;
} );
}
Then, we can take the code for populating the text element and stick it in the repeater1_itemReady event handler. This function will run once for each currency item in the array fed to the repeater's data property. Make sure you use the properties panel to wire the function to the matching repeater event.
export function repeater1_itemReady($item, itemData, index) {
$item("#result").text = "Name: " + itemData.name + "\n"
+ "Symbol: " + itemData.symbol + "\n"
+ "Rank: " + itemData.rank + "\n"
+ "Price (USD): " + itemData.price_usd + "\n"
+ "Market Capitalization (USD): " + itemData.market_cap_usd + "\n"
+ "Percent Change 1h: " + itemData.percent_change_1h + "\n"
+ "Percent Change 24h: " + itemData.percent_change_24h + "\n"
+ "Percent Change 7d: " + itemData.percent_change_7d;
}
Notice two subtle changes to the code. First, we use $item instead of $w to select the text element. This selects the specific instance of the text element in the current repeater element. Second, we use itemData instead of currencyInfo[0]. This gives us the specific data that is associated with the current repeater element.

adding params to joomla plugin based on external file

I am trying to develope a simple joomla plugin and i have a question, if you kindly could help me.
I have a long list of constants to use in my plugin, a group is to use with a joomla version and another group to use with another version, like this
//joomla version 2.5
$a01 = " some value "
$a02 = " some value "
$a03 =" some value "
....
....
$a99 = " some value "
//joomla version 3.0
$b01 = " some value "
$b02 = " some value "
$b03 = " some value "
....
....
$b99 = " some value "
In my plugin file i have this code:
if (!version_compare(JVERSION, '3.0', 'ge'))
{
// do something using constants for version less than 3.0
} else {
// do something using constants for version more than 3.0
}
For a better reading and organization where can hold those constants? In same file or in another file like (params or constants)? Which is the best approach? And how could i implement it?
What about placing it in a db-table? You retrieve them in your plugin by:
$db=JFactory::getDbo();
$db->setQuery('select key, value from #__yourtable where version ='.$version);
$list=$db-loadAssocList();
foreach($list as $v){
eval("define({$v['key']}, {$v['value']});");
}
Now all your constants for version $version are loaded.
...and if you want to be able to manage your constants from the joomla backend interface you could use a component-creator to quickly create this simple table with a full editing interface ( try component-creator.com )
regards Jonas (not affiliated with component-creator.com :) )

Blackberry publish in facebook

I'm developing an application for Blackberry and i need to know what is the best solution in order to post in the user's wall on Facebook.
Thanks
Edited: I need to post in user's wall
maybe you should check Facebook BlackBerry SDK:
http://sourceforge.net/projects/facebook-bb-sdk/
I don't know if this is the best, but you could simple invoke facebook sharelink in BrowserField
String FACEBOOK_SHARE_URL = "http://m.facebook.com/sharer.php";
String FACEBOOK_URL_PARAM = "u";
String FACEBOOK_TITLE_PARAM = "t";
String shareLink = "http://www.links.com/link123";
String title= "Title";
String url = FACEBOOK_SHARE_URL + "?" + FACEBOOK_URL_PARAM + "=" +
shareLink + "&" + FACEBOOK_TITLE_PARAM + "=" + appName;
BrowserField browser = new BrowserField();
add(browser);
browser.requestContent(url + ";deviceside=true");

How to use MongoRegex (MongoDB C# Driver)

Has anyone have any idea how to use MongoRegex for the document search?
I attempted this, but returns nothing back:
var spec = new Document();
spec.Add("Name", new MongoRegex("/" + searchKey + "*/", "i"));
collection.Find(spec)
Wondering why it doesn't work, I tried to execute following command from the console:
db.things.find({"Name":/john*/i}) /* WORKS */
db.things.find({"Name":"/john*/i"}) /* DOESN'T WORK */
Is that possible that the driver applies double quotation to the regex?
Thanks..
you just want a simple prefix query. Your regex is then ^ + searchKey. Also, this form will allow mongodb to use an index on Name.
var spec = new Document("Name", new MongoRegex(string.Format("^{0}",searchKey), "i"));
collection.Find(spec)
I think you need to not include the "/"s in C#, i.e.,
spec.Add("Name", new MongoRegex(searchKey + "*", "i"));
After digging the source code, I finally found the answer :)
var spec = new Document();
spec.Add("Name", new MongoRegex(".*" + searchKey + ".*", "i"));
collection.Find(spec)