I want to integrate swagger UI into my ruby based slate generated API docs , for that I looked up here
and did the directed changes to the layout.erb file adding the required head and body sections but upon building the webpage nothing shows up , these are the modified head and body section.
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><%= current_page.data.title || "API Documentation" %></title>
<link rel="stylesheet" type="text/css" href="swagger-ui.css">
<style>
<%= Rouge::Themes::MonokaiSublime.render(:scope => '.highlight') %>
</style>
<%= stylesheet_link_tag :screen, media: :screen %>
<%= stylesheet_link_tag :print, media: :print %>
<% if current_page.data.search %>
<%= javascript_include_tag "all" %>
<% else %>
<%= javascript_include_tag "all_nosearch" %>
<% end %>
<body class="<%= page_classes %>" data-languages="<%=h language_tabs.map{ |lang| lang.is_a?(Hash) ? lang.keys.first : lang }.to_json %>">
<div id="swagger-ui"></div>
<script src="swagger-ui-bundle.js"></script>
<script src="swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
url: "https://qa-refapp.openmrs.org/openmrs/module/webservices/rest/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
]
})
window.ui = ui
}
</script>
I added the complete layout.erb file here
Related
I'm doing statics on html5. I have many HTML lines of the same type:
<meta name="keywords" content="any keywords" />
<meta name="description" content="any description" />
The site has many pages, and editing these lines takes a lot of time for each individual file *.erb.
I wanted to find out how to call the required string from a single * .erb file. If I use <%= partial '...' %> in this case, the entire file will be called. Tell me if any opportunity to call only those lines which are necessary. I do not know how to call any line parts of a file from one file *.erb using middleman3. Perhaps there is a method to call from a file - lines by numbers, or any method.
===
since i'm a beginner maybe i don't understand
is it possible? look at the picture
Create a new file for instance "views/_partial.html.erb" ; The filename should begin with an underscore. Put your HTML content in this file which is the following:
<meta name="keywords" content="any keywords" />
<meta name="description" content="any description" />
Now from the view from which you want to call the partial, use the following code:
<%= render :partial => 'views/partial' %>
Note: while calling the partial you should exclude the underscore.
Edit Method 2
File: _partial.html.erb
<% if page == 1 %>
<meta name="keywords" content="any keywords" />
<meta name="description" content="any description" />
<% elsif page == 2 %>
<meta name="keywords" content="any keywords" />
<meta name="description" content="any description" />
<% end %>
Code to call the partial
<%= render partial: 'partial', locals: {page: 1} %>
<%= render partial: 'partial', locals: {page: 2} %>
I am working on a rails project and am unable to identify the source of the error : SyntaxError: [stdin]:10:26: missing ) when i render application.html.erb.
From the template i can't find the cause of the error or how to fix it.
Am using Rails 5.1.6
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>App</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= csrf_meta_tags %>
<%= tag :meta, name: :psj, action: action_name, controller: controller_name %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render 'layouts/header' %>
<%= yield %>
<%= render 'layouts/footer' %>
</body>
</html>
Isolating code sections shows that the error is being triggered by either including the lines containing ** javascript_include_tag ** or stylesheet_link_tag
I have faced a problem that ng-admin is not rendering inside simple ui-view.
Here is the code:
$stateProvider
.state('home', {
url: '/',
template: homeTemplate
})
.state('login', {
url: "/login",
template: loginTemplate,
controller: 'LoginController',
controllerAs: 'vm'
})
.state('register', {
url: "/register",
template: "<div>Register is under maintenance</div>",
})
;
And here is Html:
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Admin-tool</title>
<meta name="google" value="notranslate">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--<link rel="shortcut icon" href="favicon.ico" />-->
</head>
<body ng-strict-di class="main-content">
<div id="content-body" class="content">
<div ui-view=""></div>
</div>
<pg-footer></pg-footer>
</body>
Also there is an info message
WARNING: Tried to load angular more than once.
Maybe this is the case? Could you please point me out why it doesn't even render ng-admin simple page?
In browser it just looks like:
<!-- uiView: -->
<div ui-view="" class="ng-scope"></div>
Well, ng-admin has it's own routing so it was needed to make login rout and default on which ng-admin initialize. If it's needed to make custom pages inside ng-admin you just need to specify that in your state like this: parent: 'ng-admin'
I'm trying to get my first AngularJS app running with a Rails backend, so far I had some problem but somehow manage to move forward, but now there is another problem.
It seems like my Angular tags are not evaluating. This is how it looks like
Following is my setup
#app/assets/javascripts/recipes.js
this.recipe = angular.module('recipe',['ngRoute']);
this.recipe.config(['$routeProvider', function($routeProvider){
return $routeProvider.otherwise({
templateUrl: '../templates/home.html',
controller: 'RecipeCtrl'
});
}]);
Template file
#public/templates/home.html
Value of "foo": {{foo}}
Ng controller
#app/assets/javascripts/angular/controllers/RecipeCtrl.js
this.recipe.controller('RecipeCtrl',['$scope', function($scope){
$scope.foo = 'bar'
}]);
Layout file
#app/views/layouts/application.html.haml
!!!
%html{'ng-app' => 'recipe'}
%head
%title WILT
= stylesheet_link_tag "application", media: "all"
= javascript_include_tag "application"
= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js'
= javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-route.js'
= csrf_meta_tags
%body
%ng-view
= yield
Edit
Source of the HTML page
<!DOCTYPE html>
<html ng-app='recipe'>
<head>
<title>WILT</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" />
<link href="/assets/recipes.css?body=1" media="all" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-route.js"></script>
<script src="/assets/jquery.js?body=1"></script>
<script src="/assets/jquery_ujs.js?body=1"></script>
<script src="/assets/angular.js?body=1"></script>
<script src="/assets/angular-animate.js?body=1"></script>
<script src="/assets/angular-resource.js?body=1"></script>
<script src="/assets/angular/controllers/RecipeCtrl.js?body=1"></script>
<script src="/assets/recipes.js?body=1"></script>
<script src="/assets/application.js?body=1"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="Mducbu35Xjovr50CaR4zX5yWNhZ/3Q8RKYaz1B8xGXg=" name="csrf-token" />
</head>
<body>
<ng-view>
</ng-view>
</body>
</html>
I am trying to do something like this in an aspx page:
<head runat="server">
<% #if DEBUG %>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<% #else %>
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<% #endif %>
</head>
I get an error "Preprocessor directives must appear as the first non-whitespace character on a line". How can I do this?
<head runat="server">
<%
#if DEBUG
%>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<%
#else
%>
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<%
#endif
%>
</head>
Works for me - note that this is based on the value of the debug attribute in the <compilation> element of the web.config.
Edit to respond to comment
Ah, so you're also adding controls to the head through the code-behind? Then you'll probably need to be adding this dynamically from the code-behind as well.
If you're happy to always serve the minified version, but want to use IntelliSense in Visual Studio you should ensure that you've installed the hotfix to enable this:
VS2008 SP1 Hotfix to Support "-vsdoc.js" IntelliSense Doc Files
This would enable you to name your non-minified version jquery-1.3.2.min-vsdoc.js and have VS read that one in while you're building the pages.
this is worked for me:
<head runat="server">
<asp:PlaceHolder runat="server">
<%
#if !DEBUG
%>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<%
#else
%>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<%
#endif
%>
</asp:PlaceHolder>
</head>