How to highlight HTTP requests in Github Markdown? - http

I'm writing my README.md file for a Github repository, which contains some requisitions written for manual testing the application. The tool I use to make the manual tests is the REST Client extension for VSCode.
I want to show the manual tests highlighted on the front page of the repository, on the README. If it was some javascript, I could write something like:
```javascript
console.log("Hello World")
```
Github would recognize the code between the ``` and highlight it as javascript. But how can I do it for HTTP headers like these ones?
```http
### Expect { message: 'Wellcome to TestsAPI'}
GET http://localhost:5001/
### Expect code 201 and info about the new user
POST http://localhost:5001/user
Content-Type: application/json
{
"name": "Pitossomo",
"email": "pitossomos#hmail.com"
}
### Expect code 400
POST http://localhost:5001/user
Content-Type: application/json
{
"name": "",
"email": ""
}
```
In the example, there are 3 requisitions that can be made my the VSCode REST Client extension, separated by the ###. I put the ```http but it does not work, maybe there is some other word to refer to http headers?
Searching in google I've found the reference for the documentation of Highligh.js, but it does not specifies the word used by Github

Related

How to properly map my markdown content to dynamic URLs in Next.js?

I'd like to have the following URL structure:
URL
Role
/
markdown contents of /index.md
/about
markdown contents of /about.md
/cookies
markdown contents of /cookies.md
/privacy-policy
markdown contents of /privacy-policy.md
/category1
category1 index page
/category1/post1
markdown contents of /category1/post1.md
/category1/post2
markdown contents of /category1/post2.md
/category2
category2 index page
/category2/post1
markdown contents of /category2/post1.md
/category2/post2
markdown contents of /category2/post2.md
I'd like to avoid having to create separate .js files for my content in the root directory (so no /about.js, /cookies.js, etc), but if I try something like this...
pages/
index.js
[root_article_id].js
[category]/
index.js
[category_article_id].js
... then Next.js complains because it cannot decide when I request the URL /about whether if it should use [category]/index.js or [root_article_id].js, even though I feel the latter should be called first, and if it doesn't want to deal with the request (i.e. if there's no about.md in the root of my markdown directory), then it should fall back to [category]/index.js, which still could pass the request through to the 404 handler if [category].js spits it out.
What's the correct way of structuring Next.js files for this? Do I really need to have separate .js files for my markdown files in the root content directory?
What's the correct way of structuring Next.js files for this? Do I really need to have separate .js files for my markdown files in the root content directory?
This is the easiest way since you have to somehow tell nextjs what pages you want to be articles. However, if want to avoid doing it, you can do it with rewrites.
If you know all articles (or categories), this is what you need in your next.config.js:
module.exports = {
rewrites() {
return [
{
source: "/about",
destination: "/article/about",
},
{
source: "/cookies",
destination: "/article/cookies",
},
{
source: "/privacy-policy",
destination: "/article/privacy-policy",
},
];
},
};
And then make article/[root_article_id] page. Note that rewrite does not mean redirect. The page will be available in /about but nextjs will handle it like the request was to /article/about. This means that these pages will also be available from article/about, but this can probably be prevented if for some reason necessary.
Whether you should do rewrites for articles or categories depends on which one is dynamic. If neither one is really dynamic in a sense that you know all the possible values, you should pick the one with less possible values.
If both of categories and articles are dynamic, you need to do the rewrites with middleware (beta). In your middleware you get the req and you somehow need to decide if the requested url is an article or a category page. How this is done obviously depends on where and how you store your data.

Using r googledrive package to create custom property

According to the documentation for drive_mkdir() in the googledrive package, "Named parameters to pass along to the Drive API. Has the tidy dots semantics that come from using rlang::list2(). You can affect the metadata of the target file by specifying properties of the Files resource via .... Read the "Request body" section of the Drive API docs for the associated endpoint to learn about relevant parameters." In the Google Drive API, it lists adding custom properties as, "Custom file properties are key/value pairs used to store custom metadata for a file, such as tags, IDs from other data stores, information shared between workflow applications, and so on.
To add properties visible to all apps, use the properties field of files resource."
In the Google API Files Page, it lists it as
"properties": {
(key): string}
I've tried a number of different ways to pass a value, but nothing seems to work. Does anyone have an example of adding a custom property while creating a folder?
Here is one example I've tried that does not work:
GDriveTarget <- "https://drive.google.com/drive/u/1/folders/'etc'"
drID <- drive_get(GDriveTarget, verbose = TRUE)
gProps <-list2(properties = c("Region","Far Northeast"))
curFolder <- drive_mkdir(name="School Folders",
path=GDriveTarget,
gProps)
this results in:
Error: These parameters are unknown:
Backtrace:
googledrive::drive_mkdir(...)
googledrive::drive_create(...)
googledrive::request_generate(...)
gargle::request_develop(endpoint = ept, params = params)
gargle:::check_params(params, endpoint$parameters)
gargle:::stop_bad_params(unknown, reason = "unknown")
Removing "gProps" creates the desired folder, so I have the proper rights. I'm just unsure how to pass the parameters Google is expecting. When I use the "try this API" tool on Google Developer, what it is expecting is:
{
"properties": {
"Region": "Far Northeast"
}
}

Control index.xml for Atom/RSS to generate valid rss feed (without relative links)

