Brijesh619 commented on code in PR #721:
URL: https://github.com/apache/atlas/pull/721#discussion_r3933484615
##########
webapp/pom.xml:
##########
@@ -683,6 +683,84 @@
</tasks>
</configuration>
</execution>
+ <execution>
+ <id>fix-enunciate-csp-assets</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <skip>${skipEnunciate}</skip>
+ <tasks>
+ <!-- Copy CSS -->
+ <copy failonerror="true"
todir="${project.build.directory}/api/v2/css">
+ <fileset
dir="${project.basedir}/src/main/enunciate-assets/css" />
+ </copy>
+ <copy failonerror="true"
todir="${project.build.directory}/api/v2/apidocs/css">
+ <fileset
dir="${project.basedir}/src/main/enunciate-assets/css" />
+ </copy>
+ <copy failonerror="true"
todir="${project.build.directory}/api/v2/apidocs/ui/css">
+ <fileset
dir="${project.basedir}/src/main/enunciate-assets/css" />
+ </copy>
+
+ <!-- Copy JS (Note: jQuery 1.12.2 is pinned
for compatibility with Bootstrap 3.4.1 in static Enunciate REST API
documentation) -->
+ <copy failonerror="true"
todir="${project.build.directory}/api/v2/js">
+ <fileset
dir="${project.basedir}/src/main/enunciate-assets/js" />
+ </copy>
+ <copy failonerror="true"
todir="${project.build.directory}/api/v2/apidocs/js">
+ <fileset
dir="${project.basedir}/src/main/enunciate-assets/js" />
+ </copy>
+ <copy failonerror="true"
todir="${project.build.directory}/api/v2/apidocs/ui/js">
+ <fileset
dir="${project.basedir}/src/main/enunciate-assets/js" />
+ </copy>
+
+ <!-- Replace URLs -->
+ <replace
dir="${project.build.directory}/api/v2" includes="**/*.html"
token="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
value="css/bootstrap.min.css" />
Review Comment:
I have added a comment in webapp/pom.xml to clarify this behavior.
Enunciate does emit HTML in deeper subdirectories (like api/v2/apidocs and
api/v2/apidocs/ui), but the relative replacements (css/... and js/...) work
perfectly because the maven-antrun-plugin is already copying the CSS and JS
directories into all three directory depths directly above the replacement step.
The added comment ensures this logic is documented for future maintainers.
Let me know if there's anything else to adjust!
##########
webapp/src/main/enunciate-assets/css/prettify.css:
##########
@@ -0,0 +1,34 @@
+/* Pretty printing styles. Used with prettify.js. */
Review Comment:
I've moved prettify.css to the css/ directory for better organization.
Additionally, I updated the logic inside run_prettify.js so it dynamically
requests ../css/prettify.css based on its own path.
I also added a check for api/v2/css/prettify.css into the positive
validation logic we previously added to pom.xml, guaranteeing it gets properly
resolved.
Let me know if there's anything else you need!
##########
webapp/src/main/enunciate-assets/js/run_prettify.js:
##########
@@ -0,0 +1,64 @@
+!function(){/*
+
+ Copyright (C) 2013 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Copyright (C) 2006 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+(function(){function aa(g){function
r(){try{L.doScroll("left")}catch(ba){k.setTimeout(r,50);return}x("poll")}function
x(r){if("readystatechange"!=r.type||"complete"==z.readyState)("load"==r.type?k:z)[B](n+r.type,x,!1),!l&&(l=!0)&&g.call(k,r.type||r)}var
X=z.addEventListener,l=!1,E=!0,v=X?"addEventListener":"attachEvent",B=X?"removeEventListener":"detachEvent",n=X?"":"on";if("complete"==z.readyState)g.call(k,"lazy");else{if(z.createEventObject&&L.doScroll){try{E=!k.frameElement}catch(ba){}E&&r()}z[v](n+
+"DOMContentLoaded",x,!1);z[v](n+"readystatechange",x,!1);k[v](n+"load",x,!1)}}function
T(){U&&aa(function(){var g=M.length;ca(g?function(){for(var
r=0;r<g;++r)(function(g){k.setTimeout(function(){k.exports[M[g]].apply(k,arguments)},0)})(r)}:void
0)})}for(var
k=window,z=document,L=z.documentElement,N=z.head||z.getElementsByTagName("head")[0]||L,B="",W="",F=z.getElementsByTagName("script"),l=F.length;0<=--l;){var
O=F[l],Y=O.src.match(/^[^?#]*\/run_prettify\.js(\?[^#]*)?(?:#.*)?$/);if(Y){B=Y[1]||"";W=O.src.replace(/run_prettify\.js(\?[^#]*)?(?:#.*)?$/,"");O.parentNode.removeChild(O);
+break}}var
U=!0,H=[],P=[],M=[];B.replace(/[?&]([^&=]+)=([^&]+)/g,function(g,r,x){x=decodeURIComponent(x);r=decodeURIComponent(r);"autorun"==r?U=!/^[0fn]/i.test(x):"lang"==r?H.push(x):"skin"==r?P.push(x):"callback"==r&&M.push(x)});l=0;for(B=H.length;l<B;++l)(function(){var
g=z.createElement("script");g.onload=g.onerror=g.onreadystatechange=function(){!g||g.readyState&&!/loaded|complete/.test(g.readyState)||(g.onerror=g.onload=g.onreadystatechange=null,--S,S||k.setTimeout(T,0),g.parentNode&&g.parentNode.removeChild(g),
+g=null)};g.type="text/javascript";g.src=W+"lang-"+encodeURIComponent(H[l])+".js";N.insertBefore(g,N.firstChild)})(H[l]);for(var
S=H.length,F=[],l=0,B=P.length;l<B;++l)F.push(W+"skins/"+encodeURIComponent(P[l])+".css");F.push(W+"prettify.css");(function(g){function
r(l){if(l!==x){var k=z.createElement("link");k.rel="stylesheet";
+k.type="text/css";l+1<x&&(k.error=k.onerror=function(){r(l+1)});k.href=g[l];N.appendChild(k)}}var
x=g.length;r(0)})(F);var ca=function(){"undefined"!==typeof
window&&(window.PR_SHOULD_USE_CONTINUATION=!0);var g;(function(){function
r(a){function d(e){var a=e.charCodeAt(0);if(92!==a)return a;var
c=e.charAt(1);return(a=k[c])?a:"0"<=c&&"7">=c?parseInt(e.substring(1),8):"u"===c||"x"===c?parseInt(e.substring(2),16):e.charCodeAt(1)}function
f(e){if(32>e)return(16>e?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);
+return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function c(e){var
c=e.substring(1,e.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));e=[];var
a="^"===c[0],b=["["];a&&b.push("^");for(var a=a?1:0,h=c.length;a<h;++a){var
m=c[a];if(/\\[bdsw]/i.test(m))b.push(m);else{var
m=d(m),p;a+2<h&&"-"===c[a+1]?(p=d(c[a+2]),a+=2):p=m;e.push([m,p]);65>p||122<m||(65>p||90<m||e.push([Math.max(65,m)|32,Math.min(p,90)|32]),97>p||122<m||
+e.push([Math.max(97,m)&-33,Math.min(p,122)&-33]))}}e.sort(function(e,a){return
e[0]-a[0]||a[1]-e[1]});c=[];h=[];for(a=0;a<e.length;++a)m=e[a],m[0]<=h[1]+1?h[1]=Math.max(h[1],m[1]):c.push(h=m);for(a=0;a<c.length;++a)m=c[a],b.push(f(m[0])),m[1]>m[0]&&(m[1]+1>m[0]&&b.push("-"),b.push(f(m[1])));b.push("]");return
b.join("")}function g(e){for(var
a=e.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)",
+"g")),b=a.length,d=[],h=0,m=0;h<b;++h){var
p=a[h];"("===p?++m:"\\"===p.charAt(0)&&(p=+p.substring(1))&&(p<=m?d[p]=-1:a[h]=f(p))}for(h=1;h<d.length;++h)-1===d[h]&&(d[h]=++r);for(m=h=0;h<b;++h)p=a[h],"("===p?(++m,d[m]||(a[h]="(?:")):"\\"===p.charAt(0)&&(p=+p.substring(1))&&p<=m&&(a[h]="\\"+d[p]);for(h=0;h<b;++h)"^"===a[h]&&"^"!==a[h+1]&&(a[h]="");if(e.ignoreCase&&A)for(h=0;h<b;++h)p=a[h],e=p.charAt(0),2<=p.length&&"["===e?a[h]=c(p):"\\"!==e&&(a[h]=p.replace(/[a-zA-Z]/g,function(a){a=a.charCodeAt(0);
+return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var
r=0,A=!1,q=!1,I=0,b=a.length;I<b;++I){var t=a[I];if(t.ignoreCase)q=!0;else
if(/[a-z]/i.test(t.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){A=!0;q=!1;break}}for(var
k={b:8,t:9,n:10,v:11,f:12,r:13},u=[],I=0,b=a.length;I<b;++I){t=a[I];if(t.global||t.multiline)throw
Error(""+t);u.push("(?:"+g(t)+")")}return new
RegExp(u.join("|"),q?"gi":"g")}function l(a,d){function f(a){var
b=a.nodeType;if(1==b){if(!c.test(a.className)){for(b=
+a.firstChild;b;b=b.nextSibling)f(b);b=a.nodeName.toLowerCase();if("br"===b||"li"===b)g[q]="\n",A[q<<1]=r++,A[q++<<1|1]=a}}else
if(3==b||4==b)b=a.nodeValue,b.length&&(b=d?b.replace(/\r\n?/g,"\n"):b.replace(/[
\t\r\n]+/g," "),g[q]=b,A[q<<1]=r,r+=b.length,A[q++<<1|1]=a)}var
c=/(?:^|\s)nocode(?:\s|$)/,g=[],r=0,A=[],q=0;f(a);return{a:g.join("").replace(/\n$/,""),c:A}}function
k(a,d,f,c,g){f&&(a={h:a,l:1,j:null,m:null,a:f,c:null,i:d,g:null},c(a),g.push.apply(g,a.g))}function
z(a){for(var d=void 0,f=a.firstChild;f;f=
Review Comment:
The issue raised in the comment has been fully resolved. The path for
prettify.css has been updated and the findings regarding the lack of query
parameters have been documented in the pom.xml.
Everything looks good and is ready to go! Let me know if there's anything
else you need.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]