Call a function in clojure website - angularjs

I just started learning some Clojure and i have some general questions about it, since i can't find anything about it in google.
I will create a website with clojure. How can i call a function on the website via an a-Tag or a button? Is this even possible? If not, how can i react to user interactions?
is it possible to pass data through clj files? I have experiance with Angular JS. There, if I want to share data, I just store it in a global factory and later I can just access it. Is this also possible in clojure? I don't want to use angular or JS in this application.
how can i get data from an url: /myroute/myId (car/5). I want to get the ID 5.
I hope you can understand my questions. Thanks in advance

You can use Clojure to make a robust back end server. You can use a library such as compojure for routing. This enables you to transfer data via request and response maps. For the front end you can use Clojurescript (which unlike Clojure, runs on javascript). Clojurescript is not easy to set up until you are very comfortable with how projects are set up in Clojure.
The libraries and plugins that I definitely recommend are:
For Clojure (back end):
Ring
Compojure
clj-http or http-kit
For ClojureScript
figwheel

I suggest you start off with learning the back-end (pure Clojure) and then move on to the front-end (ClojureScript). You could make a simple REST api using Compojure and use static HTML files to talk to them (or use Swagger).
There are other and better (IMO) libraries for building web backends in Clojure out there, but Compojure is a good one if you're not very experienced yet.
Don't jump to ClojureScript before you're comfortable enough with Clojure! Otherwise you'll get lost :-).

Related

Use Vue3 components/routing in AngularJS project

My task is migrate incrementally from AngularJS to Vue3. The idea is to start using Vue components in some places, rotes, server requests.
Is someone has success story using Vue3 components/routing in AngularJS project?
I've spent few days trying make it work, but in internet there is no example about it. Only Vue2/AngularIO, Vue3/AngularIO, Vue2/AngularJS, etc.
Not sure what more information I need to provide.
Thanks in advance!
I think one good way to achieve such a complex migration would be to borrow some principles from the microfrontend architecture principle.
Just divide your application in big components, that you would like to convert one by one.
Take a big component of your application, rewrite it in VueJS, and make it communicate to the rest of your application using custom events.
That will allow you to work incrementally, without using any additional component or library to make the transition.
Just be sure to define clearly the boundaries between your different components, and don't try to apply this approach to very small components (as there will be some overhead involved by adding this event communication).

Make Angular Web App available offline

I am struggling with some details about finding a solution to make an Angular / C# app available offline.
My idea would be to use upup.js the get the business logic for the SPA in Angular available offline. upup.js uses service workers to do so. I would store the data required for the offline app using angular-localForage which uses IndexedDB and falls back to WebSQL and localStorage in case.
The problem is, that I have to make files and images available offline too without requiring the user to visit the page they are being used on and I am worried about the maximum quotas. I could store them using either upup.js and adding those files as assets, or store them with angular-localForage as blobs. IndexedDB is supposed to be unlimited by now if I am informed correctly? I couldn't find any maximum quota for a service worker though, as the upup.js solution would use. The AppCache is deprecated, so I wouldn't use that... Or maybe I understood something completely wrong, or there is even another, better solution? Anyhow, the question is:
TL;DR: What is the better way to store files for an AngularJS offline application: angular-localForage (IndexedDB etc.) or a Service Worker (upup.js) and what are the maximum quotas for each solution? Or is there an even better solution?
In my opinion Service Worker (SW) is better than tradition local storage. Plus SW can also use indexedDB.
For the implementation, it is very depending. How your app structure, what technologies of front-end being with with your angular app, what is your main goals of using SW...?
1. Traditional JS loading, you are likely merge all the JS file in one... like app.js contains everything.
And you also don't care about Push Notification neither any other cool features that SW offering.
=> For this case it seem like upup.js suite you the best.
NOTE : beware that upup.js attempt to registering SW on it own, so it likely blocking or complexified your work on expanding feature of SW.
2. Advanced AMD user, where almost all of your JS chopped to small pieces... like fooCtrl.js, barCtrl.js, etc...
For sure you don't want to configure like 100+ files of JS, and further more you will got a lot of html template to load.
=> In this case I will suggest you to use sw-toolbox . A very powerful and light weight tool made by Google. At initial if you are not familiar with SW concept yet, you will have a bit of trouble setting it up for your site (but it won't be longer than a day of you are an advanced JS developer)
After all has configured, all become so very simple. For example this is how I cache all of static content in my site.
self.toolbox.router.get(/(.js|.css|.png|.jpg|.json|.html)/, self.toolbox.fastest);
3. You don't care about what kind of technology at front-end side. You just interest with SW.
=> Simply go for sw-toolbox it's a real time-saver for basic configuration. And if you want to expand the usage of SW, you can just expand it by your own will.

How to perform Language translation on Single Page App with Angularjs and Laravel

I have been thinking implementing translation for my app and I have the following idea
Make the English and My language [Amharic] mirror jsons and render English if selected. Just configuration Json file from the server that gets called once app routed
Make all in one API to get the json once and persist
will it be a good idea,How is this implemented on real world
Don't need to implement it yourself. angular-translate is an excellent module, here you can take a look at it: https://angular-translate.github.io/ .It covers everything you need.
It is plenty of features and some of them are:
Flexibility
Pluralization
Directive
Filter
Service
Asynchronous loading
Keep in mind that this module has been there for a long time and many people use it. You can solve everything you need and there is no need to reinvent the wheel.

Using Skue or similar frameworks to build REST API on google-app-engine

Searching for ways to build REST APIs, I found skue (https://code.google.com/p/skue/). However there is not much information on the site. My plan is to build a rest api as follows strictly:
Models << Business logics << Restful Resources.
What this means is: the models are access exclusively by the business logic; the restful resources interface is the only layer a client has direct access to. I am specifying all this to avoid people suggesting using the appengine-rest-server.
My question is: has anyone ever successfully used Skue? If so do you have any examples you would not mind sharing? GET and POST would be sufficient, but more is welcomed. If not Skue, are there any frameworks out there that allow building such rest-apis on top of the google-app-engine?
Why not just use json.loads() and get dictionary? In python (unlike in Java) dictionary is a first-class citizen.
As a seasoned Java programmer I was tempted, when moved to Python, to load all data into objects which I defined elsewhere, but I found that it's perfectly OK in python to get a dictionary and use it instead. It's so much easier to pass dictionaries and use them in many places (for example as keyword parameters in methods). Simply use more tests ...
In python you are moving the static compile check towards the dynamic unit-test check, and that's perfectly ok in pythonic way.

What's the best way to do a jQuery autocomplete tag that draws data from GAE

i have something here that is basically from jqueryui. Yes, it is raw and the example uses JSON to handle the autocompleting process. My back end developers are using python on GAE and they usually just draw data out from the gql direct and dump it into the webpage. i need this function to create tags just like stackoverflow. What is the best practice in my situation here?
Whiff includes support for both GAE, jqueryUI, and AJAX that works really well for me. Have a look at http://whiffdoc.appspot.com -- particularly the tutorials.

Resources