Sass why is useful

Posted by Pablo Ifran on November 26, 2010

Sass is used for generating css files based on his own syntax, it’s very useful because allows you to avoid repeating code across the different scss files using import (allows you to import code from other scss file), or mixins(scss functions). Also, allows you to write varibles, for using in different scss, this makes easier to do different templates based on colors or images for example.

_sprites.scss

@mixin sprite_for($image_class, $x, $y, $image: "/images/sprite_image.png") {
  .sprite_image.#{$image_class} {
    background: transparent url($image) no-repeat scroll $x $y;
    height:16px;
    width:16px;
  }
}
_images.scss
$my_sprite_image_path: "/images/my_sprite_image_path.png";

default.scss

@import "sprites", "images";

@include sprite_for("my_image", 0, 0, $my_sprite_image_path);

That generates

default.css

  .sprite_image.my_image {
    background: transparent url(/images/my_sprite_image_path.png) no-repeat scroll 0 0;
    height:16px;
    width:16px;
  }

So, this is best sorted using this method, because you have the image path in a single file and you use it in other files only by importing the file with the images path, it’s also simpler to remove an image because you only need to find the references to that variable and delete them.

The sass framework also allows you to use the DRY principle because you can write nested selector, I’ll show you with an example:

default.scss

.some_class {
  width: 100px;
  .some_other_class {
    display: block;
  }
}

default.css

.some_class {width:100px;}
.some_class .some_other_class {display:block;}

Doesn’t affect the performance because it generates a css file at development time.

It also allows you to benefit from some of the advantages of css 3 right now.

Juggernaut: Chat on Rails

Posted by ivan.etchart on November 19, 2010

