I'm learning swagger, trying to make a little change and see if it can be reflected on index page. So the starting point is the index.html page, I made a copy of it from the jar file :
C:\swagger-ui\target\swagger-ui-2.1.0-M1\WEB-INF\lib\swagger-ui-2.1.8-M1.jar
and saved the new page as index2.html, added a line to the html content inside, and added it to the above jar file.
But I've noticed it has a .gz file for the original index.html file, don't know its purpose, so I also made a file called index2.html.gz and added it to the above jar file, then run the jetty server, and loaded the index.html :
http://localhost:8080/swagger-ui/webjars/swagger-ui/2.1.8-M1/index.html
It showed up alright, then I tried to load : index2.html, but it couldn't find the page, why ? Where should I include it so it will show up at : http://localhost:8080/swagger-ui/webjars/swagger-ui/2.1.8-M1/index2.html
The error message is :
HTTP ERROR 404
Problem accessing /swagger-ui/webjars/swagger-ui/2.1.8-M1/index2.html. Reason:
Not Found
What exactly are you trying to change in the Swagger-UI? I have been messing around with branding/customizing Swagger myself. If you take a look at the swagger-ui.js file you will see that it is 30,000+ lines of code and poorly organized. They are also using handlebars and backbone.js which I am not familiar with. I added some custom features by simply manipulating the DOM once the page had been rendered. I did this by writing a JS file that was added to the index.html.
I got it done with the following steps :
[1] Create : C:\swagger-ui\petstore
[2] Copy swagger.json into it [ This is where you can customize ]
[3] Copy the index.html and save it as : Swagger_Test.html into C:\swagger-ui\src\main\webapp [ This is where you can customize ]
[4] Unpack swagger-ui-2.1.8-M1.jar into : C:\swagger-ui\src\main\webapp
[5] Create C:\swagger-ui\src\main\webapp\css and move the *.css and *.css.gz files mentioned in the original index.html file from C:\swagger-ui\src\main\webapp to C:\swagger-ui\src\main\webapp\css
[6] Create C:\swagger-ui\src\main\webapp\lib and move the *.js and *.js.gz files mentioned in the original index.html file from C:\swagger-ui\src\main\webapp to C:\swagger-ui\src\main\webapp\lib
[7] Maybe move another few files in the original index.html file from C:\swagger-ui\src\main\webapp to C:\swagger-ui\src\main\webapp\css or C:\swagger-ui\src\main\webapp\lib
[8] Comment out the following from the pom file
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.1.8-M1</version>
</dependency>
[9] In the Swagger_Test.html file
replace : url = "http://petstore.swagger.io/v2/swagger.json";
with : url = "/swagger-ui/petstore/swagger.json";
[10] Recompile and start the server
[11] Load page : http://localhost:8080/swagger-ui/Swagger_Test.html
or : http://localhost:8080/swagger-ui/Swagger_Test.html?url=http://localhost:8080/swagger-ui/petstore/swagger.json
Related
I'm trying to create link for the file upload. I'm calling file upload function from .cfc file. The file should be uploaded in a different folder. Here is what I get if after this code is executed in component.cfc page:
<cfset thisPath = ExpandPath( "./" ) />
C:\\wwwroot\\myapp\\components\\
I need to go level back in myapp and open bug folder. Then in a bug folder I need to direct the path either to folder1/ documents or folder2/documents. That will depend on the form field, here is example:
<cfset folder = trim(form.type) EQ 1 "folder1" : "folder2">
The path should either point to:
C:\\wwwroot\\myapp\\bug\\folder1\\documents\\
or
C:\\wwwroot\\myapp\\bug\\folder2\\documents\\
I'm looking for a solution that will work even if I roll this code to a different server with the same directory structure. Is there a good way to achieve this in ColdFusion?
I have images and I want to load them to my appplication.
my_app/lib/... - here my source files
my_app/assets/images/... - here my images
I need to get list of files in assets/images/ and after that show some of them (according to other logic)
I'm trying this
final dir = Directory("assets/images/");
print(dir.existsSync()); // <---- it also print: false
var files = dir.listSync().toList();
files.forEach((e) => list.add(MyImageItem(e.path)));
The problem is: I recieve exception
FileSystemException: Directory listing failed, path = 'assets/images/'
(OS Error: No such file or directory, errno = 2)
I've tried different ways: assets/images/, images/, images and so on
My pubspec.yaml
flutter:
assets:
- assets/images/
- assets/
When I create Image directly all is fine
new Image(image: AssetImage("assets/images/cat.png"))
I knew that previously (month ago) each resource has to be declared in pubspec.yaml directly, but now assets/images/ is ok.
I can load file by direct path. Why I can't access a directory? How to get list of files in directory to get them from my code?
When you add files to your assets, it means that you already know their paths.
Store all the images paths in a list and access them whenever you need.
For example if you have 3 images in
your_app/assets/images/image1.jpg
your_app/assets/images/image2.jpg
your_app/assets/images/image3.jpg
create a list and store all of them like:
List<String> imagePaths = ['assets/images/image1.jpg', 'assets/images/image2.jpg', 'assets/images/image3.jpg'];
and for example if you want to access your first image, use
AssetImage(imagePaths[0])
I keep a json file inside assets which records the file tree of assets folder.
When file list is needed, I just read from the json file.
Such json file can be easily generated by code.
However, this does not solve your problem directly when u have 5-10k images.
Only one json file might be too large to read.
Images should be grouped and recorded in separated json files.
I'm working on a Lua script which will be hosted by a third party program (some .exe which will call a certain function in my script). In order to implement a functionality I need (make a rest call to a webservice to retrieve certain info) I want to use socket.http.request.
I've first build an example script for the call I wanted to make:
local io = require("io")
local http = require("socket.http")
local ltn12 = require("ltn12")
local data = "some data")
local response = {}
socket.http.request({
method = "POST",
url = "http://localhost:8080/someServce/rest/commands/someCommand",
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = string.len(data)
},
source = ltn12.source.string(data),
sink = ltn12.sink.table(response)
})
print(table.concat(response))
print("Done")
This works fine. I get the response I expect.
Now when I try to do this from the third party host, I first got an error:
module 'socket.http' not found:
no field package.preload['socket.http']
no file '.\socket\http.lua'
no file 'D:\SomeFolder\lua\socket\http.lua'
no file 'D:\SomeFolder\lua\socket\http\init.lua'
no file 'D:\SomeFolder\socket\http.lua'
no file 'D:\SomeFolder\socket\http\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\http.luac'
no file '.\socket\http.dll'
no file 'D:\SomeFolder\socket\http.dll'
no file 'D:\SomeFolder\loadall.dll'
no file '.\socket.dll'
no file 'D:\SomeFolder\socket.dll'
no file 'D:\SomeFolder\loadall.dll'
I've tried copying the socket folder from the LUA folder to the folder the host is executing from (D:\SomeFolder). It then finds the module, but fails to load it with another error:
loop or previous error loading module 'socket.http'
I've also tried moving the require statement outside of the function and making it global. This gives me yet another error:
module 'socket.core' not found:
no field package.preload['socket.core']
no file '.\socket\core.lua'
no file 'D:\SomeFolder\lua\socket\core.lua'
no file 'D:\SomeFolder\lua\socket\core\init.lua'
no file 'D:\SomeFolder\socket\core.lua'
no file 'D:\SomeFolder\socket\core\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\core.luac'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\core.lua'
no file '.\socket\core.dll'
no file 'D:\SomeFolder\socket\core.dll'
no file 'D:\SomeFolder\loadall.dll'
no file '.\socket.dll'
no file 'D:\SomeFolder\socket.dll'
no file 'D:\SomeFolder\loadall.dll'
Then I tried copying the core.dll from socket into the D:\SomeFolder folder and it gave me another error:
error loading module 'socket.core' from file '.\socket\core.dll':
%1 is not a valid Win32 application.
Now I'm stuck. I think I must be doing something completely wrong, but I can't find any proper description on how to fix issues like this. Can anyone help me out?
As it turns out, the actual path Lua is going to look for is the problem here. Together with the third party we found that if we put a set of libraries in D:\SomeFolder\ everything now works. So for example there is now a socket.lua in D:\SomeFolder\and there are a socket and a mime forlder there as well.
Rule of thumb appears to be that the location of lua5.1.dll that is bound by the application is leading for the location of any modules you want to load.
You probably need to have the following folder structure (relative to your D:\SomeFolder folder):
socket.lua
socket/core.dll
socket/http.lua
socket/url.lua
socket/<any other file from socket folder required by http.lua>
I just tested this configuration and it works for me.
loop or previous error loading module 'socket.http'
This is usually caused by loading socket.http from socket/http.lua file itself.
Hey i'm trying to localize a plugin called Donate Plus ( which locallized technicly).
the plugin came with en_CA and de_DE files, i've tried creating a he_IL file without success.
So i've tried with the de files came with the plugin but didn't work.
I've set the WPLANG in wp-config.php to de_DE yet that dosen't change the code.
this is the setting code :
load_plugin_textdomain( 'dplus', '/wp-content/plugins/donate-plus' );
And i did check that all the string are set to be localized.
Anyone has a clue?
I just was with a similar isue, did you try to rename your files from de_DE.po and de_DE.mo to name-of-plugin-de_DE.mo and name-of-plugin-de_DE.po (changing name-of-plugin with yours, of course)?
dplus-de_DE.mo and dplus-de_DE.po It must work ;)
load_plugin_textdomain takes three parameters.
In your case it would be something like this (assuming the .po and .mo files are located in a subdir called 'languages')
load_plugin_textdomain( 'dplus', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
I checked the source of DonatePlus Plugin and I found that the Plugin is doing localization wrongly.
The load_plugin_textdomain() call is made inside the DonatePlus classes constructor. But it should be present inside the 'init' hook. Trying adding the following code (which is at the of the file) inside the init function.
if( class_exists('DonatePlus') )
$donateplus = new DonatePlus();
Where are all the .po and .mo files stored? Are they inside the /wp-content/plugins/donate-plus folder itself? If not then change the path or move the files.
I had a similar issue where I was loading the translation files with the load_plugin_textdomain function from within a service class using PSR-4. This meant that the dirname( plugin_basename( __FILE__ ) ) string returned the wrong path.
The correct path is the relative path your-plugin/languages (assuming you are loading the translation files from the /languages directory).
Absolute paths such as /var/www/html/wp-content/plugins/my-plugin/languages won't work.
My plugins file structure looks something like this:
- my-plugin
- assets
- languages
- services
- Api
- Base
Translation.php
- ...
Plugin.php
- vendor
- views
composer.json
composer.lock
index.php
my-plugin.php
uninstall.php
Since my Translation service is placed in the /services/Base/ directory, this worked for me:
$root = plugin_basename(dirname(__FILE__, 3));
load_plugin_textdomain( 'my-plugin', false, "$root/languages/");
Also, I used no action hook at all instead of init or plugins_loaded and fired the load_plugin_textdomain function at the beginning of the plugin, since the hooks don't fire early enough for the admin menu and action links to get translated.
Use:
load_textdomain( TEXT_DOMAIN , WP_PLUGIN_DIR .'/'.dirname( plugin_basename( FILE ) ) . '/languages/'. get_locale() .'.mo' );
While configuring FLOW3, I get the following error
#1315561483: It seems like the PHP binary "C:\php/php" cannot be executed by
FLOW3. Set the correct path to the PHP executable in Configuration/Settings.yaml,
setting FLOW3.core.phpBinaryPathAndFilename.
Any help please
In the configuration directory, I modified the setting file Settings.yaml.example to Settings.yaml by ist keeping the original and then have uncommented and set the following code at the end of the file
# core:
# phpBinaryPathAndFilename: 'C:/path/to/php.exe'
as per the path of php exe file.
By the way, you should also care about the indentation.
--> Don't use Tab but Space
--> Add 2 more spaces for each line as such:
TYPO3:
FLOW3:
persistence:
|
core:
phpBinaryPathAndFilename: 'C:/map2/php.exe'