Difference between revisions of "Workflow"

From CSE330 Wiki
Jump to navigationJump to search
Line 1: Line 1:
 
The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.
 
The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career.  It is remarkable how many hours you can save just by using the best interface for text editing and deployment.
 +
 +
== Setting Up SSH ==
  
 
== Komodo Edit ==
 
== Komodo Edit ==

Revision as of 07:16, 31 March 2013

The few minutes it takes to optimize your workflow will be the best few minutes you will spend in CSE 330 and your career. It is remarkable how many hours you can save just by using the best interface for text editing and deployment.

Setting Up SSH

Komodo Edit

Komodo.png

This semester in CSE 330, we will be using Komodo Edit as our editor of choice. We chose this editor because:

  1. It is free for everyone.
  2. It runs on Windows, Mac OS X, and Linux.
  3. It supports all of the languages we will be using in this class.
  4. It has a decent amount tools like auto-completion that will speed up your workflow.

Installation

Komodo Edit is already installed on the CEC lab machines. If you prefer to use your personal computer, download it from the web site: http://www.activestate.com/komodo-edit

Connecting Komodo to your Remote Instance

With a little time spend on configurations and installing a plugin, Komodo Edit enables you to edit files on your desktop and then upload those files directly to your remote instance.

Adding SSH Public Key to Keychain

In order for Komodo to connect to your instance using SSH Public Key Authentication, you need to add your public key permanently to your SSH agent utility. Instructions are below on how to do this in OS X and Windows. You may skip to the next section if you are using password-based authentication.

Mac OS X
  1. Open Terminal.
  2. Save your *.pem file to ~/.ssh/cse330.pem:
    $ mv /path/to/your/cse330.pem ~/.ssh/cse330.pem
    
  3. Run the following command to add the key to your SSH agent:
    $ ssh-add ~/.ssh/cse330.pem
    
    For more information on ssh-add, see the manual.
Windows

under construction

Configure your Server Settings in Komodo

Once you have your public key in your SSH agent (if applicable), follow these steps to tell Komodo how to connect to your remote instance.

  1. Open the Komodo Edit Preferences. In Windows, this is Edit -> Preferences; in Mac OS X, this is Komodo -> Preferences.
  2. In the menu on the left, choose Servers.
  3. For Server Type, select SFTP. (Since you have an SSH server running, you will be able to connect to your instance via SFTP.)
  4. Name it something like CSE 330 Cloud Instance.
  5. Enter the details of your instance, including your hostname and username.
    • If you are using Public Key Authentication, leave your password empty.
    • Unless you explicitly changed your SSH port, your port will be 22.
  6. Your default path will be where you want to save the files you upload. Generally, this should be the root of your web server.
    Workflow-3.png
  7. Press Add to save the server information, and then press OK.
  8. IF YOU ARE USING PUBLIC KEY AUTHENTICATION, you need to perform these additional steps:
    1. In the Komodo Edit Preferences, choose Environment.
    2. Find the information about your SSH environment:
      • Mac OS X:
        • Enter the command ssh-agent in Terminal. You should see output similar to:
          SSH_AUTH_SOCK=/tmp/ssh-xxxxx/agent.xxxxx; export SSH_AUTH_SOCK;
          SSH_AGENT_PID=xxxxx; export SSH_AGENT_PID;
          echo Agent pid xxxxx;
      • Windows:
        • under construction
    3. Add the following environment variables in Komodo:
      • Name: SSH_AUTH_SOCK
      • Name: SSH_AGENT_PID
      The values for these environment variables should be what you learned earlier in step 2.
    4. Press OK to save your changes.
  9. To test whether Komodo is able to successfully connect to your server, choose File -> Open -> Remote File. Select CSE 330 Cloud Instance from the drop-down menu. You should be able to see a list of files in your public_html directory.

Installing Upload Extension

