DJANGO COMMON PATTERN : view -> url -> template
Today's Progress: identified the resources that will guide me do my first 30 days thats with django python
Thoughts: the first 30 days, I will do django based projects, then the next 30 days I will spent it doing react based projects, the other 30 I will spend doing ruby on rails based projects.
Link to work: this is the blueprint
Today's Progress: Setting up the environment for django applications
**Thoughts:**you need a virtual environment to run specific django applications; you also need django installed on those directories where you will build your django apps;to run or start an environment on the apps you run pipenv
Link to work: testapp
Today's progress
I have created my first django app and linked it explicitly to the main django project. also I have gotten to learn about all the different python files created when you django-admin startproject and python manage.py startapp ...
**thoughts:**webpages in django are made up of applications, these apps are supposed to be linked explicitly with the main django application; for this you have to edit the settings.py : open the settings.py scroll down to the list of installed applications and add the app on top .
Link to work: urls
today's progress I have created and served my first application page to the web browser I created a view on the views.py which accepts http requests and gives a response the function created in the views is then imported into the newly created urls.py you sync this urls.py with the project level urls.py
thoughts: Django works on request a view the url delivers it to you so it is url -> view -> model(incase)-> template
Link to work: views
today's progress
- created a new project - newpages
- took sometime but I now know the commands off the book
- the steps include: create a directory(mkdir pages) cd into the directory(cd newpages) pipenv an environment (thats pipenv install django) run the environment(pipenv shell) create a django project(django-admin startproject pages .) create an app(python manage.py startapp pageapp) exit the environment(exit) with this you are all set to start your django project
**thoughts:**that dot we include at the end of django-admin startproject is really important to avoid redundunacy of directories being created ensure you are working on the environment for the right application lest you mess up the environments, that's the point of creating all this environments
Link to work: pageapp
today's progress
- created a django template in index.html
- updated the settings.py to reroute django to check for templates in the django project-level directory(you do this by finding the templates[], and update 'DIRS': [] to this line 'DIRS': [os.path.join(BASE_DIR, 'templates')],)
- index.html has html content to it
**thoughts:**every web page that you are going to serve to the web is in form of htmls, the generic model to do this is: template -> views -> urls (this pattern holds for every Django web page you make)
Link to work: templates
today's progress
- added the template view to the views.py
- added the view to urls.py
- upon running the server, I got an error of : "TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'"
- I will come back later and work on this since I have not found the solution yet to it
what the code was supposed to do: serve me a webpage having the line: first django template
error:" TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'"
line that was containing the error: in the pageapp urls, the file we created , when configuring url patterns this is the line I had written:
urlpatterns = [ path('',HomePageView.as_view(),name='home'), ]
updated line that fixed the error:
urlpatterns = [ path('',HomePageView.as_view(template_name="home.html"),name='home'), ]
**thoughts:**I have no thoughts today, I have encountered an error, and until I solve it, I don't, it is something to do with how I am serving my webpages, but I will be back to this
Link to work: views.py
today's progress
- created an about.html template - purpose is to serve the about's page
- created a view for the about's page in the views.py
- routed the url of the view(AboutPageView) in the app's urls.py
- upon running the server at about, the page worked perfectly
thoughts: yesterday I encountered an error,about template_name not defined, the solution to it is to pass a parameter into your as_view() method; that is to say: path('',HomePageView.as_view(template_name="(nameofthehtmltemplate for this case)home.html"),name='home')
Link to work: urls.py
today's progress
- created a new template base page
- this template acts as a navigation bar
- navigation bar is normally consistent across all the pages present in a website
- it contains links to the other pages present in the app
- visit the link below to see how they are called into the base.html and how the base page extends to the other pages.
thoughts: creating a navigation page in django is pretty easy, you just have a template on its own, write and style it up to your perfection and then extend it to the pages you have in your application.
link to work: base bar
today's progress
- in tests, we have added a new class, with two methods.
- Each method is designed for each of our two pages home and about
- It gets the status code of the client side
- Then compares it with status 200
- Returns true if it passes the code.
thoughts: writing tests code, can really save you a lot of time, because you don't have to manually check your pages if they are being served to the client
link to work: tests
today's progress
- the site to use for deployment is heroku
- the directions and commands on how to done the deployment are found in heruko
- I haven't succeded yet, encountered an error: Couldn't find that process type (web). when I run heroku ps:scale web=1
thoughts: I have to take a break before this deployment stage bursts me up, I will work on it tomorrow
link to work: procfile
today's progress
- basic layout of the message_board_app
- blog : name of the directory
- blog_project : name of the blog projects
- blog : name of the apps
- add the created app in the list of installed apps in project level
Thoughts: it is the start of a project with backend servers.
link to work: django base setup
today's progress
- created a database model
- created a view to help serve the content
- configured the project level urls and the app level urls
- created templates to help on creation of the webpages
thoughts: Django is a really exciting framework, creating the databases is something really sweet
link to work: django blog
- created a css file to help in styling
- created a new view, linked it to url to help distribute our pages to individual blogs
thoughts: our page is shaping up, I have gotten the full idea / full picture of how the django works/framework view -> url -> template
link to work: post page
- wrote test cases and imported modules into our tests.py
thoughts: I still need to learn the ropes of these django tests
link to work: tests
- I want a user to add there own blogs
- so I first create a new url to link us to a view for creating the blog template
- I then create the view
- and finally the template that is going to be served to the webpage
thoughts: I emphasized more on what is needed to create a django web page (url -> view -> template) and did a little introduction to forms. right now I can comfortably create a webpage to be served into a webpage
link to work: post form
- created the base requirements for a django application
- created a home.html page to be served when login is successful
- created a superuser for the login justification
- the default django login template works well and the project in genral
thoughts: Django by default has its own login model, and that's what I have used in this project, tomorrow I am going to use a customized view
link to work: loginsystem
- created a customlogin project
- created an account app
- this app has views for the login, registration and home page
thoughts: today's project has emphasized more the urls -> views -> template model django users.
link to work: CustomLogin
- added a functionality for deleting and updating post
- created templates, views and urls configuration for the above functionalities
thoughts: I have added functionalities to the app link to work: views
- used the django login default has illustrated three days ago in day 16.
- created a signview, imported the loginview thoughts: hosting at heroku has been a challange to me upto now, I hope this finallly works
- I created a django custom login page
- I created a superuser account
- more information about the creation of django custom login is found in this README.md
thougths: working with a custom login in django is more inspiring since you have some little of freedom.
link to work: news app
- yesterday I created a custom login project (news)
- Today I have added the ability for a user to sign up/ login /and logout
- with this tested and verified the app newspaper is fine upto this place
- the details and step by step procedure of how I did this is found in this README
thoughts: a user can signup, sign in and log out of my news app. Django automatically looks for the login template in /registration
link to work: signup page
- we need to style our pages/templates so as to be aesthetic
- we are going to use bootstrap for this
- we are going to import this through this with CDN(content delivery network)
- we need to import four things:
thoughts: styling our templates makes them look nice and so we are going to do this using bootstrap, the major heavy lifting has already been done for us.
link to work: bootstrap
this is a third party package lets pipenv install django-crispy-forms we als need to install crispy bootstrap5 so as allow us to use bootstrap5 in our project pip install crispy-bootstrap5 add both crispy forms and the crispy-bootstrap5 to the list of installed apps ('crispy_forms','crispy_bootstrap5') we should also add CRISPY_TEMPLATE_PACK = 'bootstrap4' and CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap5' at the bottom of our file
- many a times a user forgets his login password
- django allows us to enable the user to reset his/her own password
- and for this emails are sent to the user's emails
- we are going to implement this using emails SendGrid
- but first we want to test out the django Backend service which would send the email to our console instead
- implementation of this is found in this README and the templates created for this are found in the registration folder.
thoughts: django does the heavy lifting for us, all we need to do is to tell it were to send our emails, and for today we have ordered django to send it to our console using this line: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' tomorrow I am going to reroute it so that it sends it to the users personal email instead.
-
created an account in SendGrid N/B : use a diffrent email with the ones you have signed up for in our applications.
-
we are going to configure our emails via SMTP.
-
we create an api
-
link it to our settings.py ; first update our EMAIL BACKEND to use SMTP EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
-
add this additional lines below our email backend:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # - sends it via smtp EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_HOST_USER = 'apikey' EMAIL_HOST_PASSWORD = 'paste your sendgrid password here' EMAIL_PORT = 587 EMAIL_USE_TLS = True
thoughts: I need to be able to rely messages to users directly to their emails but it hasn't worked and so I need to restudy this concept of SendGrid well and do it again.
link to work: SendGrid
- my sendGrid is not working as it is supposed to do.
- I have customized the emals being sent to the users though
- I have to redo this last process of user authentication flow.
thoughts: emails are not being sent to the user, there's an opaque problem in this last part of user authentication flow otherwise the other parts are okay - that's signup/login/change password.
link to work: custom emails
- created a new app (articles)
- added the app to the list of installed apps
- configured a new database model
- made our database model recognizable by our admin
thoughts: our articles application would automatically be updating on the time a blog is changed updated or created, that's why we used a timezone. for more information about our articles application, check out on this articles README
link to work: articles
- on today's working, I have added the functionality of editing and deleting the blogs
- django framework is pretty easy - create a url, then create a view and then a template
thoughts: We have created a dedicated articles app with CRUD FUNCTIONALITY C - create R - read U - update D - delete link to work: articles
- like every other blog user, they want a place to leave comments and so today I have added the functionality of a user to leave a comments
- How to do that is found on this readme
- this is the end of my newspaper application.
- what it remains of me is to try and solve the problem of hosting django apps which has been hailing me for the last three or so weeks
thoughts: Django is 99% beautiful web framework, I have covered all the major features of Django: templates, views, urls, users, models, security, testing, and deployment. You now have the knowledge to go off and build your own modern websites with Django
link to work: Django
My django journey comes to a pause here, tomorrow I will start on react N/B: there's a problem when it comes to hosting my django though and I need to work on that !
this is the end of django and start of reactjs
- created a react directory
- React projects require node and npm installed.
command to install node -
sudo apt install nodejs
command to confirm node version -node --version
command to install npm(node package manager) -sudo apt install npm
command to confirm npm version -npm --version
- created a react project called hacker-stories
command used
npx create-react-app hacker-stories
- cd into the directory and run
npm run
this should lead you to a webpage that shows you that your react app is working fine.
thougths: React is a javascript framework created by facebook used for building user interfaces; mostly single-page applications.
link to work: react directory
- JSX stands for javascript html
- it is using both js and html together
- this is enabled by the use of curly braces
- Today I edited the content of app.js so that it displays content I have specifically told it to
- I have also gotten to work with javascript variables and objects
thoughts: the homepage displayed when you first create a react app is found in the app.js and this is the page where your customization has to start. JSX elements are pretty useful here. JSX elements look much like html but with slight tweaks in its tags as it uses camelCase and so the way tags are displayed using html are slightly different to the way they are defined using JSX elements.
link to work: app.js
- I created a variable holding lists, just the common way you can in javascript.
const list = []
- I created a react component line 53. this component is going to help me break down functionalities of my app component.
- to import one react component into another:
<Nameofthereactcomponent/>
thoughts: you should not overload your react app component, breaking it down into smaller and more solid components can come in handy. larger applications have what we term as component hierarchies /trees where it has only one entry point - that's root component.
link to work: app.js
this acts as the bridge between html and our jsx files it takes two arguments: 1. the html item/the react component to be rendered. 2. where it shall be rendered.
thoughts: DOM is Document Object Model - is a tree like structure that contain all the elements and it's properties of a website as its node. ReactDOM purpose is to display the specified HTML CODE inside the specified HTML element.
link to work: index.js
global variables are globally available and can cause pollution it is technically viable to be defined into the components and use props to be available to its child's components you have to use props for it child to access the variables defined in the parent component.
thoughts: Props are arguments passed into React components. Props are passed to components via HTML attributes. props stands for properties.
link to work: props
- I started a new react project
- this was for the sole purpose of having playing around with react components
- I created 4 react components
- placed all this react components in one larger react component
- I then exported or rendered this one large react component
- I also imported an image into our index.html page.
- created a component for it and rendered it into our index.html
thoughts: for a component having more than one jsx element to be complete, you must have a wrapper html element that encloses them all into one html element like
link to work: 30-days-of-reactjs
today I started working with react props - properties indepth props helps us to pass data into childs
thoughts: Instead of injecting data we can also pass the data as props. React props are similar to parameters in functions.
link to work: props
I didn't do much today honestly, but I introduced myself to mapping arrays in react thoughts: In React, we use map to modify an array to list of JSX by adding a certain HTML elements to each element of an array. link to work: mapping
- created a whole new app to help me deal with react states
- I am going to use this app to learn about react states.
thoughts: Image result for react states What Is 'State' in ReactJS? The state is a built-in React object that is used to contain data or information about the component. A component's state can change over time; whenever it changes, the component re-renders
link to work: state
I am still working on the react state component today i have rendered a stateless view to help me understand why we need to use states in react
thoughts: if you want to know the road ahead, ask those who are coming back!
link to work: stateless component
Today my stateful react app is up and running. I have changed my stateless app from using object values to functions.
thoughts: Inside the anonymous function that you pass to setState(), make sure you reference the argument—state—and not the component’s state—this.state. Otherwise, you still run a risk of getting an out-of-date state object. The state in your function will be otherwise identical.
link to work: state
React class based components are the bread and butter of most modern web apps built in ReactJS. These components are simple classes (made up of multiple functions that add functionality to the application). All class based components are child classes for the Component class of ReactJS.
today I rendered my first class based component via having an app dedicated for the class-based components.
thoughts: Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML via a render() function.
Components come in two types, Class components and Function components
link to work: class-based-views
Today I understood and created a component based on class-based individually I exported the app and imported it into my app.js file and rendered it
thoughts: Class based component is made using JavaScript class and it inherits from react Component. link to work: class-based react app
I created a new project to help me understand conditional rendering in React.js' here is where you render a specific jsx element based on the condition of your state. it just works the same way as in javascript. you use the if.... else statements .
thoughts: to use conditional rendering in react you can use : if...else, &&, ternary opearator
link to work: conditional rendering
one will need the user to sign in, submit some information, or even sign up I started working with forms today. and i have created a new project for the forms forms
thoughts: forms are pretty required in every other application since they are some data that has to be submitted so we just need the forms
link to work: form
today I worked with a form that requires one to import different inputs from the user link to work: Diffrent inputs
today I was learning about how I should structure my react folders so as to achieve a neat way of doing things.
from having a folder for components, images fonts and logos, and even for our css style files
thoughts: React doesn’t have opinions on how you put files into folders.
link to work: react folder structure
I want to build a complete react project A shopping list: users should be able to sign in/up users should be able to add products users should be able to see the total add up and decriment this shopping list is going to employ the following react elements: React Hooks Components props useState handling html input in react thoughts: I am excited for this project and I am going to host it
link to work: shopping list
my App.js file has an updated code regarding the adding of items to the list
thoughts: for more information about the code inside App.js, reference this Blueprint
link to work: shopping list
today i have hosted my react project on Netlify
i got to learn how to host a github subdirectory on Netlify
on the build directory:
base - should have the path to the subdirectory REACT/shopping-list
then on the build command use npm run build
then on the publish directory - 'the path then end with build REACT/shopping-list/build
thoughts: hosting on netlify is really easy, it took me a million times to figure out how to host a sub-directory in heroku
link to work: grocery-shop
Go language was developed by google - it's a backend language
in today's projects - I wrote an hello world program that takes the user input processes the result and displays the output.
thoughts: Go lang is built on top of C
link to work: GO-LANG
GOPATH, also called the workspace directory, is the directory where the Go code belongs. It is implemented by and documented in the go/build package and is used to resolve import statements. GOROOT is for compiler and tools that come from go installation and is used to find the standard libraries. It should always be set to the installation directory.
thoughts: Go tools expect a certain layout of the source code. GOROOT and GOPATH are environment variables that define this layout.
GOROOT is a variable that defines where your Go SDK is located. You do not need to change this variable, unless you plan to use different Go versions.
GOPATH is a variable that defines the root of your workspace. By default, the workspace directory is a directory that is named go within your user home directory (~/go for Linux and MacOS, %USERPROFILE%/go for Windows).
link to work: GOPATH & GOROOT
today I have learnt the javascript data types: the primitive data types include: undefined strings null numbers boolean I also got to learn about : inline scripting internal scripting external scripting
thoughts: javascript is preferred to be imported/written on the body than the head of an html.
link to work: javascript
today I reminded myself about js non-primitive datatypes:this include: arrays objects I also reminded myself about the math object in JS, this object helps us in manipulating strings.
thoughts: primitive data types are immutable whereas non-primitive data types are mutable, they can be changed.
link to work: non-primitive data types
today I started learning javascript functions there are different ways of creating functions: Declaration function Expression function Anonymous function Arrow function thoughts: functions can be created to take unlimited number of parameters/ arguments from the user functions can also have a return value or not
link to work: functions
today i started working with js objects everything in javascript is an object objects has key value pairs objects are mutable
thoughts: when creating user defined functions in objects, use normal functions instead of arrow functions since this keyword in arrow functions limits it usability to within the function only and not the object itself as should be.
link to work: object
the BOM (Browser Object Model) allows javascript to talk to the browser. The window object is supported by all browsers. It represents the browser's window.
All global JavaScript objects, functions, and variables automatically become members of the window object.
Global variables are properties of the window object.
Global functions are methods of the window object.
Even the document object (of the HTML DOM) is a property of the window object.
thoughts: The BOM allows JavaScript to “interact with” the browser. The object of window represents a browser window and all its corresponding features. A window object is created automatically by the browser itself
link to work: BOM
Data validation is the process of ensuring that user input is clean, correct, and useful.
Typical validation tasks are:
has the user filled in all required fields? has the user entered a valid date? has the user entered text in a numeric field? Most often, the purpose of data validation is to ensure correct user input.
HTML form validation can be done by JavaScript.
thoughts: JavaScript provides facility to validate the form on the client-side so data processing will be faster than server-side validation. Most of the web developers prefer JavaScript form validation.
link to work: javascript form validation
HTML document is structured as a JavaScript Object. Every HTML element has a different properties which can help to manipulate it. It is possible to get, create, append or remove HTML elements using JavaScript.
Selecting HTML element using JavaScript is similar to selecting using CSS. To select an HTML element, we use tag name, id, class name or other attributes.
you can get elements by:
- Id - getElementsById() targets a single HTML element. We pass the id without # as an argument.
- TagName - getElementsByTagName():takes a tag name as a string parameter and this method returns an HTMLCollection object. An HTMLCollection is an array like object of HTML elements.
- ClassName - getElementsByClassName() method returns an HTMLCollection object. An HTMLCollection is an array like list of HTML elements.
thoughts: HTML objects are considered js objects.
link to work: DOM
exception is when we try catching errors then we execute a specific set of code.
thoughts: for more information checkout on this README
link to work:exception handling
today I start my thirty days of ruby
I have installed the apps, dependecies and the extensions needed for me to start learning ruby tomorrow
link to work: ruby
today, day 2 of learning ruby, I have gone through the basics of ruby data types: this includes: strings, symbols, numbers and booleans ruby has a very smart way of manipulating its data types which include changing from one data type to another. more information about this datatypes are found in this README
thoughts: every piece of code in ruby, has to return something, and those pieces of code that has no return value returns a nil
link to work: ruby datatypes
there are four types of ruby variables:
- local
- global
- instance
- class
thoughts: each of the variables above scope to their specific scopes only.
link to work: variables
to output data in ruby you use print
or puts
input is any data that is read by the program, either from a keyboard, file or other programs. Output is data that is produced by the program. The output may go to the screen, to a file or to another program.
to input in ruby you use gets
thoughts: The print and puts methods produce textual output on the console. The difference between the two is that the latter adds a new line character.
link to work: ruby inputs and outputs )
Ruby arrays are ordered collections of objects. They can hold objects like integer, number, hash, string, symbol or any other array.
Its indexing starts with 0. The negative index starts with -1 from the end of the array. For example, -1 indicates last element of the array and 0 indicates first element of the array.
thoughts: to get all methods associated with arrays you myArray.methods
link to work: Ruby Arrays
ruby has inbuilt and userdefined methods
to build your own methods in ruby you use def
keyword
ruby offers explicit and implicit return capabilities.
ruby methods can take parameters, or even have default parameters.
thoughts: Methods name should always start with a lowercase letter. Otherwise, it may be misunderstood as a constant.
link to work: ruby methods
today I have started learning OOP in ruby it is pretty much the same OOP concepts in the other programming languages
thoughts: I am going to learn deeper the OOP concepts at the code academy.
link to work: OOP
today I have learnt of the ruby constructor methods, instance methods and objects
when a class wants to inherit from a superclass, you use <
thoughts: ruby being an OOP means it can be embedded in an HTML
link to work: RUBY CLASS
today I have started my first project on ruby the caesar cipher
what I have done today under this project has taught me:
hands on splitting of string to array - split and to_a
finding the character integer ordinal - character.ord
and finally shifting the integer ordinal using a key
and also I have learnt to use methods since I am using a method for this,
thoughts: to run ruby on your terminal you just have to type irb
or to run a ruby script you ruby the name of your script
link to work: ceasar cipher
building up on the caesar_cipher game i started yesterday. today my program can encrypt your text well if all your inputs are in small letters.
thoughts: if you want to get the ascii code of a character, you .ord
, and when you have an integer and you want to get its character assuming that your integer is an ascii code you 123.chr
link to work: caesar_cipher
another ruby project you pass a string and an array of words the method iterates over the array and checks if the word atleast exists in the string it returns an hash of the word and the number of times it appears in the string
thoughts: if you want to check if a particular hash key exists in the hash you use the has_key?
method.
link to work: substrings
you pass an array of stocks, the method looks for the day with least stock cost and high stock cost
it then finds the index of the elements and returns them as days.
thoughts: to find the maximum value in an array you .max
same to the least value .min
. To find its index position you use .find_index(element)
link to work: stockPicker
often times we need to import data into our programs and manipulate that data ruby has a special way of importing and manipulating them
we use the File
library provided to us by Ruby.
thoughts: with the File
library we can read lines import content , modify content, delete content and basically much file manipulation
link to work: File Serialization
today I started learning about ruby on rails and thus I needed to remind myself of the HTTPs
thoughts: https version 2.0 allows for multiplexing - many requests sent at once reducing the time required to load a page
link to work: Web Refresher
when we send a request for a resource: it passes throught the Model -> view -> controller controller receives instructions from the router, checks for data from the model then sends the data to the view(HTML template) which will then be sent back to the user.
thoughts: routes: It's a way to redirect incoming requests to controllers and actions.
link to work: routing
ActiveRecord is the M
in the MVC
ActiveRecord is the ORM that allows one to access the databases
thoughts: with Active Records, you don't need to write sql codes to access your database since you can do so using ruby code.
link to work: ActiveRecords
name your classes in singular with the first name Book
ruby on rails will autogenerate the name of your database table books
in small letters and plural. Ruby does a lot of heavy lifting if you follow its naming conventions.
thoughts: ruby actually gives you the plural of your class name, if it is Mouse
you are using as a class name you will get a database table called Mice
.
link to work: ActiveRecord
this is the C in your MVC
it's your controller
to create a new controller you rails generate controller <name of your contorller>
thoughts: ensure that your controller name is capitalized and singular, this will easen things for you.
link to work: controllers
today I started a new rubyonrails application, art App
everything from implementation of the application to models to seeding is found in this README
thoughts: seeding allows us to fund our database with data used for testing our models.
link to work: ART APP
today I was working on the views for my artists in my art app
thoughts: when you create a new method in your controllers ensure you create a .erb view too so as not to get lost.
link to work: artist
I have created an app that uses a joker api to get random jokes and display them.
thoughts: when you include js in your rubyonrails project ensure that you run a js webpack server.
link to work: jokerApp
today I have started learning about databases so that I can use them in my rails applications
I am learning postgres sql
thoughts: classes in ruby are capitalized and in singular and so the corresponding databases are plural and lowercase
link to work: DATABASES
today I have started integrating postgres database with ruby irb
to execute sql databases in irb you use .exec
method on the database you want to access.
thoughts: when you access data in irb it returns it in astring format but hashes, so we need to convert it into a ruby object.
link to work: postgres with ruby
today I learnt something new about routes in rails
several routes can lead to the same url but different methods.
this restful routes can be used in one url under one controller.
to enable all this restful routes, in your routes.rb
you resources :nameofyourcontroller
thoughts: restful routes sync with methods inside the controller and not to urls, they may all link to one url.
link to work: routes and controllers
I am learning the theory part of views and you don't necessarily need to include the html boiler plates since that is taken care of in the application.html.erb
thoughts: yield
method is used to inject views into the application.html.erb
link to work: views
in the most basic way, your application has no controllers no views no models except the application.html.erb.
you write actions/routes in your controllers.
if you want any of your actions to be a default index page, you can redirect it in your routes.rb thats by root "controller_name#method_name"
.
thoughts: you can redirect any of your controller methods as a main/index page.
link to work: Hello Multiverse
today I have created a new application sample App
i have generated controller StaticPages with two custom made actions and wrote tests for this two actions.
I have also edited the views so as to render HTML text.
thoughts: you can render static html in your views if your application is still on the baby tracks.
link to work: sample App
I have created a new application from scratch rails new ...
installed the neccessary gems bundle gems
defined roots
and worked with static html, played around with the title
I also did failing and TDD tests.
thoughts: Automated testing allows us to write test suites that drive the develop- ment of new features, allow for confident refactoring, and catch regres- sions.
link to work: sample app
working with ruby forms.
when you pass your form data it is taken in as params
you use name attribute for forms.
thoughts: ruby on rails needs to authenticate your form and so there's an authenicity input that needs to be included in your form.
link to work: FORMS
today I have started working on just a little styling of my website
N/B: I am after web programming and not design
I used bootstrap gem for ths particular project!
thoughts: every other time you update your gem file you have to restart your server
link to work: Bootstrap
autonomous program on the internet or another network that can interact with systems or users.
today I started working with bots, I did a telegram bot to get me started which just echos what you say to it
thoughts: you need an APi so that it can allow you communicate with your server.
link to work: Bots
today I did another simple bot, today using ruby language.
it has two commands /start/
and /greet
it simply says hello back to you in different languages.
thoughts: writing bots with ruby is pretty much easy!
link to work: julienHello
today I have created a new bot, that is supposed to return links
I have learnt about messange handler and command handlers in telegram module.
thoughts: using message handlers and command handlers makes working with telegram bots easy.
link to work: julienlink
under this specific bot, I have learnt to put the message into my console, analyse the various fields it comes with and select the users username then reply to his/her message.
thoughts: whatever is returned by the API to you is pretty much the same across all languages: the id, username, date, and even first name.
link to work: JulienReply
I am trying to write my telegram bot in rust, but since it is my first encounter with rust, I am in absolute shambles
thoughts: I need to do more work on this rust thing
link to work: Telegram Bot with rust
today I started working with the meals api
thoughts: I need to teach myself how to use javascript fetch
link to work: Meals API
today I have taught myself how to use fetch api to request data from the apis.
thoughts: fetch always returns a promise irregardless of the http response. you have to jsonfy this response object.
link to work: QUIZ API
json is a standard of sending data across the web to servers and back.
you can convert objects to JSON, send them across and covert them back on the other end.
thoughts: JSON is language independent and it is also text-based.
link to work: JSON
api stands from application programming interface.
there are two types of apis. browser apis and server apis
APIs that are built into the browser and provide native features that can also be used in a web app
thoughts: Browser APIs are built into the web browser and are able to use data from the browser and the computer environment to perform more complex actions with that data
link to work: BROWSER API
i have today completed my 100 days of code.
i have learnt about:
- django framework
- javascript and a little bit about react
- ruby on rails framework
- and apis
thoughts: the last 100 days have been a season of growth, learning,relearning and unlearning. what I have realized though is that backend comes easy for me and thats what I am going to specialize on going forward
link to work: 100 days of code