Gitlab Atom feed entries link configuration - rss

I just find out my Gitlab's Atom feed does not serve public URL for entries links.
My Atom feed URL is at http://MY_PUBLIC_URL.ltd/dashboard.atom?private_token=XXXXXXXX
By generated entries are like:
<entry>
<id>tag:192.168.0.105,2014-06-03:189</id>
<link href="http://192.168.0.105/team/project/issues/2"/>
<title>User commented on issue #16 at My project / my repo</title>
<updated>2014-06-03T05:46:26Z</updated>
<media:thumbnail width="40" height="40" url="http://www.gravatar.com/avatar/7fe0e43839bea9ad3e28344e6f9306bb?s=40&d=mm"/>
<author>
<name>Author's name</name>
<email>user#bMY_PUBLIC_DOMAIN.ltd</email>
</author>
<summary type="xhtml">
</summary>
</entry>
So as you can see, it uses 192.168.0.105 instead of MY_PUBLIC_URL, even though gitlab.yml is defined so:
production: &base
gitlab:
host: MY_PUBLIC_URL
port: 80

Related

loop xml and retrieve node values and construct xml outputusing Xquery

Team, I need your help /expertise to retrieve node value by traversing an xml response. I would like to use this an integration middleware.
Input file sample:
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xml:base="https://api12preview.sapsf.eu:443/odata/v2/">
<title type="text">PerEmail</title>
<id>https://api12preview.sapsf.eu:443/odata/v2/PerEmail</id>
<updated>2022-11-09T13:58:27Z</updated>
<link href="PerEmail" rel="self" title="PerEmail"/>
<entry>
<id>https://api12preview.sapsf.eu:443/odata/v2/PerEmail(emailType='54139',personIdExternal='GI00152188')</id>
<title type="text"/>
<updated>2022-11-09T13:58:27Z</updated>
<author>
<name/>
</author>
<link href="PerEmail(emailType='54139',personIdExternal='GI00152188')"
rel="edit"
title="PerEmail"/>
<category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
term="SFOData.PerEmail"/>
<content type="application/xml">
< properties>
<d:personIdExternal>GI00152188</d:personIdExternal>
<d:emailAddress>someone#test_boehringer.com</d:emailAddress>
</m:properties>
</content>
</entry>
<entry>
<id>https://api12preview.sapsf.eu:443/odata/v2/PerEmail(emailType='54139',personIdExternal='GI00453224')</id>
<title type="text"/>
<updated>2022-11-09T13:58:27Z</updated>
<author>
<name/>
</author>
<link href="PerEmail(emailType='54139',personIdExternal='GI00453224')"
rel="edit"
title="PerEmail"/>
<category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"
term="SFOData.PerEmail"/>
<content type="application/xml">
<m:properties>
<d:personIdExternal>GI00453224</d:personIdExternal>
<d:emailAddress>someone#test_boehringer.com</d:emailAddress>
</m:properties>
</content>
</entry>
<link href="https://api12preview.sapsf.eu:443/odata/v2/PerEmail?$select=emailAddress,personIdExternal&$filter=emailType%20eq%2054139&$skiptoken=eyJzdGFydFJvdyI6MTAwMCwiZW5kUm93IjoyMDAwfQ=="
rel="next"/>
</feed>
Out of this response or xml Xquery should run through all 'entry' node and pick values of node 'personIdExternal' and I'm expecting result like this
<element>
<personIdExternal>GI00152188</personIdExternal>
<personIdExternal>GI00453224</personIdExternal>
</element>
I have tried something below code earlier but it's not working here, and I suspect this is due to namespace in the source xml. My knowledge is limited in XQuery - Please help
{let $input:= /entry
for $i in $input/properties
return
<element>
<personIdExternal>{i/personIdExternal/text()}</personIdExternal>
</element>}
/entry doesn't select anything because the entry elements aren't at the top level, and they're in a namespace.
$input/properties is wrong because the properties element isn't a child of entry and it's in a namespace.
i doesn't select anything, it should be $i
personIdExternal doesn't select anything because it's in a namespace.
You just need
<element>{//*:personIdExternal}</element>

How to customize AccessDenied page of MinIO?

When the expiration date of MinIO links passes, It responds to an XML like this:
<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<Key>key-of-the-resource</Key>
<BucketName>bucket-name</BucketName>
<Resource>/path-to/teh-resource</Resource>
<RequestId>16FC78B1C6185XC7</RequestId>
<HostId>5d405266-91b9-XXXX-ae27-c48694f203d5</HostId>
</Error>
Is there any way to customize this page by some sort of configuration inside the MinIO? I didn't find any related config on their documents.
Other potential solutions:
Use redirect links on my backend, and check if this link was expired, then redirect it to another page
Maybe we can use Nginx, but I don't know what the directives are. I appreciate your help with that.
Update
complete response headers:
$ curl <minio-url> -I
HTTP/2 403
date: Tue, 05 Jul 2022 12:51:13 GMT
content-length: 0
accept-ranges: bytes
content-security-policy: block-all-mixed-content
strict-transport-security: max-age=15724800; includeSubDomains
vary: Origin
vary: Accept-Encoding
x-amz-request-id: 16FEEFE391X98X88
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
complete response:
$ curl <minio-url>
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Request has expired</Message><Key>new_structure/7553257.jpg</Key><BucketName>storage</BucketName><Resource>/decodl-storage/new_structure/7553257.jpg</Resource><RequestId>16FEEFFB573XXXXC</RequestId><HostId>5d405266-91b9-xxxx-ae27-c48694f203d5</HostId></Error>
Assuming your 403 error returns with the Content-Type header being set to text/xml, you can transform this XML response to the HTML with the nginx using XSL Transformations. To do it you'll need the XSLT module, and you should be aware this module is not built by default, it should be installed additionally as a dynamic module (or enabled with the --with-http_xslt_module configuration parameter when you build nginx from the sources).
After you install the module, you should specify the xslt_stylesheet directive under the location used to proxy requests to the MinIO backend:
location ... {
xslt_stylesheet /path/to/error.xslt;
...
}
Here is an example of the XSLT file that can be used to transform the XML response you've showed in your question:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text>
<html>
<head>
<title><xsl:value-of select="Error/Code"/></title>
</head>
<style type="text/css">
body {
height: 100vh;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
p {
font-weight: bold;
}
.itemvalue {
font-family: monospace, monospace;
font-weight: normal;
font-size: 1em;
}
</style>
<body>
<h1><xsl:value-of select="Error/Message"/></h1>
<p>Additional information:</p>
<table><tbody>
<xsl:for-each select="Error/*[not(name()='Code' or name()='Message')]">
<tr>
<td class="itemname"><xsl:value-of select="local-name()"/>:</td>
<td class="itemvalue"><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</tbody></table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The above file, being applied to the response sample, will give you the following:
You can style the output whatever you like. I think this question is not about web design (and I'm not a designer), however provided information should be enough to be an example that you can adapt to your needs.
Update
If your MinIO response comes with somethat different MIME content type, e.g. application/xml, you'd need to add that content type to the list of MIME types processed by the XSLT module with the xslt_types directive:
location ... {
xslt_types application/xml;
xslt_stylesheet /path/to/error.xslt;
...
}
Digging futher into the XSLT I finished up with somewhat different XSLT file. This one will transform only error messages containing Error top level node, leaving any other response unchanged:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/Error">
<html>
<head>
<title><xsl:value-of select="./Code"/></title>
</head>
<style type="text/css">
/* custom CSS styles, see the previous example */
</style>
<body>
<h1><xsl:value-of select="./Message"/></h1>
<p>Additional information:</p>
<table><tbody>
<xsl:for-each select="./node()[not(self::Code or self::Message)]">
<tr>
<td class="itemname"><xsl:value-of select="local-name()"/>:</td>
<td class="itemvalue"><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</tbody></table>
</body>
</html>
</xsl:template>
<xsl:template match="/node()[not(self::Error)]">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
For those who may come across this question for ingress, I've created this Dockerfile for ingress-nginx-controller; you can build it and then use your image inside the ingress-nginx-controller deployment.
FROM k8s.gcr.io/ingress-nginx/controller:v1.0.0#sha256:0851b34f69f69352bf168e6ccf30e1e20714a264ab1ecd1933e4d8c0fc3215c6 as builder
USER root
WORKDIR /tmp
RUN apk add git openssl-dev pcre-dev zlib-dev libc-dev gcc make libxml2 libxslt-dev
RUN NGINX_VERSION=$(nginx -v 2>&1 | sed 's/nginx version: nginx\///') && \
wget -qO- https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar xvz && \
mv nginx-${NGINX_VERSION} nginx
RUN ls ./nginx
RUN cd ./nginx && \
./configure --with-compat --with-http_xslt_module=dynamic && make modules
FROM k8s.gcr.io/ingress-nginx/controller:v1.0.0#sha256:0851b34f69f69352bf168e6ccf30e1e20714a264ab1ecd1933e4d8c0fc3215c6
USER root
RUN apk add libxml2 libxslt-dev
USER 101
COPY --from=builder /tmp/nginx/objs/ngx_http_xslt_filter_module.so /etc/nginx/modules
Then you can load the module with this configMap. Don't forget to restart deployment after applying the ConfigMap:
apiVersion: v1
data:
main-snippet: |
load_module /etc/nginx/modules/ngx_http_xslt_filter_module.so;
kind: ConfigMap
metadata:
name: ingress-nginx-controller
namespace: ingress-nginx
And finally, you can use the XSLT module inside your ingresses:
metadata:
annotations:
...
nginx.ingress.kubernetes.io/configuration-snippet: |
xslt_types application/xml;
xslt_stylesheet /tmp/files/minio.xslt;
to mount volume you can use configmaps like this:
k -n ingress-nginx create configmap minio-xslt --from-file=</path/to/your/xslt-containing-folder>
Don't forget to update your deployment YAML file:
# k -n ingress-nginx edit deployments.apps ingress-nginx-controller
spec:
...
template:
...
spec:
...
volumeMounts:
...
- mountPath: /tmp/files
name: minio-xslt
...
volumes:
...
- configMap:
name: minio-xslt
name: minio-xslt

Delay in youtube PubSubHubbub notifications

I have subscribed my server to my Youtube channel via youtube
PubSubHubbub. I am experiencing delay in notifications sometimes.
Is there anyway ( like statistics, tracking, youtube API ) by which I can know, when the PubSubHubbub event is fired, so that I can actually know, if there is a delay?.
The atom feed looks like this:
<entry>
<id>yt:video:vidxxx</id>
<yt:videoId>videxxx</yt:videoId>
<yt:channelId>channelxxx</yt:channelId>
<title> titlexxx</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=vidxxx"/>
<author> <name>Author</name>
<uri> https://www.youtube.com/channel/channelxxx </uri>
</author>
<published>2019-01-06T13:00:57+00:00</published>
<updated>2019-01-06T17:18:07+00:00</updated>
<media:group> <media:title> title xxx </media:title>
<media:content url="https://www.youtube.com/v/xxx?version=3"
type="application/x-shockwave-flash" width="640" height="390"/>
<media:thumbnail url="https://i2.ytimg.com/vi/xxx/hqdefault.jpg"
width="480" height="360"/>
<media:description> description XXX </media:description>
<media:community>
<media:starRating count="45" average="4.91" min="1" max="5"/>
<media:statistics views="70593"/>
</media:community>
</media:group>
</entry>

How to get item source from inoreader feed?

I have a inoreader tag feed url with below format:
<item>
<title></title>
<link></link>
<description></description>
<pubDate></pubDate>
<category></category>
<dc:creator></dc:creator>
<source url=" "> XYZ </source>
<guid isPermaLink="false"> </guid>
</item>*
Example of the feed is : http://www.inoreader.com/stream/user/1005908176/tag/devotional
I could not fetch itewm source i.e., XYZ using simplepie or magpie.
Also I could not get <dc:creator>
How to fetch those parameters using any rss parser?
Also can I get these parameters to MySQL?

Spring MVC Static Resources partially work

I have a basic directory app that works fine except that it seems to only sometimes find the static resources that I’ve configured using the mvc:resources tag. My search of the board found problems related to handler mappings, but my problem seems to be different.
Specifically, when the PersonController is called via a method mapping to “/person”, it returns personlist.jsp using the view resolver and correctly finds and uses the static css and js files. No problems.
When the same controller is called via another method mapping to “/person/{familyid}” ( narrows the person list to a particular family), it returns the same personlist.jsp…but now it fails to find or use the css and js files (though it does display the correct data).
I don’t understand why there is a behavior difference since both scenarios use the same Controller, the same return String (return “personlist”), and resolve to the same JSP (ie. with the same Head section links for the css, js).
I looked at what came back in the browser for each case using ‘view source’, and both pages return the same head tag rendering for the css and js linking:
<link href="resources/css/directory.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js"></script>
<script type="text/javascript" src="resources/scripts/directory.js"></script>
I thought the problem could be with my tag mapping, so I also tried this:
<resources mapping="**/resources/**" and
resources mapping="resources/**"
but no help.
Am I approaching the use of static resources properly here (and what is the right resources tag mapping if that’s the problem)? Thanks.
I am using Spring 3.0.6 and my css and js files are located under /WebContent/resources/css and /WebContent/resources/scripts respectively, which are mapped using the mvc:resource tag (see below).
PersonController:
#Controller
public class PersonController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
List<Person> personList;
Boolean familyCalled = false;
#Autowired
PersonService personService;
#RequestMapping(value="/people", method=RequestMethod.GET)
public String people(Model model) {
logger.debug("Received request to show peoplelist page");
System.out.println("Running inside people() method of PersonController");
personList = personService.getPersons();
familyCalled = false;
model.addAttribute("personList", personList);
return "personlist";
}
#RequestMapping(value="/people/{familyId}", method=RequestMethod.GET)
public String familyMembers(#PathVariable("familyId") String fid, Model model) {
System.out.println("Running inside familyMembers() method of PersonController");
personList = personService.getPersonsInFamily(fid);
familyCalled = true;
model.addAttribute("personList", personList);
return "personlist";
}
Servlet-Context.xml (without namespaces):
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- for transactions -->
<tx:annotation-driven/>
<!-- Needed for #PreAuthorize security on methods -->
<aop:aspectj-autoproxy/>
<context:annotation-config />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="resources/" />
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven/>
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.c3works.preps" />
</beans:beans>
personlist.jsp (Head section):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</meta>
<title>XXXXXXXXXXXXXXXXXXX</title>
<link href="resources/css/directory.css" rel="stylesheet" type="text/css">
</link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js">
</script>
<script type="text/javascript" src="resources/scripts/directory.js">
</script>
</head>
Your URLs are relative and therefore the browser is looking for the resources in the wrong place. (Check the resulting HTML code)
One solution is to use the <spring:url> tag to build the urls of the resources.
<spring:url var="banner" value="/resources/images/banner-graphic.png" />
<img src="${banner}" />

Resources