• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
 
 

I made a simple plugin to explain a concept of render-filters.

merb_render_filter

In your controller,

   1  class Posts < Application
   2    before_render :set_title1, :only => :show
   3    before :set_title2, :only => :show
   4  
   5    def show(id)
   6      @post = Post.get(id)
   7      display @post
   8    end
   9  
  10  private
  11    def set_title1
  12      @title = @post.title # <= you can access to @post here
  13    end
  14  
  15    def set_title2
  16      @title = @post.title #=> @post is nil!
  17    end
  18  end

Without this plugin, you couldn't access to instance variables from before-filters. Of course you can prepare @post in the first before-filter so that you can access from other before-filters. But why Merb has the action-args? They are ignored in such case. This was the problem I wanted to solve by the plugin.

posted by Png takiuchi on Sun 1 Feb 2009 at 10:19

I released the merb_full_url plugin that provides URL which has origin (scheme, host and port)

You can install this gem like this;

   1  % sudo gem install merb_full_url --source http://merbi.st

And you get full URLs by calling full_url/full_resource methods instead of url/resource.

But I think, it is better for merb to become providing such methods in advance :-)

posted by Png takiuchi on Sat 24 Jan 2009 at 02:30

I am using merb with passenger on our production server. The passenger is going well in most of cases. But if dependent gems have been updated, it becomes acting up when it got restarted. After I encountered such situations several times, I decided to begin investigation about the issue.

Detail of the issue is as follows.

  • My merb app becomes causing errors after restarting of passenger by "touch tmp/restart.txt" if dependency gems were updated and they have no compatibility.
  • Even if the gems were compatible, my merb app kept using old gems until apache is reloaded.
  • pids were changing successfully while restarting.
  • /etc/init.d/apache reload can refresh everything as expected.
  • "touch tmp/restart.txt" can't.

I wonder there is the master of master processes which keeps LOAD_PATH and it is refusing to use new gems. I am thinking I should investigate the Rack.

Update

Finally, the issue was solved!

The solution is found here

posted by Png takiuchi on Sat 17 Jan 2009 at 22:42

Recently, I've been making web sites by using Merb. It was like a battle lacking logistics.

I made and released dm-pagination on github. http://github.com/genki/dm-pagination/tree/master

Yes, I know dm-is-paginated-0.0.1, but its spec files was not working. The dm-pagination is able to be used with arbitrary collections which include scoped_query.

You can easily paginate, like this:

   1  class Posts
   2    def index
   3      @posts = Post.paginate(:page => params[:page])
   4    end

Links will be drawn by calling simple helper method.

   1  <ul>
   2  <% @posts.each do |post| %>
   3    <li><%= h(post.body) %></li>
   4  <% end %>
   5  </ul>
   6  <%= paginate @posts %>

merb_slice-gen is also available in order to provide useful generators for slices of which it has namespace but doesn't have subdirectories.

You can generate controller, resource and resource_controller in slice project, like this

   1  % slice-gen controller top

it generates controller files enclosed by SliceName module without any subdirectories.

In addition, there are other gems I made.

posted by Png takiuchi on Thu 15 Jan 2009 at 03:05

I made a SIMBL plugin for Terminal.app which enable us to copy on selection. Here is the plugin named TerminalCopyOnSelect.

TerminalCopyOnSelect.bundle.zip

INSTALLATION

  1. At first, you should install SIMBL.
  2. Download the zipped plugin file I mentioned above and expand it.
  3. Copy the extracted file "TerminalCopyOnSelect.bundle" to the plugin directory which is located at ~/Library/Application Support/SIMBL/Plugins/
  4. Terminate all processes of Terminal.app and restart it.

You're done! Now you can get copied selected text from the terminal when you released mouse button on it.

You are also able to disable this feature by turning off the following menu "Copy On Select".

ss01

Finally, I opened the source of this plugin on the GitHub under the MIT license.

Enjoy!

posted by Png takiuchi on Tue 25 Nov 2008 at 19:11 with 8 comments

I thought that the engineer's happiness is always in an expanding market of which it's expansion is benefit to all players.

Because the market is tolerant to mutual cooperation.

posted by Png takiuchi on Wed 22 Oct 2008 at 03:14

This release includes a small spec change.

I changed spec of count method. Now it works without :group option. If you want old behaviour, you can use count_ids method instead.

http://github.com/genki/pagination_scope/tree/master

Good luck ;-)

posted by Png takiuchi on Sun 28 Sep 2008 at 03:57

Today, maiha, the author of the one of the most authorized books regarding rails in Japan, had sent me a patch including various improvements for the PaginationScope. I want to say thank you for the great contribution.

And then I merged it into the master and pushed to the GitHub.

http://github.com/genki/pagination_scope/tree/master

Here is the list of improvements from Maiha.

<モデル>

  • AR.paginate の第三引数に options を渡せるように変更
  • AR.paginate の options は第一引数でも可能にした AR.paginate(params[:page], 10, options) 以外にも以下のように書ける
       1     options = {
       2       :page => params[:page],
       3       :per_page => 10,
       4       :order => "id",
       5     }
       6     AR.paginate(options)
    

<ヘルパ>

  • Helper#paginate のオプション名を変更 (newer->prev, older->next) 昇順、降順によって newer/older が逆の意味になってわかり辛かったので
  • Helper#paginate の各要素にクラス名を付与 will_paginate のスタイルシートがそのまま使えるように合わせた
  • Helper#paginate のリンクに rel 属性を追加 AutoPagerize 対応
  • Helper#paginate のオプションに truncate を追加 省略時の '...' を設定可能にした

Thanks again!

posted by Png takiuchi on Fri 26 Sep 2008 at 18:48

Recently, the Formula had been slowing down.

The Formula is the service which provides a way to make images of mathematical expressions for embedding it into your blogs, BBSs and so on.

There was the problem in the manner of ranking the referred formulae. So I solved the issue by choosing simpler algorithm.

Now it became faster. Please try it again if you've given up once before for the slowness of the service.

Thank you for patience. I will keep appreciating any kind of feedbacks. Feel free to contact us.

posted by Png takiuchi on Wed 24 Sep 2008 at 03:48

Today, I added the feature mentioned in the title above to the Gist Ubiquitifier.

Gist Ubiquitifier
Uploaded with plasq's Skitch!

Obviously, it lacks title of the commands. This spec came from our purpose of providing transparent service to make pages for installing ubiquity commands.

But it might be provided in the future.

posted by Png takiuchi on Tue 16 Sep 2008 at 21:47