We're writing a grails (Grails 2.1.1) project where, for some of our views, we want to use markdown instead of gsp files.
At the moment we can do this using the markdown plugin in a special layout. This allows us to render markdown views like so:
render(layout: 'docs', view: 'markdown')
However, this requires the markdown page to have a .gsp extension, when, for practical reasons, we need it to have a .md extension.
Does anyone know a better way to use markdown as a grails view? It would be great if we can avoid using the .gsp extension.
The Short Answer
You're not going to be able to without some heavy modifications. The distributed GrailsViewResolver is hard-tied to .gsp and .jsp extensions.
See grails-core on github for verification.
The Long Answer
You might be able to fashion your own Ant task to hook it into the Compile cycle of your Grails application so that, at a minimum, you can compile your *.md files through the GroovyPageCompiler.
That process might look something like this (though not exactly, since I am relying on the plugin's taglib to do the rendering in this case, for simplicity).
But this doesn't solve all of your problems. You would also need to register a new view resolver, and to do that you would inevitably go down the road of rewriting the GrailsDispatcherServlet.
It sounds like your solution of storing the files in the conf directory might be your best (although dirty) bet for now. Maybe somebody will take the time to allow for configurable GSP file extensions in the future, and that might solve your problem down the road.
I hope you find some of this information useful.
I did pretty much the same thing but with another approach today. I wanted to serve the readme file of the project so I couldn't really move it anywhere. I ended up soft linking it from readme.md to grails-app/views/readme/readme.gsp. I posted about the whole thing.
And yes - soft linking works if you and all your coworkers are on *-nix - so it is not a platformsafe way to do it.
Related
I'm completely new to translating QML widgets.
I see people using i18n() and i18nc() in their source code.
I've found the commands documented here:
https://techbase.kde.org/Development/Tutorials/Localization/i18n#QML
But the QML documentation only lists the qsTr() method. I guess the other 2 commands are KDE specific?
Do I really have to dabble with those KDeclarative etc objects, in C++? I'm not really sure how that works. My widget doesn't use any of that, just qml files and some javascript files for external functions.
I've found out I can get the translation to work with PoEdit but only for .js files, if I define a custom source keyword (function name) to extract from them, but ONLY if they are i18n and i18nc (qsTr doesn't work) and when using a directory structure I stole from a working widget (that is /contents/locale/language_key/plasma_applet_widget_id.mo). Sadly, since the parser getText can't read qml files, this solution isn't good enough.
Now, I know qt provides a command, lupdate, to extract those keywords from the source, but that only works for qsTr, conversely. Trying to pass -tr-function-alias qsTr=(i18n) as an argument doesn't work. With qsTr() I can have a nice .ts file, but trying to convert that to po and use the previously mentioned trick doesn't work.
I wonder though, why the devs of the downloadable widgets all seem to use i18n and i18nc in their source code if lupdate doesn't seem to be able to extract those keywords.
Why do people use i18n and i18nc instead of qsTr?
Probably because it's way more convenient. I've been able to get .qml files to work using the above-mentioned trick by simply manually editing the .po files (referencing the qml file in question, the line where the keyword occurs and so on).
I hope someone here has used the Blink.jl package for building Julia and Electron apps.
I am having problems setting up and using it, though. The issue is with all of the functions in the api provided: load/loadcss/loadjs/importhtml. They do not seem to work, or I might be doing something wrong.
For example:
loadcss!(w, "styles.css")
does not apply any of the styles in the styles files in the directory.
importhtml!(w, 'index.html')
does not display the html page stored in the local directory. The app shows a blank screen.
I might be doing something wrong as i could not find documentation on how to use the package
I think I found out why, the methods take the full path and not the relative paths, even if files are inside the same folder. So, something like this works:
loadcss!(w, "D:\project\styles.css")
but this won't work:
loadcss!(w, "styles.css")
I've tried to lay out my classes in one file each, with the classes belonging to a couple different libraries.
Basically, these files have library inf.logic; at the top:
web/logic/realm.dart (imports region.dart)
web/logic/region.dart (imports ../events.dart)
web/logic/tile.dart
This has library inf.gfx;:
web/gfx/viewport.dart (imports ../logic/realm.dart)
This has just library inf;:
web/events.dart
And then I have the main entry point, which seems to end up in the inf library by default:
web/inf.dart (imports gfx/viewport.dart, logic/realm.dart, logic/region.dart, logic/tile.dart)
When I generate dartdoc, it only seems to catch some classes, seemingly randomly. Even though the main entry point uses all of the above classes explicitly, I only get docs generated for region.dart and events.dart. No other files are included, and the links in the doc that refers to the other classes result in 404's.
It feels like I'm doing something wrong. Should I resort to create a wrapper file for the libraries and use part and part of? I really dislike the idea of adding that need for maintenance between file relations, that should already be implicit from the imports.
Also, how can I get rid of relative paths? I tried package:inf/logic/realm.dart, but it doesn't work…
Andrei Mouravski answered this on the mailing list:
There are several issues here:
If Dartdoc is generating 404 links, then file a bug with all information you can possibly provide. It's very possible something broke. dartbug.com/new
You can document multiple things at the same time by passing multiple entrypoints. Note: if you have multiple entrypoints, you should use the 'pkg' command line option to specify your packages folder.
You shouldn't need a wrapper file, but dartdoc should document every library that was imported in the entrypoint, so a possibility is to just have a simple file that imports all the libraries you want documented. We're working on something better for this, and I'm sorry it's a little broken at the moment.
Basically I need to send to my designer a non-finished rails website.
My Designer doesn't have ruby / Rails environnement installed and should be able to:
modify the CSS
add some html elements
I can manually check the diff after he worked.
Is there a way that I can make an easy extraction of my app or giving an access to the deployed one with capacity to re-root the css from his files?
Based on your question, your designer, in addition to the design, also writes code: he creates css files, and edit your views files. That makes him an integrator.
As such, he should learn the basics of source control management, such as git, svn or any system you prefer (my favorite is Bazaar, for its simplicity).
It is a best practice that will allow you to save some time and avoid a lot of headaches when merging your revisions. A nice side effect: he will be able to easily roll-back to a previous working version of the code, should anything bad have happened.
I develop rails applications with my designer who has minimum knowledge about rails.
She works on Windows through file-sharing from a Linux server.
She always has hard time finding view files to work on.
I usually use 'grep' to find a view file.
But she can't.
If you have a good suggestion, please share with me.
I have an idea which may be overkill.
Is there a way to automatically add comments around view files (including layouts and partials?) in html file?
Like this:
<!--Starting app/views/some_dir/some_file.html.erb-->
HTML here...
<!--Ending app/views/some_dir/some_file.html.erb-->
This way, my designer can find the file very easily.
Of course, this should be automatic and development environment only.
Thanks.
Sam
I use the Rails Footnotes gem (https://github.com/josevalim/rails-footnotes) in some of my projects which allows me to click a link in the footer of my app that opens the current view (also shows partials) in TextMate. Not sure if it could be customised to work with a Windows text editor but you could look at the URL to work out the file name.
I.e to open a file in MacVim, it creates the following link:
mvim://open?url=file:///Users/steveholt/Sites/foo/app/views/projects/log.html.haml
and for TextMate:
txmt://open?url=file:///Users/steveholt/Sites/foo/app/views/projects/log.html.haml