/// <summary> /// Our site wide search action method /// </summary> public JsonResult GetYouTubeData(string youTubeUrl) { string videoID = string.Empty; var videoUri = new Uri(youTubeUrl); if (youTubeUrl.StartsWith("http://www.youtube.com/") || youTubeUrl.StartsWith("https://www.youtube.com/")) { videoID = HttpUtility.ParseQueryString(videoUri.Query).Get("v"); } else if (youTubeUrl.StartsWith("http://youtu.be/")) { videoID = youTubeUrl.Replace("http://youtu.be/",""); } else { throw new Exception("Not a valid you tube url"); } var youTubeData = new MediaService().GetYouTubeVideoData(videoID); return Json(youTubeData); }
/// <summary> /// Our site wide search action method /// </summary> public JsonResult GetVimeoData(string vimeoUrl) { if (!vimeoUrl.StartsWith("http://www.vimeo.com/") && !vimeoUrl.StartsWith("http://vimeo.com/")) { throw new Exception("Not a valid vimeo url"); } //http://www.vimeo.com/20278551?ab = /20278551 var videoUriWithoutQuery = new Uri(vimeoUrl).AbsolutePath; var videoID = videoUriWithoutQuery.Replace("/",""); var vimeoData = new MediaService().GetVimeoVideoData(videoID); return Json(vimeoData); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <param name="originalImageUrl"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="h"></param> /// <returns></returns> public string SaveAreaAvatar(Area obj, Stream stream, ImageCropOpts cropOpts) { var meta = SaveAreaAvatarAuthorization(obj, stream, cropOpts); var original = obj.GetCloneWithGeo(); //-- Also save the image to the location's media real var media = new MediaService().CreateImageMedia(new Media() { FeedVisible = true, Title = "Climbing pic of " + obj.Name, ContentType = "image/jpg" }, obj.ID, stream); var newImgUrl = SaveAvatar240Thumb(stream, obj.Avatar, obj.NameUrlPart, ImageManager.ClimbinAreaPath, fileName => { obj.Avatar = fileName; areaRepo.Update(obj); }, cropOpts, media.Content); //-- No change occurs to the mod's profile because the image has to be verified by other users SaveModActionAndUpdateModProfile(ModActionType.AreaSetAvatar, original, obj, meta, (m, actionID) => m.SetAvatarChanged(actionID), null, "set map img {0}", obj.Name); return(newImgUrl); }
/// <summary> /// Saves the climbing image (used as the avatar/map image) /// </summary> /// <param name="obj"></param> /// <param name="stream"></param> /// <param name="cropOpts"></param> /// <returns></returns> //public string SaveLocationIndoorAvatar(LocationIndoor obj, Stream stream, ImageCropOpts cropOpts) //{ // throw new NotImplementedException("SaveLocationIndoorAvatar"); // //var meta = SaveLocationIndoorAvatarAuthorization(obj, stream, cropOpts); // //var original = obj.GetSimpleTypeClone(); // ////-- Also save the image to the location's media real // //var media = new MediaService().CreateImageMedia(new Media() { Title = "Climbing pic of " + obj.Name, ContentType = "image/jpg" }, obj.ID, stream); // //var newImgUrl = SaveAvatar240Thumb(stream, obj.Avatar, obj.NameUrlPart, ImageManager.ClimbingIndoorPath, // // fileName => { obj.Avatar = fileName; locIndoorRepo.Update(obj); }, cropOpts, media.Content); // ////-- No change occurs to the mod's profile because the image has to be verified by other users // //SaveModActionAndUpdateModProfile(ModActionType.LocationIndoorSetAvatar, original, obj, meta, // // (m, actionID) => m.SetAvatarChanged(actionID), null, "set map img {0}", obj.Name); // //return newImgUrl; //} public Media SaveLocationAvatar(Location obj, Stream stream, ImageCropOpts cropOpts) { var locTypePath = ImageManager.ClimbingIndoorPath; var actionType = ModActionType.LocationIndoorSetAvatar; if (obj.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing) { locTypePath = ImageManager.ClimbingOutdoorPath; actionType = ModActionType.LocationOutdoorSetAvatar; } var meta = SaveLocationAvatarAuthorization(obj, stream, cropOpts); var original = obj.GetSimpleTypeClone(); //-- Also save the image to the location's media real var media = new MediaService().CreateImageMedia(new Media() { FeedVisible = true, Title = "Climbing pic of " + obj.Name, ContentType = "image/jpg" }, obj.ID, stream); SaveAvatar240Thumb(stream, obj.Avatar, obj.NameUrlPart, locTypePath, fileName => { obj.Avatar = fileName; locRepo.UpdateLocationAvatar(obj.ID, fileName); }, cropOpts, media.Content); //-- No change occurs to the mod's profile because the image has to be verified by other users SaveModActionAndUpdateModProfile(actionType, original, obj, meta, (m, actionID) => m.SetAvatarChanged(actionID), null, "set map img {0}", obj.Name); return media; }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <param name="originalImageUrl"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="w"></param> /// <param name="h"></param> /// <returns></returns> public string SaveAreaAvatar(Area obj, Stream stream, ImageCropOpts cropOpts) { var meta = SaveAreaAvatarAuthorization(obj, stream, cropOpts); var original = obj.GetCloneWithGeo(); //-- Also save the image to the location's media real var media = new MediaService().CreateImageMedia(new Media() { FeedVisible = true, Title = "Climbing pic of " + obj.Name, ContentType = "image/jpg" }, obj.ID, stream); var newImgUrl = SaveAvatar240Thumb(stream, obj.Avatar, obj.NameUrlPart, ImageManager.ClimbinAreaPath, fileName => { obj.Avatar = fileName; areaRepo.Update(obj); }, cropOpts, media.Content); //-- No change occurs to the mod's profile because the image has to be verified by other users SaveModActionAndUpdateModProfile(ModActionType.AreaSetAvatar, original, obj, meta, (m, actionID) => m.SetAvatarChanged(actionID), null, "set map img {0}", obj.Name); return newImgUrl; }