Put 'about' page by default in cgit projects - cgit

Is there any way to put the "About" page instead of "Summary" by default in specific project or by default in all projects?

Related

Rails 4: Any way to fix/use regular html href links w/o 'link_to'?

So my question is that I have a link to 'pages/home' and I click on it, ill go to my home page.
But then I'll try to click again, but the link changes to 'pages/pages/home' and then I'll get a routing error. Is there anyway to fix this using regular old anchor tags? or do i need to use link_to?
edit:
This is how i insert my link into the page.
Home
This is not related to rails, the problem is you use a relative url :
Home
This will lead to <any_path_you're_in>/pages/home.
For it to be absolute, you have to use (note the leading slash):
Home
By the way, it's quite a bad practice to use hardcoded url to your own rails app. You can avoid using #link_to while still taking advantage of rails' routing :
Home
Provided you have a "home" route, of course :
get '/pages/home' => 'pages#home', as: 'home'
This will save you a lot of pain when you decide to restructure your app.

How to create a custom page in ActiveAdmin gem

Ruby 2.0, Rails 4.0, PSQL 9.3
In the ActiveAdmin documentation there is the example:
ActiveAdmin.register_page "My Page" do
content do
para "Hello World"
end
end
Where do I put this code? The documentation says:
In the above example, a new page will be created at /admin/my_page
with the title “My Page” and the content of “Hello World”.
This implies that such a file would be created automatically somehow? Nevertheless, I created a file named import.rb under app/admin and the Import item in the menu does appear. However, I am not able to use HTML, as this file is .rb and not .erb. I suppose, in order to be able to use html, I need to create a partial and den render it within the content method. But when I look under app/views there is not admin folder (only layouts). Does this mean I need to create the folder admin under app/views? If yes, where should I put my partial - directly under app/views/admin or under a new folder app/views/admin/import?
I am sorry for the menu questions, but the documentation of ActiveAdmin is pretty modest. I would really appreciate if someone could provide a more details explanation of the steps needed for creating and adding content to a new page in ActiveAdmin.
What the documentation meant was that if you create a new custom page app/admin/my_page.rb, this page will be available in the URL /admin/my_page (if you are using the default ActiveAdmin configuration).
Regarding rendering of an ERB or HAML partials for your my_page.rb, you can do it this way:
ActiveAdmin.register_page "My Page" do
content do
render :partial => 'about'
end
end
This will look under the directory app/views/admin/my_page/. If the directories do not exist, create them. Also, you can still specify other directories by referencing the full template path (e.g. shared/sections/about) like you would for a non-ActiveAdmin controller.

Restful route design for adding item to container

My cart can have many folders. Those can be nested, but are always displayed as a whole. I want to design an interface to add new item to the folder.
My plan is to have a button for folder, after clicking it, the products#index is displayed. The user select one product, and in the products#show page, the user fills some options and click submit, then the item is added into the particular folder.
What's a RESTful way to design the routes?
My rough design is the following. Is it okay?
get folders/13/add_products/
get folders/13/add_products/3
post folders/13/add_products/3
In general, you should avoid verbs (e.g. "add") in RESTful routes:
GET /folders/:id/products
GET /folders/:id/products/:product_id
POST /folders/:id/products/:product_id

AttributeRouting generate links with specified language

I would like to know if there is some way to using Html.ActionLink to set in which language has to be generated the URL of link using AttributeRouting. I have tried with:
Html.ActionLink("DescriptionLinkText", "Controller", "Action",
new { language="en" }, null)
but it doesn't work. Is there a way to set to AttributeRouting in which language has to be generated the URL.
What I need is to put at the top of my website links to change the current language. For example if the user is at /en/contact and click on links to change to spanish I want the same page was reloaded but in spanish language /es/contacto instead of redirecting to home page, for this reason I need to generate URL's in different culture of CurrentCulture to allow to change language and continue to the same page.
Thanks for your help
Why don't you use resources for localization?
#Html.ActionLink(LocalizedResources.ActionLinkLabel, "Action", "Controller")
update:
#Html.ActionLink(LocalizedResources.ActionLinkLabel, LocalizedResources.Action, LocalizedResources.Controller)

Rails Routing

I have built a new portal on Rails which can be accessed as say: https://xyz.com
The problem with this is:
1.) It has 2 tabs – “ShipmentInfo” , “Aging Shipments Dashboard” both implemented using
<li> tags and YUI library’s tabview.
<ul class="yui-nav">
<li id="tab1" class="selected">Shipment Info</li>
<li id="tab2">Aging Shipments Dashboard</li>
</ul>
2.) When I click on “Aging Shipments Dashboard” tab – url should be – https://xyz.com/#tab2 but you get to see only https://xyz.com . I presume it because of client side implementation of Tabs.
3.) After I click on “Current Summary” button in that tab, I get the corresponding results but instead of showing me the active Tab set to “Aging Shipments Dashboard” it is always set to “ShipmentInfo” tab.
How can I set the activeTab on getting the results to corresponding Tab from which request has been placed ? All form requests use GET method.
Or is there a way wherein I can explicitly mention in routes.rb, basing on the params that the activeTab should be set to “Aging Shipments Dashboard”?
Thanks,
Raja.
As far as I can tell, whatever the YUI does to transform that ul into a set of tab probably has nothing to do with the hrefs inside the li. I think you should verify the usage syntax for producing your tabs.
Moving on, the href links only point to anchors within the current page. Which means the client (browser) doesn't have to send an HTTP request to re-get the current page. I don't think that modern browsers ever do. I doubt they send the anchor part of the URL (the part after the #) since the HTTP server doesn't care about that information.
What this amounts to, is that your rails application is never notified about when the user clicks on a tab, and never gets the part of the URL after #. So you can't put any rules about it in the routing table.
EDIT: I forgot to tell you what really should happen.
The YUI (or some other javascript code) should attach to the onClick of the li, which looks like a tab, from your description.
When the user clicks on a tab, it reads the URL, and in some way divines what content-tag to display as the tab's content. For example, this could be a div that contains the 2nd tabs content, and it could have an id of tab2 or something.
It then makes the current tab's content invisible. Usually the is done using the CSS display property, setting it to display: none.
Finally, the content for the tab that was clicked on is made visible. Which would be done using display: block or something simliar.
Yes. You probably already have these lines at the end of your routes.rb file:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Change them to:
map.connect '#:controller'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
This way you can define the two variables as different controllers within the rails app. You could probably do the same thing as two actions too, but that's your call.

Resources