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
import React from 'react'; | |
import { View, Text, TouchableOpacity, Image} from 'react-native'; | |
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'; | |
import {faHeart, faComment, faPaperPlane, faBookmark} from '@fortawesome/free-solid-svg-icons'; | |
import {t} from 'react-native-tailwindcss'; | |
const PhotoPost = ({post}) => { | |
const {image_url, username} = post | |
return ( |
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
import React, {useState, useEffect} from 'react'; | |
import Axios from 'axios' | |
import {ScrollView} from 'react-native'; | |
import PhotoPost from '../components/PhotoPost'; | |
const Home = () => { | |
const [posts, setPosts] = useState([]) | |
useEffect(()=>{ | |
Axios.get('http://localhost:3000/image_post/index') |
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
import React from 'react'; | |
import {NativeRouter, Switch, Route} from 'react-router-native'; | |
import { t } from 'react-native-tailwindcss'; | |
import {SafeAreaView} from 'react-native'; | |
// Components | |
import BottomNav from './components/BottomNav'; | |
// Pages | |
import Home from './pages/Home'; |
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
// copy and past your code here |
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
2.4.1 :001 > user = User.find(1) | |
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]] | |
=> #<User id: 1, username: "cgibsonmm", email: "cgibsonmm@email.com | |
2.4.1 :003 > user.forum_posts.first | |
ForumPost Load (0.4ms) SELECT "forum_posts".* FROM "forum_posts" INNER JOIN "forum_threads" ON "forum_posts"."forum_thread_id" = "forum_threads"."id" INNER JOIN "forum_topics" ON "forum_thr | |
eads"."forum_topic_id" = "forum_topics"."id" INNER JOIN "forum_categories" ON "forum_topics"."forum_category_id" = "forum_categories"."id" WHERE "forum_categories"."user_id" = ? ORDER BY "forum | |
_posts"."id" ASC LIMIT ? [["user_id", 1], ["LIMIT", 1]] | |
=> #<ForumPost id: 8, forum_thread_id: 7, user_id: 1, body: "<div>;flahd f;kjahda fkjhdflkajhflasjdkfhalkjhlfaj...", created_at: "2018-11-08 00:13:11", updated_at: "2018-11-08 00:13:11"> |
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
module ForumPostHelper | |
def render_post(string) | |
to_return = [] | |
unprossesed = string.split('https') | |
unprossesed.each_with_index do |s, i| | |
if i.zero? | |
to_return << s | |
elsif | |
to_return << parse_adrress(s) |
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
$(document).ready(function() { | |
Trix.config.attachments.preview.caption = { | |
name: false, | |
size: false | |
}; | |
function uploadAttachment(attachment) { | |
var csrfToken = $('meta[name="csrf-token"]').attr('content'); | |
var file = attachment.file; | |
var form = new FormData; |
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
class ForumThreadsController < ApplicationController | |
before_action :authenticate_user!, except: [:index, :show] | |
before_action :set_forum_thread, except: [:index, :new, :create] | |
# before_action :set_forum_subject | |
def index | |
@q = ForumThread.search(params[:q]) | |
@forum_threads = @q.result(distinct: true).includes(:user) | |
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
function uploadAttachment(attachment) { | |
var file = attachment.file; | |
var form = new FormData; | |
form.append("Content-Type", file.type); | |
form.append("forum_post_photo[image]", file); | |
var xhr = new XMLHttpRequest; | |
xhr.open("POST", "/forum_post_photos.json", true); | |
xhr.setRequestHeader("X-CSRF-Token", Rails.csrfToken()); |
NewerOlder