How to collect visit statistics on a Sinatra web app? [closed] - ruby

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm writing a blog application in Sinatra, and I want to collect some visit statistics.
As of now, I'm only thinking of getting more or less reliable visit statistics per user (that is, page visits grouped by users). Maybe later I'll want to get some client-related information (i.e., user agent).
How do I do that?

While you can use Sinatra to do this, the technology has already been implemented in other ways. I think the easiest solution is to put a piece of Javascript on the frontend that records this information for you. The most popular library for doing this is Google Analytics. This will give you far more information than you could easily capture yourself (screen size, device, etc..), and in a very clean format.

My idea to do it:
Use Rack sessions to determine the visitor ID;
Store the hits in a database table
Write a Thor task to unload it into something human-readable.
I'll appreciate any critique of this idea and/or any other ideas to do it.

Related

App like Kahoot; Laravel Sanctum or Passport? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to build a game-app like kahoot, for fun! :)
This will be an app where guests can either register and create a game or just get invited and enter the created game with a PIN. Then they can answer all kinds of questions.
It will be a SPA structured application. Laravel based with Vue on the frontend.I was already thinking of using an ecosystem like Laravel Echo or maybe something like Pusher for websockets.
However, I am puzzled when thinking about what authentication method to use. What authentication would be better in this case? Either Laravel Sanctum or Passport? What would be the benefits and disadvantages of these methods to use? What would you recommend? They both look pretty good options to me. However, I don't want to get stuck at a certain point because I have chosen the wrong kind of auth-method.
I'd love to hear your thoughts about the issue.
Thank you!
If you're using Laravel 7 or higher, I recommend installing Sanctum, it's light weight and is super flexible with VueJS.
But, if it's a big project, use the Passport, it has more features.
See this video from Andre Madarang maybe it helps you out.
https://www.youtube.com/watch?v=D9oIu6jiYLk
But, if you know spanish see this from Aprendible:
Part I - https://www.youtube.com/watch?v=mAdp3lpdNfo
Part II -
https://www.youtube.com/watch?v=Lzm_7ymlgAU
Part III - https://www.youtube.com/watch?v=6mrhs68JOFQ

How to develop RSS Feeder [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I need to build a RSS feeder in Go and I guess I did not understand some key concepts. To make it clear, I ask that question.
Is there any standard for number of last fetched news in XML file?
Should RSS document needs to be generated when requested? I mean should the client get always the latest news?
Here is the Go part. I will use https://github.com/gorilla/feeds library. It basically generates RSS XML. But it does not provide a publishing way.
Should I serve RSS XML document from a REST endpoint? If I do, is it okay for RSS clients?
You may say that first I should search on the internet and I did. Most of the articles talks about parsing and fetching from a RSS Feeder.
Is there any standard for number of last fetched news in XML file?
No. And it also varies between feeds. This also makes sense since there are some sites which produces lots of new content and others only few.
Should RSS document needs to be generated when requested? I mean should the client get always the latest news?
That's completely up to the server. But in many cases it is likely more efficient if the server creates a static file whenever new news were added instead of dynamically creating the same output again and again for each client. This also makes it easy to provide caching information (i.e. ETag or similar) and let the client retrieve the full content only if changed.
Should I serve RSS XML document from a REST endpoint? If I do, is it okay for RSS clients?
This does not really matter. The URL for the RSS can be anything you want, but you have to publish it so that RSS readers know where to get the RSS.

Compare frameworks: spring mvc, struts2, zend, laravel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I must complete the comperation table below. I've searched and filled a few but i'm not sure about my answers.
Can you help me check them?
Thanks so much.
comperation table
I am working on Laravel from the last 5 years, so I can give my perspective on that. According to me, Laravel is easy to learn and fast to develop a framework.
They have artisan commands to create your basic structure very fast.
Routing - Laravel has now categorized routes according to their area, like web routes, API routes and console routes. so you can easily differentiate your routes according to their use.
Database - As you said Eloquent, it is enough powerful. you can use the DB facade as well.
HTML JSON & Image Rendering - Laravel uses a blade template engine so their helpers come very handy. e.g. #yield or #include, now they have even #slots.
helpers are available for assets.
Login - just enter one command basic login structure is ready for you. from registration to forgot password. make::auth command is there. it even creates basic database tables for you. you can override it as well. Authentication Quickstart
ACL - You are free to write your own middlewares.Middleware laravel

Ruby on Rails - KeyCode in Ruby [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is there a possibility to check if a key is pressed in Ruby?
For example:
In CoffeeScript/JavaScript, you are able to say:
$(document).keypress event, ->
alert event.keyCode
Is this possible in Ruby as well? (I know, I could use NodeJS instead of Rails, but that's not my question)
Since Ruby is not interpreted in your browser like JavaScript, it cannot do what you are trying to do by itself. The browser never gets to see any of your Ruby code but only the resulting HTML (and JS) after your controller finished the appropriate method for a request.
Rails is REST based, so each request is executed separately and no state is kept between requests, save for the information in a cookie or similar means. It is not constantly running, waiting for a reply or something like that.
However, you can simply embed JS code like you posted within your Ruby templates. This JS can then check for a keypress event and send a new (AJAX) request to the server for some additional actions. You will need to process the returned values and manually display them using JS code.
If your page or application would make heavy use of such dynamic features, other languages might be a better fit.

recomendations for spring SEO [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a site made with SPRING mvc and jstl. It has a product catalog on it. Can any one give me some recomendations for making it SEO friendly ? I understand that google's spiders searches in the html pages. However, how do i help them index on what it´s on the database (mysql), like the products and some content ? should i read/do something extra ?
Thank you!
Open account with google webmasters: http://www.google.com/webmasters
Make your URIs SEO friendly Best way to create SEO friendly URI string
Write service that will create sitemap.xml file for your site. Sitemap should include all the pages that are not obvious to the indexing spider bots.

Resources