Task: I want to add an RSS feed to my site. (Later I want to add a separate RSS feed for a specific category [for R Bloggers])
Setup:
I use the Hugo Academic template
via the R blogdown package
push my sources to github
https://github.com/Tazinho/AlmostRandom
from where it gets published via netlify
http://www.malte-grosser.com/
added an example blogpost here
http://www.malte-grosser.com/post/test-post/
Issue and validation:
According to this video
https://www.youtube.com/watch?v=gF0tohv99Ow
my blogs rss should be this
http://www.malte-grosser.com/index.xml
According to some validator side
http://www.feedvalidator.org/
My rss feed seems not to be valid and has several kinds of errors
http://www.feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.malte-grosser.com%2Findex.xml
eg: line 5, column 11: link must be a full and valid URL: / [help]
Steps to solve this so far:
I followed some SO posts, as far as I could. For example this related one
Control index.xml for Atom/RSS (hugo / blogdown generates feed with relative links)
I added rss.xml to /post/layouts/ and modified it according to
https://coolbutuseless.bitbucket.io/2018/02/07/blogdown-rss-feed-of-full-articles/
I struggled a bit with the part under
"# Reference your RSS Feed". I don't know wehre exactly what exactly has to go
I read several other posts and tried to find similar public repositories from rbind.io.
I deleted most of my trials, to have a clean setup for further trials
the only parts I kept are the following changes within config.toml
baseurl = "http://malte-grosser.com/"
rssLimit = 10
[outputs]
home = [ "HTML", "CSS", "RSS" ]
section = [ "HTML", "RSS" ]
taxonomy = [ "HTML", "RSS" ]
taxonomyTerm = [ "HTML", "RSS" ]
and the rss.xml under /post/layouts/
From my understanding (after reading once more Control index.xml for Atom/RSS (hugo / blogdown generates feed with relative links)) it seems to be ok to have these kind of errors.
Also for anyone with similar problems: It turns out that the blogs RSS should be under http://www.malte-grosser.com/post/index.xml and the categories RSS's should be under http://www.malte-grosser.com/categories/R-bloggers/index.xml

Invalid schema for REST JSON CreatePassengerNameRecord response

I am trying to test the integration for the Sabre CreatePassengerNameRecord rest API. As the first step, I tried downloading the JSON schemas for the Request and Response and tried to generate the POJOs using jsonschema2pojo. But it looks like the schema files are all pointing to dependent references using a URL http://services.sabre.com which is non existing. Hence the POJO generation is getting failed. This is happening for both the request and response. I was able to fix the request schema by changing the URL for XMLSchemaTypes.json dependency to provided URL link in documentation, but the response has a reference which is not specified anywhere (Please check the Response schema section of question ).
API Link: https://developer.sabre.com/docs/rest_apis/air/book/create_passenger_name_record/
Response Schema:
In the response, there is a reference to http://services.sabre.com/STL_Payload/v02_02 which is not existing.
File : http://files.developer.sabre.com/doc/providerdoc/STPS/create_passenger_name_record/v200/CreatePassengerNameRecord2.0.0RS.json
....
"CreatePassengerNameRecordRS" : {
"type" : "object",
"title" : "CreatePassengerNameRecordRS",
"properties" : {
"version" : {
"type" : "string",
"minLength" : 1,
"maxLength" : 255
},
"ApplicationResults" : {
"$ref" : "http://services.sabre.com/STL_Payload/v02_02#/definitions/ApplicationResults"
....
It would be great it you could provide the latest file for the STL_Payload or update the documentation to the latest working version.
The missing files were added to the documentation page.
This should allow you to move forward.
The id-s are still used as tags and not as absolute resource pointers so you still need to play with it they way you described to make the auto-generation working out of the box.
We will consider your request to convert them to resource pointers in the future.
Just one more hint: if you are using Java-API version of jsonschema2pojo please use this for config:
GenerationConfig config = new DefaultGenerationConfig() {
public String getRefFragmentPathDelimiters() {
return "#/";
}
};
You need it because the default path delimiters in jsonschema2pojo are "#/." and the "." does not work with some of the types declared in the schema like Text.Long
+1 Sabre please make JSON schema available on http://services.sabre.com as it is problematic when generating models using Quicktype. Types are not being resolved correctly.

open graph sample object, invalid og:type?

I've set up a custom action and custom object. I'm attempting to post to my timeline with the sample code Facebook offers:
curl -F 'access_token=<my token>' \
-F 'photo=http://samples.ogp.me/351656114891990' \
'https://graph.facebook.com/me/stipple_staging:stipple'
The response that comes back is this (parsed out for easier reading):
{
"error":{
"type":"Exception",
"message":"Object at URL 'http:\/\/samples.ogp.me\/351656114891990' is invalid because the configured 'og:type' of '103770389680565:photo' is invalid."
}
}
I'm sort of clueless at this point. Is this a known gotcha where I need to do something, or just a bug?
EDIT: Facebook now seems to have fixed this problem.
I think your issue is that your og:type is supposed to be your app namespace:action type, like
<meta property="og:type" content="your_app_namespace:photo" />
Check out section IV of the custom objects walkthrough, it has some examples of how the og:type tag should be formatted. I'm not certain that appid and namespace are the same thing, in the eyes of FB.
On a side note, you can check your FB URL's here instead of doing everything through cURL, if you prefer.
If you want to make it easy on yourself, there is a list of allowed values available on the Facebook website. If can use any of them in the type field: http://developers.facebook.com/docs/opengraphprotocol/#types

Resources