This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_topic | |
@topic = ForumTopic.find(params[:id]) | |
unless @topic | |
respond_to do |format| | |
format.html { redirect_to forum_path(params[:forum_id]) } | |
format.json { render json: {redirect: forum_path(params[:forum_id])}, status: 500 } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.$watch "postPagination.cur", (newVal) -> | |
if angular.isDefined newVal && newVal | |
$scope.loadPosts newVal | |
$window.history.pushState({},"",$scope.currentPath+"?page="+newVal) | |
$anchorScroll() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.$watch "postPagination.cur", (newVal) -> | |
if typeof newVal != "undefined" && newVal | |
console.log newVal | |
$scope.loadPosts newVal | |
$window.history.pushState({},"",$scope.currentPath+"?page="+newVal) | |
$anchorScroll() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.filter("filterTree", [ | |
"$filter", function($filter) { | |
return function(tree) { | |
var newTree = []; | |
angular.forEach(tree, function(node, index) { | |
var newNode; | |
newNode = { | |
id: node.id, | |
sort_order: index, | |
children: $filter('filterTree')(node.children) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 1, | |
"sort_order":0, | |
"children": [ | |
{ | |
"id": 3, | |
"sort_order":0, | |
"children": [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 1, | |
"name": "Игровой раздел", | |
"hidden": 0, | |
"technical": 0, | |
"is_category": 1, | |
"image": null, | |
"description": null, | |
"isCategory": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
If I have a $scope.links array how do I make this in angular? | |
--> | |
<a href="/links/linkl_head">link1_link</a>, <a href="/links/link2_head">link2_link</a>, <a href="/links/link3_head">link3_link</a>, <a href="/links/link4_head">link4_link</a>, <a href="/links/link5_head">link5_link</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#forum.rb | |
def get_all_posts | |
forums = self.subtree_ids | |
topics = Topic.where(forum_id: forums).collect(&:id) | |
posts = Post.where(topic_id: topics) | |
end | |
# Forum has_many :topics and has_ancestry | |
# Topic has_many :posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.factory "News", ["$resource", ($resource) -> | |
$resource("/news/:id.json",{id: '@id'}, {update: {method: "PUT"}, get_total:{method:"GET", params:{get_total:true}}}) | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.controller 'NewsCtrl', ["$scope", "$location", "News", ($scope, $location, News) -> | |
$scope.loadSomeNews = (number) -> | |
$scope.news = News.query {limit: number} | |
$scope.pagination = { } | |
$scope.initNews = (page = 1) -> | |
$scope.pagination.cur = page | |
$scope.getTotal() |