Strangely, Komodo Edit does not come built-in with a mechanism to upload files from your computer to the server. Fortunately, the community has released an add-on that gives us this feature.

  1. In Komodo, go to Tools -> Addons.
  2. Search for the add-on named Uploader.
  3. Download and install it, and restart Komodo.
  4. In your Server preferences, create a new server (or rename an existing one) to be identical to your project name, but starting with a star. For example, in my project named FileShare, I would name the server *FileShare. The default path will be the location to which Komodo will upload your files. Note: The path should be absolute.
  5. You can now select a file and go to File -> Upload to upload it to your server.

Tip: To make things quicker, you can bind a keyboard shortcut like ctrl/cmd+D to the Upload feature by following these steps:

  1. In Komodo preferences, choose Editor -> Key Bindings.
  2. Find the "Upload" command under "General". Press in the "New Key Sequence" box, and press ctrl/cmd+D. Proceed through the on-screen instructions; you can name your new scheme Custom.
  3. Save the preferences and restart Komodo. You will now be able to upload files by simply pressing ctrl/cmd+D.

SourceTree

SourceTree is a tool that enables you to perform version control using a graphical user interface. It is free and available for Windows 7+ and Mac OS X 10.6+.

SourceTree is available on the Mac App Store. Windows users (and OS X users who don't like the App Store) may install it from http://sourcetreeapp.com/

Git

Git is a distributed version control system that enables you to track changes to your code and work with collaborators on the same code base. In CSE 132, you used Subversion (SVN), which is also version control system.

Git, like SVN, is a command-line tool. However, SourceTree enables you to use Git without having to pull up a Terminal window every time you need to perform an action.

In Module 5, you will learn more advanced techniques for using Git. However, for Modules 2-4, you will be using Git primarily as a method to push your changes to your remote repository.

Configuring Git/SourceTree

Once you install SourceTree, you need to tell it your name so that it knows how to tag changes you make.

  1. Open the SourceTree Preferences (SourceTree->Preferences on OS X or Tools->Preferences on Windows).
  2. Check the box that says "Allow SourceTree to modify your global Mercurial and Git configuration files".
  3. Enter your name and e-mail address.

Note: This actually does the same thing as running git config --global user.name <NAME HERE> and git config --global user.email <EMAIL HERE> from the command line.

Cloning a Repository

We will start by cloning a remote Git repository.

"Cloning" in Git is much like "checking out" in SVN: a remote copy of the repository is copied down to a local working directory. Word of Caution: Git uses the term "checkout" to mean something different (which you will learn in Module 5), so do not use the words "clone" and "checkout" interchangeably.

If you wanted to clone a repository on the command line, the command would be:

$ git clone git://www.example.com/url-of-repo destination-path

In SourceTree, go to File->New, enter the remote repository URL and the destination path, and press "Clone". The destination path is where you want the repository's files to be copied on your personal computer; the path should point to either an empty or a nonexistent directory on your personal computer. In this screenshot, I am cloning the repository for the Fedora Linux kernel:

SourceTree-Clone.png

The remote repository will now be cloned onto your personal computer and all ready to use.

Starting a Project

When you start a new project, whether individual or group, you should create a new directory and a new Komodo Project file.

  1. Create a new directory in your repository named after the project you will be starting (e.g., fileshare).
  2. In Komodo, choose Project -> New Project (or press shift-ctrl-N).
  3. Navigate to the directory you just created, enter a name for the project (e.g., FileShare.komodoproject), and press "Save".
  4. You should now see a window like this:
    Workflow-1.png
  5. Press ctrl-N (or cmd-N) to create a new file. Save it in your project. For example, you could create a page named index.html with the Quick and Easy Page Layout:
    Workflow-2.png
  6. Continue creating and editing the files from your site.
    Tip: To change between files without using a mouse, press ctrl-PageUp and ctrl-PageDown (cmd instead of ctrl on OS X). Many computers without explicit PageUp and PageDown buttons bind them to fn-Up and fn-Down. For example, on a MacBook Pro, to change to the next tab, you would press three keys: fn+cmd+down.
  7. When you are ready, upload your files to your remote server. To do this, go to File -> Save as Other -> Remote File.