Commit e9f21bf3 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Fixed `ihaskell setup` to untar a profile.tar file

parent 215668fc
......@@ -42,20 +42,12 @@ build-type: Simple
-- Constraint on the version of Cabal needed to build this package.
cabal-version: >=1.8
extra-source-files:
config/custom.js
config/ipython_config.py
config/ipython_console_config.py
config/ipython_notebook_config.py
config/ipython_qtconsole_config.py
deps/codecell.js
deps/tooltip.js
build-parser.sh
images/ihaskell-logo.png
HaskellParser.y.pp
data-files:
profile/profile.tar
library
build-depends: base ==4.6.*,
tar,
ghc-parser,
unix >= 2.6,
hspec,
......@@ -83,6 +75,7 @@ library
mtl == 2.1.*,
template-haskell
exposed-modules: IHaskell.Display,
Paths_ihaskell,
IHaskell.Types,
IHaskell.Message.UUID
......@@ -111,6 +104,7 @@ executable IHaskell
-- Other library packages from which modules are imported.
build-depends: base ==4.6.*,
tar,
ghc-parser,
unix >= 2.6,
hspec,
......@@ -143,6 +137,7 @@ Test-Suite hspec
Ghc-Options: -threaded
Main-Is: Hspec.hs
build-depends: base ==4.6.*,
tar,
ghc-parser,
unix >= 2.6,
hspec,
......
......@@ -17,10 +17,12 @@ import System.Directory
import qualified Filesystem.Path.CurrentOS as FS
import Data.List.Utils (split)
import Data.String.Utils (rstrip)
import Text.Printf
import qualified System.IO.Strict as StrictIO
import qualified IHaskell.Config as Config
import qualified Paths_ihaskell as Paths
import qualified Codec.Archive.Tar as Tar
-- | Run IPython with any arguments.
ipython :: Bool -- ^ Whether to suppress output.
......@@ -86,7 +88,9 @@ setupIPythonProfile profile = shelly $ do
ipythonDir <- pack <$> rstrip <$> ipython True ["locate"]
let profileDir = ipythonDir ++ "/profile_" ++ pack profile ++ "/"
path <- getIHaskellPath
liftIO $ copyProfile profileDir
insertIHaskellPath profileDir
{-
writeConfigFilesTo profileDir path
-- | Write IPython configuration files to the profile directory.
......@@ -114,6 +118,25 @@ writeConfigFilesTo profileDir ihaskellPath = do
where
conf filename = fromText $ profileDir ++ filename
-}
-- | Copy the profile files into the IPython profile.
copyProfile :: Text -> IO ()
copyProfile profileDir = do
profileTar <- Paths.getDataFileName "profile/profile.tar"
Tar.extract (unpack profileDir) profileTar
-- | Insert the IHaskell path into the IPython configuration.
insertIHaskellPath :: Text -> Sh ()
insertIHaskellPath profileDir = do
path <- getIHaskellPath
let filename = profileDir ++ "ipython_config.py"
template = "exe = '%s'.replace(' ', '\\\\ ')"
exeLine = printf template $ unpack path :: String
liftIO $ do
contents <- StrictIO.readFile $ unpack filename
writeFile (fromText filename) $ exeLine ++ "\n" ++ contents
-- | Get the absolute path to this IHaskell executable.
getIHaskellPath :: Sh String
......
......@@ -16,6 +16,10 @@ build-type: Custom
-- extra-source-files:
cabal-version: >=1.10
extra-source-files:
build-parser.sh
HaskellParser.y.pp
library
exposed-modules: Language.Haskell.GHC.Parser,
Language.Haskell.GHC.HappyParser
......@@ -24,3 +28,4 @@ library
build-depends: base >=4.6 && <4.7, ghc == 7.6.3
-- hs-source-dirs:
default-language: Haskell2010
# Available Subsitutions:
# ${executable}: Path to IHaskell kernel.
# Available Variables:
# exe: Path to IHaskell kernel.
c = get_config()
exe = '${executable}'.replace(' ', '\\\\ ')
c.KernelManager.kernel_cmd = [exe, 'kernel', '{connection_file}']
c.Session.key = ''
c.Session.keyfile = ''
......@@ -33,7 +33,7 @@ var IPython = (function (IPython) {
this.time_before_tooltip = 800;
// handle to html
this.tooltip = \$('#tooltip');
this.tooltip = $('#tooltip');
this._hidden = true;
// variable for consecutive call
......@@ -48,40 +48,40 @@ var IPython = (function (IPython) {
this._hide_if_no_docstring = false;
// contain the button in the upper right corner
this.buttons = \$('<div/>').addClass('tooltipbuttons');
this.buttons = $('<div/>').addClass('tooltipbuttons');
// will contain the docstring
this.text = \$('<div/>').addClass('tooltiptext').addClass('smalltooltip');
this.text = $('<div/>').addClass('tooltiptext').addClass('smalltooltip');
// build the buttons menu on the upper right
// expand the tooltip to see more
var expandlink = \$('<a/>').attr('href', "#").addClass("ui-corner-all") //rounded corner
var expandlink = $('<a/>').attr('href', "#").addClass("ui-corner-all") //rounded corner
.attr('role', "button").attr('id', 'expanbutton').attr('title', 'Grow the tooltip vertically (press tab 2 times)').click(function () {
that.expand()
}).append(
\$('<span/>').text('Expand').addClass('ui-icon').addClass('ui-icon-plus'));
$('<span/>').text('Expand').addClass('ui-icon').addClass('ui-icon-plus'));
// open in pager
var morelink = \$('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button').attr('title', 'show the current docstring in pager (press tab 4 times)');
var morespan = \$('<span/>').text('Open in Pager').addClass('ui-icon').addClass('ui-icon-arrowstop-l-n');
var morelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button').attr('title', 'show the current docstring in pager (press tab 4 times)');
var morespan = $('<span/>').text('Open in Pager').addClass('ui-icon').addClass('ui-icon-arrowstop-l-n');
morelink.append(morespan);
morelink.click(function () {
that.showInPager(that._old_cell);
});
// close the tooltip
var closelink = \$('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button');
var closespan = \$('<span/>').text('Close').addClass('ui-icon').addClass('ui-icon-close');
var closelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button');
var closespan = $('<span/>').text('Close').addClass('ui-icon').addClass('ui-icon-close');
closelink.append(closespan);
closelink.click(function () {
that.remove_and_cancel_tooltip(true);
});
this._clocklink = \$('<a/>').attr('href', "#");
this._clocklink = $('<a/>').attr('href', "#");
this._clocklink.attr('role', "button");
this._clocklink.addClass('ui-button');
this._clocklink.attr('title', 'Tootip is not dismissed while typing for 10 seconds');
var clockspan = \$('<span/>').text('Close');
var clockspan = $('<span/>').text('Close');
clockspan.addClass('ui-icon');
clockspan.addClass('ui-icon-clock');
this._clocklink.append(clockspan);
......@@ -104,7 +104,7 @@ var IPython = (function (IPython) {
// we need a phony element to make the small arrow
// of the tooltip in css
// we will move the arrow later
this.arrow = \$('<div/>').addClass('pretooltiparrow');
this.arrow = $('<div/>').addClass('pretooltiparrow');
this.tooltip.append(this.buttons);
this.tooltip.append(this.arrow);
this.tooltip.append(this.text);
......@@ -150,14 +150,14 @@ var IPython = (function (IPython) {
Tooltip.prototype.expand = function () {
this.text.removeClass('smalltooltip');
this.text.addClass('bigtooltip');
\$('#expanbutton').hide('slow');
$('#expanbutton').hide('slow');
}
// deal with all the logic of hiding the tooltip
// and reset it's status
Tooltip.prototype._hide = function () {
this.tooltip.fadeOut('fast');
\$('#expanbutton').show('slow');
$('#expanbutton').show('slow');
this.text.removeClass('bigtooltip');
this.text.addClass('smalltooltip');
// keep scroll top to be sure to always see the first line
......@@ -201,8 +201,8 @@ var IPython = (function (IPython) {
// basicaly you shoul be able to get xxx.xxx.xxx from
// something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2,
// remove everything between matchin bracket (need to iterate)
var matchBracket = /\\([^\\(\\)]+\\)/g;
var endBracket = /\\([^\\(]*\$/g;
var matchBracket = /\([^\(\)]+\)/g;
var endBracket = /\([^\(]*$/g;
var oldfunc = func;
func = func.replace(matchBracket, "");
......@@ -213,13 +213,13 @@ var IPython = (function (IPython) {
// remove everything after last open bracket
func = func.replace(endBracket, "");
var re = /[a-z_][0-9a-z._!]+\$/gi; // casse insensitive
var re = /[a-z_][0-9a-z._!]+$/gi; // casse insensitive
var that = this
var callbacks_v2 = function(data){
\$.proxy(that._show(data.content), that)
$.proxy(that._show(data.content), that)
}
var callbacks = {
'object_info_reply': \$.proxy(this._show, this)
'object_info_reply': $.proxy(this._show, this)
}
if(cell.kernel.object_info_request){
// we are on IPython 1.x and early 2.0 (before bidirectionnal js comm)
......@@ -306,9 +306,9 @@ var IPython = (function (IPython) {
// do some math to have the tooltip arrow on more or less on left or right
// width of the editor
var w = \$(this.code_mirror.getScrollerElement()).width();
var w = $(this.code_mirror.getScrollerElement()).width();
// ofset of the editor
var o = \$(this.code_mirror.getScrollerElement()).offset();
var o = $(this.code_mirror.getScrollerElement()).offset();
// whatever anchor/head order but arrow at mid x selection
var anchor = this.code_mirror.cursorCoords(false);
......@@ -364,9 +364,9 @@ var IPython = (function (IPython) {
this._hidden = false;
this.text.children().remove();
var pre = \$('<pre/>').html(utils.fixConsole(docstring));
var pre = $('<pre/>').html(utils.fixConsole(docstring));
if (defstring) {
var defstring_html = \$('<pre/>').html(utils.fixConsole(defstring));
var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
this.text.append(defstring_html);
}
this.text.append(pre);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment