I am trying to customize the favicon for our .net core api and set it to an image within our project structure. I am not able to get it to load though and have tried a few things that have not worked. This is how I am using my custom html for Swashbuckle in Startup.cs (Located in a folder called Swagger):
app.UseSwaggerUI(c =>
{
c.IndexStream = () => GetType().GetTypeInfo().Assembly
.GetManifestResourceStream("MyProject.Swagger.index.html");
});
Attempt #1:
Add the use of StaticFiles to my Startup.cs Configure method like so:
app.UseStaticFiles();
Then I placed the the logo.png (Set as Copy Always) inside the wwwroot folder under an Images folder and tried to reference it in the html like this. (I have also tried to reference it from an Images folder in the same directory as the html).
<link rel="icon" type="image/png" href="~/Images/logo.png" />
No dice and there is now no favicon in the tab.
Attempt #2.
Overwrite the favicon via Javascript inside the html file.
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/png';
link.rel = 'icon';
link.href = '~/Images/logo.png';
document.getElementsByTagName('head')[0].appendChild(link);
No dice, the swagger favicon still exists.
Has anybody successfully been able to replace the favicon using Swashbuckle?
The version of Swashbuckle I am using is Swashbuckle.AspNetCore 2.4.0
This is the html file I am using based on the default file from here https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.SwaggerUI/index.html
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>%(DocumentTitle)</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="~/Images/logo.png" />
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
hgroup.main {
display: none;
}
.swagger-ui .topbar {
background-color: #00CCCC;
}
</style>
%(HeadContent)
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z" />
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z" />
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z" />
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z" />
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z" />
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z" />
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<!-- Workaround for https://github.com/swagger-api/swagger-editor/issues/1371 -->
<script>
if (window.navigator.userAgent.indexOf("Edge") > -1) {
console.log("Removing native Edge fetch in favor of swagger-ui's polyfill")
window.fetch = undefined;
}
</script>
<script src="./swagger-ui-bundle.js"></script>
<script src="./swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function () {
var configObject = JSON.parse('%(ConfigObject)');
var oauthConfigObject = JSON.parse('%(OAuthConfigObject)');
// Apply mandatory parameters
configObject.dom_id = "#swagger-ui";
configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
configObject.layout = "StandaloneLayout";
// If oauth2RedirectUrl isn't specified, use the built-in default
if (!configObject.hasOwnProperty("oauth2RedirectUrl"))
configObject.oauth2RedirectUrl = window.location.href.replace("index.html", "oauth2-redirect.html");
// Build a system
const ui = SwaggerUIBundle(configObject);
// Apply OAuth config
ui.initOAuth(oauthConfigObject);
//Custom scripting
document.getElementsByClassName("link")[0].innerHTML = "Application Name";
document.getElementsByClassName("link")[0].removeAttribute("href");
}
</script>
</body>
I ran into a similar problem. However, I utilized the Index located here:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/tree/master/test/WebSites/CustomUIIndex/Swagger
From here, I was able to change the logo with the following:
<div id="header">
<section class="swagger-ui swagger-container" data-reactroot="">
<div class="topbar">
<div class="wrapper">
<div class="topbar-wrapper">
<a class="link">
<img alt="Swagger UI" src="/Swagger/UI/Logo.jpg" />
<span style="font-size:medium; color:black;text-wrap:none;text-align:right" >YourTitle</span>
</a>
</div>
</div>
</div>
</section>
</div>
Related
I have a simple code where there is a plane over barcode marker, when I click on this plane this action toggle visibility to another entity.
<!doctype HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script>
<script src="https://unpkg.com/aframe-curve-component/dist/aframe-curve-component.min.js"></script>
</head>
<body style='margin : 0px; overflow: hidden;'>
<script>
AFRAME.registerComponent("markerhandler", {
init: function () {
const animatedMarker = document.querySelector("#animated-marker");
var toggle= false;
animatedMarker.addEventListener('click', function (ev, target) {
console.log('click event on #animated-marker fired')
toggle=-toggle;
const element = document.querySelector("#show-hide-entity");
element.setAttribute('visible',toggle);
})
}
})
</script>
<a-scene embedded
arjs='sourceType: webcam; debugUIEnabled: false; detectionMode: mono_and_matrix; matrixCodeType: 4x4_BCH_13_9_3;'>
<a-marker type='barcode' value='1' emitevents="true" markerhandler>
<a-entity cursor="rayOrigin: mouse" raycaster="objects: .clickable; useWorldCoordinates: true;"></a-entity>
<a-entity geometry="primitive: plane; width: 1; height: 1"
material="color: red; opacity:0.7; side: double"
text="value: click me; align: center; wrapCount: 15"
position="0 0 0"
rotation="-90 0 0" class="clickable"
id="animated-marker"></a-entity>
<a-entity geometry="primitive: plane; width: 1; height: 1"
material="color: blue; opacity:0.7; side: double"
text="value: All it's ok; align: center; wrapCount: 15"
position="1 0 0"
rotation="-90 0 0"
id="show-hide-entity" visible="false"></a-entity>
</a-marker>
<a-entity camera></a-entity>
</a-scene>
</body
</html>
But click event isn't fired.
Used references and documentation:
How to handle click events on AR.js
Event listeners in ar.js
OnClick on model in AFrame-AR.js scene
I have installed Mathjax.2.7.5 and arabic-Mathjax from https://github.com/OmarIthawi/arabic-mathjax
I use them locally without server, without Internet-connection
i have modified the example "sample-signals.html" to get some arabic equation:
Arabic-Mathjax1
my code is:
!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--
| This example shows how to use MathJax's signal mechanism to find out
| about what MathJax is doing, and to hook into various events as they
| occur.
-->
<link href='Amiri' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="D:/4-11-2019/MathJax-2.7.5/arabic/dist/arabic.css">
<script type="text/x-mathjax-config">
// Configure MathJax
//
MathJax.Hub.Config({
jax: ["input/TeX", "output/HTML-CSS"],
extensions: ["tex2jax.js", "D:/4-11-2019/MathJax-2.7.5/arabic/dist/unpacked/arabic.js"],
TeX: {
extensions: ["AMSmath.js", "AMSsymbols.js", "autoload-all.js"]
},
'HTML-CSS': {
undefinedFamily: 'Amiri'
},
tex2jax: {
inlineMath: [
['$', '$'],
["\\(", "\\)"]
],
processEscapes: true
},
});
MathJax.Hub.Register.LoadHook("[MathJax]/extensions/TeX/noUndefined.js",
function () {MathJax.Hub.Startup.signal.Post("*** noUndefined Loaded ***")});
MathJax.Hub.Register.LoadHook("[MathJax]/extensions/TeX/AMSmath.js",
function () {MathJax.Hub.Startup.signal.Post("*** AMSmath Loaded ***")});
MathJax.Hub.Startup.signal.Post("*** In Startup Configuration code ***");
MathJax.Hub.Register.StartupHook("onLoad",function () {
Message("*** The onLoad handler has run, page is ready to process ***");
});
</script>
<!-- <script type="text/javascript" src="../MathJax.js"></script> -->
<script type="text/javascript" src="D:/4-11-2019/MathJax-2.7.5/MathJax.js"></script>
<style>
.output {
background-color: #F0F0F0;
border-top: 1px solid;
border-bottom: 1px solid;
padding: 3px 1em;
}
</style>
</head>
<body>
<p>
$$\alwaysar{x=1}$$
</p>
<p>
When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</p>
<p>\[E = mc^2\]</p>
<p>$$\ar{x=1}$$</p>
<p>$\ar{x=1}$</p>
<p>
Messages about mathematics:
<pre id="MathMessages" class="output">
</pre>
</p>
<p>
All Messages:
<pre id="AllMessages" class="output">
</pre>
</p>
<script>
(function () {
var math = document.getElementById("MathMessages");
var all = document.getElementById("AllMessages");
window.Message = function (message) {
MathJax.HTML.addText(all,message);
MathJax.HTML.addElement(all,"br");
};
MathJax.Hub.Register.MessageHook("New Math",function (message) {
var script = MathJax.Hub.getJaxFor(message[1]).SourceElement();
MathJax.HTML.addText(math,message.join(" ")+": '"+script.text+"'");
MathJax.HTML.addElement(math,"br");
});
MathJax.Hub.Startup.signal.Interest(function (message) {Message("Startup: "+message)});
MathJax.Hub.signal.Interest(function (message) {Message("Hub: "+message)});
Message("##### events above this have already occurred #####");
})();
</script>
</body>
</html>
Can anyone help me????
According to the W3C styling guide for css/svg (https://www.w3.org/TR/SVG2/styling.html) I should be able to position certain svg elements within css using the x/y attributes.
This works with chrome + the Samsung Galaxy S6 (not tried other models/browsers). However, this doesn't work in iOS and some window/htc devices that I've tried.
Here is the code I'm using (with the help of d3.js);
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="initial-scale=1, maximum-scale=1.5">
<script data-require="d3#4.0.0" data-semver="4.0.0" src="https://d3js.org/d3.v4.min.js"></script>
<style>
#media handheld,
screen and (max-width: 425px) {
foreignObject {
x: 30;
y: 30;
}
}
</style>
</head>
<body>
<script>
d3.selectAll("body")
.append("svg")
.append("foreignObject")
.attr("width", 30)
.attr("height", 30)
.attr('x', 0)
.attr('y', 0)
.html("hello")
</script>
</body>
</html>
Here is a plnk of the code also.
I was wondering if there was any kind of workaround for this? or if someone could recommend another way of adding responsive breakpoints for the x/y?
Thanks
The feature you're referring to is SVG 2. SVG 2 is still in Working Draft stage. Browser vendors are implementing features, but I wouldn't put anything into production that relied on SVG2 features. Even caniuse.com hasn't introduced a 'can i use SVG 2' section yet. They're discussing it here.
Now to answer your question :)
Option 1
If you only want to move whole SVG chunks around the page, then you can use HTML for your responsive layout and SVG within that. Something like:
<div class="responsive-wrapper">
<svg width="100%" height="200">
<rect x="10" y="10" height="200" width="200"/>
</svg>
</div>
<div class="responsive-wrapper">
<svg width="100%" height="200">
<rect x="10" y="10" height="200" width="200"/>
</svg>
</div>
Then
.responsive-wrapper {
border: 1px dashed lightgray;
width: 100%;
}
#media screen and (min-width: 500px) {
.responsive-wrapper {
float: left;
width: 48%;
}
}
rect {
fill: steelblue;
}
Option two
https://jsbin.com/xesuma/1
is JavaScript, is more complex, and isn't going to scale well.
<svg width="100%" height="200">
<rect id="rect-1" x="10" y="10" height="200" width="200"/>
</svg>
and something kinda nasty like:
var rect1El = document.getElementById('rect-1');
var currentWidth = rect1El.getAttribute('width');
window.addEventListener('resize', function() {
var newWidth = window.innerWidth > 400 ? 300 : 100;
if (newWidth !== currentWidth) {
rect1El.setAttribute('width', newWidth);
currentWidth = newWidth;
}
});
I have a major issue with apache cordova. This is an iOS-specific issue. I am using jQuery-mobile. The issue appears whenever one does a search on a listview control then my fixed position header, footer and search input moves down.
Here is the markup of my page.
<!DOCTYPE HTML>
<html>
<head>
<title>Contacts</title>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<link href="css/jquery.mobile-1.4.5.min.css" rel="stylesheet" />
<link href="css/jquery.mobile.icons.min.css" rel="stylesheet" />
<link href="css/jquery-ui.min.css" rel="stylesheet" />
</head>
<body>
<style>
#my-wrapper
{
padding-top: 81px;
background-color: rgb(250, 246, 246);
}
#my-wrapper form {
position: fixed;
left: 2%;
right :2%;
top: 35px;
width: 96%;
z-index: 2;
background-color: rgb(250, 246, 246);
border-color : rgb(120, 120, 120);
text-shadow:unset;
box-shadow:unset;
}
#ContactHeader
{
position: fixed;
top: 0px;
width: 100%;
z-index: 1;
}
</style>
<div id="employeeListPage" data-role="page" >
<div id="ContactHeader" data-role="header" style="height:32px ; ">
<a class="ui-btn-left" data-icon="arrow-l" href="#" onclick="window.location.replace('index.html');" style="vertical-align:text-top; height:8px"></a>
<h2>Contacts</h2>
</div>
<div id="my-wrapper" data-role="main">
<ul id="employeeList" data-role="listview" data-inset="true" data-filter="true" data-filter-theme="staticscroll" data-filter-placeholder="Search Contacts/Companies" ></ul>
</div>
<div data-role="footer" style="text-align:center; width: 100%;height: 25px;position:fixed;bottom: 0px;left: 0px;right: 0px;">My footer</div>
<div id="loadmoreajaxloader" style="display:none;"><center><img src="css/images/bw-loader.GIF" /></center></div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<script src="js/contactlist.js"></script>
</body>
</html>
I also have an event that fire when a user starts typing in the search bar
$(document).on("pagecreate", "#employeeListPage", function () {
$("#employeeList").on("filterablebeforefilter", function (e, data) {
var URL = window.localStorage.getItem("ContactsForSearch");
URL = URL + '/' + nextNo + '/' + value;
$.getJSON(URL, function (info) {
if (info.length === 0) {
nomoredata = true;
//alert('no more data to display');
$('#employeeList').append('<br>');
$('#employeeList').append('<center><h2>No Data <h2> </center>');
}
else {
$('#employeeList').append('<li style="border-top: 1px solid #0189D0;"><a data-transition="slide" href="employeedetails.html?id=' + id + '&comnum=' + comNum + '&contactNum=' + contactNumber + '"><h2>' + companyName + '</h2> <small>' + name + ' - ' + designation + '</small>' + '</a>' + '</li>');
}
});
});
});
Whenever you search from the top of the list:
If you are scrolling down and you start to type in the search bar , this happens...These screenshots were taken from xcode’s emulator , on the phone it has the same result except it has a keyboard popping up at the bottom:
This would solve the problem with scrolling headers:
if (window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
unfortunately it removes the "done" button too!!!
How can I avoid embedding css files to output html files during pub build (generate js)? Is it possible?
note: polymer version is 0.10.0-pre.11
Before pub build:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample app</title>
<link rel="stylesheet" href="cc.css">
<link rel="import" href="packages/polymer/polymer.html">
<!-- import the click-counter -->
<link rel="import" href="clickcounter.html">
<script type="application/dart">export 'package:polymer/init.dart';</script>
<script src="packages/browser/dart.js"></script>
</head>
<body>
<h1>Cc</h1>
<p>Hello world from Dart!</p>
<div id="sample_container_id">
<click-counter count="5"></click-counter>
</div>
</body>
</html>
After pub build:
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample app</title>
<!-- import the click-counter -->
</head>
<body><style>body {
background-color: #F8F8F8;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
font-weight: normal;
line-height: 1.2em;
margin: 15px;
}
h1, p {
color: #333;
}
#sample_container_id {
width: 100%;
height: 400px;
position: relative;
border: 1px solid #ccc;
background-color: #fff;
}
</style>
<!--
These two files are from the Polymer project:
https://github.com/Polymer/platform/ and https://github.com/Polymer/polymer/.
You can replace platform.js and polymer.html with different versions if desired.
-->
<!-- minified for deployment: -->
<!-- unminfied for debugging:
<script src="../../packages/web_components/platform.concat.js"></script>
<script src="src/js/polymer/polymer.concat.js"></script>
<link rel="import" href="src/js/polymer/polymer-body.html">
-->
<!-- Teach dart2js about Shadow DOM polyfill objects. -->
<!-- Bootstrap the user application in a new isolate. -->
<!-- TODO(sigmund): replace boot.js by boot.dart (dartbug.com/18007)
<script type="application/dart">export "package:polymer/boot.dart";</script>
-->
<script src="packages/polymer/src/js/use_native_dartium_shadowdom.js"></script>
<!--<script src="packages/web_components/platform.js"></script>
not necessary anymore with Polymer >= 0.14.0 -->
<!-- <link rel="import" href="../polymer-dev/polymer.html"> -->
<script src="packages/polymer/src/js/polymer/polymer.js"></script><polymer-element name="polymer-body" extends="body">
<script>
// upgrade polymer-body last so that it can contain other imported elements
document.addEventListener('polymer-ready', function() {
Polymer('polymer-body', Platform.mixin({
created: function() {
this.template = document.createElement('template');
var body = wrap(document).body;
var c$ = body.childNodes.array();
for (var i=0, c; (c=c$[i]); i++) {
if (c.localName !== 'script') {
this.template.content.appendChild(c);
}
}
// snarf up user defined model
window.model = this;
},
parseDeclaration: function(elementElement) {
this.lightFromTemplate(this.template);
}
}, window.model));
});
</script>
</polymer-element><script src="packages/web_components/dart_support.js"></script><script src="packages/polymer/boot.js"></script><polymer-element name="click-counter" attributes="count">
<template>
<style>
div {
font-size: 24pt;
text-align: center;
margin-top: 140px;
}
button {
font-size: 24pt;
margin-bottom: 20px;
}
</style>
<div>
<button on-click="{{increment}}">Click me</button><br>
<span>(click count: {{count}})</span>
</div>
</template>
<script type="application/dart" src="clickcounter.dart"></script>
</polymer-element>
<script type="application/dart" src="cc.html.0.dart"></script><script src="packages/browser/dart.js"></script>
<h1>Cc</h1>
<p>Hello world from Dart!</p>
<div id="sample_container_id">
<click-counter count="5"></click-counter>
</div>
</body></html>
As you can see the css file is embedded to html..
Work around for this issue is to add to every element #import ('mystle.css')
eg.
<my-element name="my-element">
<template>
<style>#import ('mystyle.css')</style>
...
</template>
<my-element>
credits go to John Messerly who invented the solution - see the thread here:
https://groups.google.com/a/dartlang.org/forum/?hl=en&fromgroups#!topic/web/8bjmkiRFhDk
Update
In Polymer.dart 0.12.1 an option was added to disable style inlining per file - see https://github.com/dart-lang/polymer-dart/blob/master/CHANGELOG.md#0121
transformers:
- polymer:
...
inline_stylesheets:
default: false
web/foo.css: true
packages/foo/bar.css: true
Original
There was an issue filed recently by a member of the Google PolymerDart team but it is not yet supported
https://code.google.com/p/dart/issues/detail?id=18597