To implement chat on Rails we need the Juggernaut gem. The newest version of Juggernaut is build upon nodeJS.
1. Install Juggernaut:
First, install nodejs (http://nodejs.org), redis (http:/code.google.com/p/redis/) and Juggernaut gem (gem install juggernaut).
Then download server git clone …
2. Integrate with Rails to implement chat!
After Juggernaut gem is installed, add it to environment.rb:
config.gem "juggernaut"
Suppose you have a system with user authentication, the idea is to generate an environment where you’re able to chat with other users and see to what extent features can be added in order to create an awesome chat!
Note: Providing a step by step guide to create a working chat isn’t the idea of this tutorial. It’s to show different possibilites to develop on
Juggernaut.

Connecting to Juggernaut from Rails

It’s necessary to add the file WebSocketMain.swf to the public folder. This hasn’t to be exactly this way, you can change its location, but if you do, then you’ll have to change the WEB_SOCKET_SWF_LOCATION, due to an issue with Firefox (… for further information visit juggernaut git page).
Juggernaut serves every file necessary for running by default, so you can leave them on the server where Jaggernaut is installed and configure everything in your client (mainly due to Firefox) in order to avoid adding extra files to your project.
Add to your view this line:
<script src="http://localhost:8080/application.js" type="text/javascript" charset="utf-8"></script>
Note : you can add this file in another way or eventually add it to your project if you want.
Inside another script tag:

var jugger = new Juggernaut;
** Connection events provided by Juggernaut
Juggernaut provides you with three different events : Connect, Disconnect o Reconnect.
jugger.on("connect - disconnect - reconnect", callback)
You can use this events to implement whatever function you want to execute, i.e. alerting when a client has connected:
jug.on("connect", function() {alert("I'm connected!!");});
At this point you have the connection of your client ready, you can test it, you have to start Juggernaut. * First run redis :
./redis-server redis.conf

(whereever you have installed it) *

Then go to the folder where you’ve downloaded the server to and run juggernaut:
node server.js
Let’s chat!
Now that we have everything going, would be a good time to start chatting.
First you need to subscribe to a channe. Inside the channel you’ll be able to connect and user messages scope is restricted to channel.
Then :
 jug.subscribe("name_or_channel_id", function(data) { .. here you'll handle all messages coming from channel ... })
Clarifying a bit… with this function we subscribe to the channel and can pass a function as a parameter to handle data coming from it, i.e. any user’s messages, let’s give an example:
First you need to have a div tag with an id (id_div), what you want is to append a list element containing message content to the div element everytime someone sends a message.
jug.subscribe("name_or_channel_id", function(data){
var li = $("<li />");
li.text(data);
$("#id_div").append(li);
});
You can have a div or textearea element, adding text to a textarea element is relatively simpler, it’s enough to do

textarea.value += (data + "\n");

but you’ll lose customizing power. li elements can be enriched with style, making the chat more attractive.

You’ve received data and added to a div element, but you’re still unable to send data. Let’s setup a form:
<% form_remote_tag(:url => path_to_send_message_method, :success => "$('#msg_body').value=''" do >
<= text_field_tag 'msg_body', '', :size => '50' >
<= submit_tag 'Send Message' >
<% end %>
And the method :
def send_message
Juggernaut.publish("name_or_channel_id", parse_chat_message(params[:msg_body], current_user))
end
parse_chat_message? … Yes, before publishing data, you can process it and why not modify it a bit.
def parse_chat_message(msg, user)
return "#{user.login} says: #{msg}"
end
We are sending information to Juggernaut with this format : ‘usuario says: something’
Done!, you have your server up and running, and know how to send and receive data, there’s nothing else to try.
Extras:
Private chat case :*

You can’t call a chat a chat if you can’t have a private conversation with someone. A good way of implementing this, is subscribing your users to a particular chatroom identified by user’s id. Simple add another subscribe:
 jug.subscribe("name_or_channel_id", function(data){ .. handle private message .. }
The receiving user must be able to subscribe to your chat and send messages to you.
To achive that, you should write a function that when you click on the user you want to send a private message to, subscribes to its chatroom and allows you to send messages to the user. This can be implemented in many different ways! You’ll have to simply make your choice according to your needs!

moove-iT was selected to develop the social network for the Ceibal project !

Posted by Martin Cabrera on June 25, 2010

ceibal

This past june 24 Moove-it won the contest “Best ideas for Ceibal 2010” organized by Rayuela and the Ceibal Plan (One laptop per child), presenting its idea “Together with Ceibal”.

Follow this link to read the official information (spanish) Rayuela Web site of Best ideas

Moove-it was selected by the Ceibal Plan as the company who will develop the first social network for more than 400.000 students of primary and high school.
The idea is to build
a web-based tool which will allow students and teachers
to interact inside and also outside the classroom. The platform will provide virtual classrooms where teachers can work directly with their groups using all the benefits of the Web, Internet and XOs. Students will also be able to use the tool to meet each other, share their interests or even play together.

This video shows a brief idea of what the “Ceibal Plan” is.

It feels really good to be part of something like this!

joomla + virtualmart our e-commerce solution

Posted by mn.burghi on March 22, 2010

virtualmart JoomlaLogowSlogan

Virtualmart – This is a package of solutions (components, plugins and modules) to create online shopping web sites with Joomla . It provides many tools to make an e-commerce solution.

Joomla – CMS (Content Management System) Open Source based in Php and mysql.

We are building a couple of sites using this combination: www.uruguaycompras.net and deportes.universia.edu.uy (coming soon).

In our opinion Virtualmart (VM) is the most complete open source solution to build this kind of sites. After installing Joomla we add the component and a lot of modules and plugins (see the instructions: http://virtuemart.net/documentation/User_Manual/Installation.html)
After that you can configure your virtualmart solution with different ways of payments (e.g. paypal, on delivery, etc.), different providers, different currencies, different vendors and so on.
VM has a complete back-end administrator to manage all the information and all the shopping process.

This picture shows the administrator panel.

virtualmart

From our experience, VM has two problems without solution until now. We expect to solve these issues and share this stuff to all the community.
The problems are:

  • multi vendor management – this module is in alpha version to developers. You cannot manage two or more providers. For Instance: we have a site for a reseller company and they sell products of different vendors. VM solution doesn’t consider this situation.
  • multi currency solution – VM allows to manage as many currencies as you want (more than 100 for default, and you can also add others if you want). But in the checkout process and in all the shop gallery you don’t have the possibility to show more than one currency.

We expect that in the next two weeks we could have another post sharing these solutions.